annotate src/DML/MainVisBundle/Resources/assets/marionette/modules/RepresentationModule/RepresentationModule.31-Master.view.collection._histogram.js @ 1:f38015048f48 tip

Added GPL
author Daniel Wolff
date Sat, 13 Feb 2016 20:43:38 +0100
parents 493bcb69166c
children
rev   line source
Daniel@0 1 "use strict";
Daniel@0 2
Daniel@0 3 App.module("RepresentationModule", function(RepresentationModule, App, Backbone, Marionette, $, _, Logger) {
Daniel@0 4
Daniel@0 5 RepresentationModule.addInitializer(function(options){
Daniel@0 6
Daniel@0 7 RepresentationModule.registerMaster({
Daniel@0 8 id: "view.collection._histogram",
Daniel@0 9 inherit: "view._histogram",
Daniel@0 10
Daniel@0 11 options: {
Daniel@0 12 },
Daniel@0 13
Daniel@0 14
Daniel@0 15 // =================================================================
Daniel@0 16 // dynamic derived vis instance data
Daniel@0 17
Daniel@0 18
Daniel@0 19 // -----------------------------------------------------------------
Daniel@0 20 // dynamic derived vis instance data - base
Daniel@0 21
Daniel@0 22
Daniel@0 23 // =================================================================
Daniel@0 24 // vis instance rendering
Daniel@0 25
Daniel@0 26 _generateHistogramOptions: function(pid) {
Daniel@0 27 var options = {};
Daniel@0 28 options.colorForBars = "#3182bd";
Daniel@0 29 options.colorForOverlay = "#31a354";
Daniel@0 30
Daniel@0 31 options.dataDefinition = {};
Daniel@0 32 options.dataDefinition.forXs = null;
Daniel@0 33 options.dataDefinition.forBars = null;
Daniel@0 34 options.dataDefinition.forFlats = null;
Daniel@0 35
Daniel@0 36 switch (pid) {
Daniel@0 37 case "tempo-histogram":
Daniel@0 38 case "pitch-histogram":
Daniel@0 39 options.dataDefinition.forXs = "edges";
Daniel@0 40 options.dataDefinition.forBars = "counts";
Daniel@0 41 break;
Daniel@0 42 case "midi-pitch-histogram":
Daniel@0 43 options.dataDefinition.forXs = "values";
Daniel@0 44 options.dataDefinition.forBars = "counts";
Daniel@0 45 break;
Daniel@0 46 case "mean-tempo-curve":
Daniel@0 47 options.dataDefinition.forXs = function(data){return _.range(0, data.means.length);};
Daniel@0 48 options.dataDefinition.forBars = "means";
Daniel@0 49 options.dataDefinition.forFlats = "std_devs";
Daniel@0 50 break;
Daniel@0 51 case "tuning-stats":
Daniel@0 52 options.dataDefinition.forXs = function(data){return data.stats.hist.edges;};
Daniel@0 53 options.dataDefinition.forBars = function(data){return data.stats.hist.counts;};
Daniel@0 54 options.dataDefinition.forXMean = function(data){return data.stats.mean;};
Daniel@0 55 options.dataDefinition.forXStdDev = function(data){return data.stats["std-dev"];};
Daniel@0 56 break;
Daniel@0 57 case "tonic-histogram":
Daniel@0 58 options.dataDefinition.forXs = "values";
Daniel@0 59 options.dataDefinition.forBars = "counts";
Daniel@0 60 break;
Daniel@0 61 case "pitch-class-histogram":
Daniel@0 62 case "tonic-relative-pitch-class-histogram":
Daniel@0 63 options.dataDefinition.forXs = "values";
Daniel@0 64 options.dataDefinition.forBars = "counts";
Daniel@0 65 break;
Daniel@0 66 }
Daniel@0 67 return options;
Daniel@0 68 }
Daniel@0 69 });
Daniel@0 70 });
Daniel@0 71 }, Logger);