Mercurial > hg > dml-open-vis
comparison src/DML/MainVisBundle/Resources/assets/marionette/modules/GraphicsRenderingModule/GraphicsRenderingModule.20-Renderer._.js @ 0:493bcb69166c
added public content
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 20:54:02 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:493bcb69166c |
---|---|
1 "use strict"; | |
2 | |
3 App.module("GraphicsRenderingModule", function(GraphicsRenderingModule, App, Backbone, Marionette, $, _, Logger) { | |
4 | |
5 GraphicsRenderingModule.addInitializer(function(options){ | |
6 | |
7 GraphicsRenderingModule.registerRenderer({ | |
8 id: "_", | |
9 | |
10 defaultVegaConfig: { | |
11 colorForBackground: "#fff", | |
12 colorForAxisLabels: "#999", | |
13 colorForAxes: "#ccc", | |
14 colorForBackgroundFill: "#f0f0f0", | |
15 fontFace: "'Web Open Sans', Verdana, sans-serif", | |
16 fontSize: 10, | |
17 fontSizeForLabelsInAxis: 10, | |
18 fontSizeForLabelsInSecondaryAxis: 8, | |
19 | |
20 data: [], | |
21 scales: [], | |
22 axes: [], | |
23 marks: [], | |
24 // these are used for debugging (easy to make stuff invisible to test if things work without it) | |
25 xdata: [], | |
26 xscales: [], | |
27 xaxes: [], | |
28 xmarks: [] | |
29 }, | |
30 | |
31 render: function($element, data, options) { | |
32 | |
33 // vc stands for vega config | |
34 // FIXME proper deep clone is needed | |
35 var vc = _.mapObject(this.defaultVegaConfig, _.clone); | |
36 | |
37 vc = _.extend(vc, options); | |
38 | |
39 vc.totalWidth = $element.width(); | |
40 vc.totalHeight = $element.height(); | |
41 | |
42 this._formVC(vc, data); | |
43 | |
44 var vegaSpec = { | |
45 "background": vc.colorForBackground, | |
46 "width": vc.width, | |
47 "height": vc.height, | |
48 "padding": vc.padding, | |
49 "data": vc.data, | |
50 "scales": vc.scales, | |
51 "axes": vc.axes, | |
52 "marks": vc.marks | |
53 }; | |
54 | |
55 var $cover = $.bem.generateElement("vis-instance", "cover", ["category_process", "visible"]); | |
56 var $coverMessage = $.bem.generateElement("vis-instance", "cover-message").text("Drawing..."); | |
57 $cover.append($coverMessage); | |
58 $element.append($cover); | |
59 GraphicsRenderingModule.vegaAsync($element, vegaSpec, "svg"); | |
60 }, | |
61 | |
62 _formVC: function(vc, data, options) {}, | |
63 }); | |
64 }); | |
65 }, Logger); |