Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / static / fusion / d3 / js / models / boilerplate.js
1
2 nv.models.chartName = function() {
3   "use strict";
4   //============================================================
5   // Public Variables with Default Settings
6   //------------------------------------------------------------
7
8
9   var margin = {top: 30, right: 10, bottom: 10, left: 10}
10     , width = 960
11     , height = 500
12     , color = nv.utils.getColor(d3.scale.category20c().range())
13     , dispatch = d3.dispatch('stateChange', 'changeState')
14     ;
15
16   //============================================================
17
18
19   //============================================================
20   // Private Variables
21   //------------------------------------------------------------
22
23
24   //============================================================
25
26
27   function chart(selection) {
28     selection.each(function(data) {
29       var availableWidth = width - margin.left - margin.right,
30           availableHeight = height - margin.top - margin.bottom,
31           container = d3.select(this);
32
33
34       //------------------------------------------------------------
35       // Setup Scales
36
37
38       //------------------------------------------------------------
39
40
41       //------------------------------------------------------------
42       // Setup containers and skeleton of chart
43
44       var wrap = container.selectAll('g.nv-wrap.nv-chartName').data([data]);
45       var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-chartName');
46       var gEnter = wrapEnter.append('g');
47       var g = wrap.select('g')
48
49       gEnter.append('g').attr('class', 'nv-mainWrap');
50
51       wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
52
53       //------------------------------------------------------------
54
55
56
57
58     });
59
60     return chart;
61   }
62
63
64   //============================================================
65   // Expose Public Variables
66   //------------------------------------------------------------
67
68
69   chart.dispatch = dispatch;
70
71   chart.options = nv.utils.optionsFunc.bind(chart);
72   
73   chart.margin = function(_) {
74     if (!arguments.length) return margin;
75     margin.top    = typeof _.top    != 'undefined' ? _.top    : margin.top;
76     margin.right  = typeof _.right  != 'undefined' ? _.right  : margin.right;
77     margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
78     margin.left   = typeof _.left   != 'undefined' ? _.left   : margin.left;
79     return chart;
80   };
81
82   chart.width = function(_) {
83     if (!arguments.length) return width;
84     width = _;
85     return chart;
86   };
87
88   chart.height = function(_) {
89     if (!arguments.length) return height;
90     height = _;
91     return chart;
92   };
93
94   chart.color = function(_) {
95     if (!arguments.length) return color;
96     color = nv.utils.getColor(_)
97     return chart;
98   };
99
100   //============================================================
101
102
103   return chart;
104 }