Daniel@0: "use strict"; Daniel@0: Daniel@0: App.module("RepresentationModule", function(RepresentationModule, App, Backbone, Marionette, $, _, Logger) { Daniel@0: Daniel@0: RepresentationModule.addInitializer(function(options){ Daniel@0: Daniel@0: RepresentationModule.registerMaster({ Daniel@0: id: "view.collection._histogram", Daniel@0: inherit: "view._histogram", Daniel@0: Daniel@0: options: { Daniel@0: }, Daniel@0: Daniel@0: Daniel@0: // ================================================================= Daniel@0: // dynamic derived vis instance data Daniel@0: Daniel@0: Daniel@0: // ----------------------------------------------------------------- Daniel@0: // dynamic derived vis instance data - base Daniel@0: Daniel@0: Daniel@0: // ================================================================= Daniel@0: // vis instance rendering Daniel@0: Daniel@0: _generateHistogramOptions: function(pid) { Daniel@0: var options = {}; Daniel@0: options.colorForBars = "#3182bd"; Daniel@0: options.colorForOverlay = "#31a354"; Daniel@0: Daniel@0: options.dataDefinition = {}; Daniel@0: options.dataDefinition.forXs = null; Daniel@0: options.dataDefinition.forBars = null; Daniel@0: options.dataDefinition.forFlats = null; Daniel@0: Daniel@0: switch (pid) { Daniel@0: case "tempo-histogram": Daniel@0: case "pitch-histogram": Daniel@0: options.dataDefinition.forXs = "edges"; Daniel@0: options.dataDefinition.forBars = "counts"; Daniel@0: break; Daniel@0: case "midi-pitch-histogram": Daniel@0: options.dataDefinition.forXs = "values"; Daniel@0: options.dataDefinition.forBars = "counts"; Daniel@0: break; Daniel@0: case "mean-tempo-curve": Daniel@0: options.dataDefinition.forXs = function(data){return _.range(0, data.means.length);}; Daniel@0: options.dataDefinition.forBars = "means"; Daniel@0: options.dataDefinition.forFlats = "std_devs"; Daniel@0: break; Daniel@0: case "tuning-stats": Daniel@0: options.dataDefinition.forXs = function(data){return data.stats.hist.edges;}; Daniel@0: options.dataDefinition.forBars = function(data){return data.stats.hist.counts;}; Daniel@0: options.dataDefinition.forXMean = function(data){return data.stats.mean;}; Daniel@0: options.dataDefinition.forXStdDev = function(data){return data.stats["std-dev"];}; Daniel@0: break; Daniel@0: case "tonic-histogram": Daniel@0: options.dataDefinition.forXs = "values"; Daniel@0: options.dataDefinition.forBars = "counts"; Daniel@0: break; Daniel@0: case "pitch-class-histogram": Daniel@0: case "tonic-relative-pitch-class-histogram": Daniel@0: options.dataDefinition.forXs = "values"; Daniel@0: options.dataDefinition.forBars = "counts"; Daniel@0: break; Daniel@0: } Daniel@0: return options; Daniel@0: } Daniel@0: }); Daniel@0: }); Daniel@0: }, Logger);