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