Daniel@0: "use strict"; Daniel@0: Daniel@0: App.module("GraphicsRenderingModule", function(GraphicsRenderingModule, App, Backbone, Marionette, $, _, Logger) { Daniel@0: Daniel@0: GraphicsRenderingModule.addInitializer(function(options){ Daniel@0: Daniel@0: GraphicsRenderingModule.registerRenderer({ Daniel@0: id: "_", Daniel@0: Daniel@0: defaultVegaConfig: { Daniel@0: colorForBackground: "#fff", Daniel@0: colorForAxisLabels: "#999", Daniel@0: colorForAxes: "#ccc", Daniel@0: colorForBackgroundFill: "#f0f0f0", Daniel@0: fontFace: "'Web Open Sans', Verdana, sans-serif", Daniel@0: fontSize: 10, Daniel@0: fontSizeForLabelsInAxis: 10, Daniel@0: fontSizeForLabelsInSecondaryAxis: 8, Daniel@0: Daniel@0: data: [], Daniel@0: scales: [], Daniel@0: axes: [], Daniel@0: marks: [], Daniel@0: // these are used for debugging (easy to make stuff invisible to test if things work without it) Daniel@0: xdata: [], Daniel@0: xscales: [], Daniel@0: xaxes: [], Daniel@0: xmarks: [] Daniel@0: }, Daniel@0: Daniel@0: render: function($element, data, options) { Daniel@0: Daniel@0: // vc stands for vega config Daniel@0: // FIXME proper deep clone is needed Daniel@0: var vc = _.mapObject(this.defaultVegaConfig, _.clone); Daniel@0: Daniel@0: vc = _.extend(vc, options); Daniel@0: Daniel@0: vc.totalWidth = $element.width(); Daniel@0: vc.totalHeight = $element.height(); Daniel@0: Daniel@0: this._formVC(vc, data); Daniel@0: Daniel@0: var vegaSpec = { Daniel@0: "background": vc.colorForBackground, Daniel@0: "width": vc.width, Daniel@0: "height": vc.height, Daniel@0: "padding": vc.padding, Daniel@0: "data": vc.data, Daniel@0: "scales": vc.scales, Daniel@0: "axes": vc.axes, Daniel@0: "marks": vc.marks Daniel@0: }; Daniel@0: Daniel@0: var $cover = $.bem.generateElement("vis-instance", "cover", ["category_process", "visible"]); Daniel@0: var $coverMessage = $.bem.generateElement("vis-instance", "cover-message").text("Drawing..."); Daniel@0: $cover.append($coverMessage); Daniel@0: $element.append($cover); Daniel@0: GraphicsRenderingModule.vegaAsync($element, vegaSpec, "svg"); Daniel@0: }, Daniel@0: Daniel@0: _formVC: function(vc, data, options) {}, Daniel@0: }); Daniel@0: }); Daniel@0: }, Logger);