nvd3-rails 0.0.1 → 0.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +3 -0
  3. data/README.md +7 -71
  4. data/lib/nvd3/rails/version.rb +1 -1
  5. data/nvd3-rails.gemspec +3 -3
  6. metadata +8 -111
  7. data/vendor/assets/javascripts/nvd3/.git.sample/HEAD +0 -1
  8. data/vendor/assets/javascripts/nvd3/.git.sample/config +0 -13
  9. data/vendor/assets/javascripts/nvd3/.git.sample/description +0 -1
  10. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/applypatch-msg.sample +0 -15
  11. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/commit-msg.sample +0 -24
  12. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/post-update.sample +0 -8
  13. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-applypatch.sample +0 -14
  14. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-commit.sample +0 -50
  15. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-push.sample +0 -53
  16. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-rebase.sample +0 -169
  17. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/prepare-commit-msg.sample +0 -36
  18. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/update.sample +0 -128
  19. data/vendor/assets/javascripts/nvd3/.git.sample/index +0 -0
  20. data/vendor/assets/javascripts/nvd3/.git.sample/info/exclude +0 -6
  21. data/vendor/assets/javascripts/nvd3/.git.sample/logs/HEAD +0 -1
  22. data/vendor/assets/javascripts/nvd3/.git.sample/logs/refs/heads/master +0 -1
  23. data/vendor/assets/javascripts/nvd3/.git.sample/logs/refs/remotes/origin/HEAD +0 -1
  24. data/vendor/assets/javascripts/nvd3/.git.sample/objects/pack/pack-babbb312d58dd7f03870b530a1b9a84c80918be3.idx +0 -0
  25. data/vendor/assets/javascripts/nvd3/.git.sample/objects/pack/pack-babbb312d58dd7f03870b530a1b9a84c80918be3.pack +0 -0
  26. data/vendor/assets/javascripts/nvd3/.git.sample/packed-refs +0 -5
  27. data/vendor/assets/javascripts/nvd3/.git.sample/refs/heads/master +0 -1
  28. data/vendor/assets/javascripts/nvd3/.git.sample/refs/remotes/origin/HEAD +0 -1
  29. data/vendor/assets/javascripts/nvd3/build.bat +0 -6
  30. data/vendor/assets/javascripts/nvd3/deprecated/bar.html +0 -198
  31. data/vendor/assets/javascripts/nvd3/deprecated/bar.js +0 -250
  32. data/vendor/assets/javascripts/nvd3/deprecated/charts/cumulativeLineChart.js +0 -174
  33. data/vendor/assets/javascripts/nvd3/deprecated/charts/discreteBarChart.js +0 -157
  34. data/vendor/assets/javascripts/nvd3/deprecated/charts/lineChart.js +0 -159
  35. data/vendor/assets/javascripts/nvd3/deprecated/charts/lineChartDaily.js +0 -168
  36. data/vendor/assets/javascripts/nvd3/deprecated/charts/stackedAreaChart.js +0 -177
  37. data/vendor/assets/javascripts/nvd3/deprecated/cumulativeLine.html +0 -171
  38. data/vendor/assets/javascripts/nvd3/deprecated/cumulativeLine.js +0 -334
  39. data/vendor/assets/javascripts/nvd3/deprecated/discreteBarChartWithEnabledTooltip.html +0 -129
  40. data/vendor/assets/javascripts/nvd3/deprecated/discreteBarChartWithEnabledTooltip.js +0 -222
  41. data/vendor/assets/javascripts/nvd3/deprecated/discreteBarWithAxes.html +0 -172
  42. data/vendor/assets/javascripts/nvd3/deprecated/discreteBarWithAxes.js +0 -152
  43. data/vendor/assets/javascripts/nvd3/deprecated/lineChart-old.html +0 -83
  44. data/vendor/assets/javascripts/nvd3/deprecated/lineChartDaily.html +0 -109
  45. data/vendor/assets/javascripts/nvd3/deprecated/linePlusBar.html +0 -173
  46. data/vendor/assets/javascripts/nvd3/deprecated/linePlusBar.js +0 -250
  47. data/vendor/assets/javascripts/nvd3/deprecated/lineWithFocus.html +0 -137
  48. data/vendor/assets/javascripts/nvd3/deprecated/lineWithFocus.js +0 -354
  49. data/vendor/assets/javascripts/nvd3/deprecated/lineWithFourAxes.html +0 -144
  50. data/vendor/assets/javascripts/nvd3/deprecated/lineWithFourAxes.js +0 -218
  51. data/vendor/assets/javascripts/nvd3/deprecated/lineWithLegend.html +0 -142
  52. data/vendor/assets/javascripts/nvd3/deprecated/lineWithLegend.js +0 -176
  53. data/vendor/assets/javascripts/nvd3/deprecated/monthendAxis.html +0 -99
  54. data/vendor/assets/javascripts/nvd3/deprecated/multiBarHorizontalWithLegend.html +0 -258
  55. data/vendor/assets/javascripts/nvd3/deprecated/multiBarHorizontalWithLegend.js +0 -226
  56. data/vendor/assets/javascripts/nvd3/deprecated/multiBarWithLegend.html +0 -162
  57. data/vendor/assets/javascripts/nvd3/deprecated/multiBarWithLegend.js +0 -249
  58. data/vendor/assets/javascripts/nvd3/deprecated/pie.js +0 -263
  59. data/vendor/assets/javascripts/nvd3/deprecated/scatterChart.html +0 -110
  60. data/vendor/assets/javascripts/nvd3/deprecated/scatterChart.js +0 -294
  61. data/vendor/assets/javascripts/nvd3/deprecated/scatterFisheyeChart.js +0 -418
  62. data/vendor/assets/javascripts/nvd3/deprecated/scatterWithLegend.html +0 -167
  63. data/vendor/assets/javascripts/nvd3/deprecated/scatterWithLegend.js +0 -261
  64. data/vendor/assets/javascripts/nvd3/deprecated/stackedArea.js +0 -286
  65. data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaChart.html +0 -183
  66. data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaChart_old.html +0 -137
  67. data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaWithLegend.html +0 -222
  68. data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaWithLegend.js +0 -297
  69. data/vendor/assets/javascripts/nvd3/examples/bullet.html +0 -96
  70. data/vendor/assets/javascripts/nvd3/examples/bulletChart.html +0 -94
  71. data/vendor/assets/javascripts/nvd3/examples/crossfilter.html +0 -167
  72. data/vendor/assets/javascripts/nvd3/examples/crossfilterWithDimentions.html +0 -180
  73. data/vendor/assets/javascripts/nvd3/examples/crossfilterWithTables.html +0 -288
  74. data/vendor/assets/javascripts/nvd3/examples/cumulativeLineChart.html +0 -155
  75. data/vendor/assets/javascripts/nvd3/examples/discreteBarChart.html +0 -116
  76. data/vendor/assets/javascripts/nvd3/examples/dynamicTimeSeries.html +0 -148
  77. data/vendor/assets/javascripts/nvd3/examples/historicalBar.html +0 -157
  78. data/vendor/assets/javascripts/nvd3/examples/horizon.html +0 -163
  79. data/vendor/assets/javascripts/nvd3/examples/images/grey-minus.png +0 -0
  80. data/vendor/assets/javascripts/nvd3/examples/images/grey-plus.png +0 -0
  81. data/vendor/assets/javascripts/nvd3/examples/indentedtree.html +0 -126
  82. data/vendor/assets/javascripts/nvd3/examples/legend.html +0 -75
  83. data/vendor/assets/javascripts/nvd3/examples/line.html +0 -95
  84. data/vendor/assets/javascripts/nvd3/examples/lineChart.html +0 -112
  85. data/vendor/assets/javascripts/nvd3/examples/lineChartSVGResize.html +0 -151
  86. data/vendor/assets/javascripts/nvd3/examples/linePlusBarChart.html +0 -114
  87. data/vendor/assets/javascripts/nvd3/examples/linePlusBarWithFocusChart.html +0 -128
  88. data/vendor/assets/javascripts/nvd3/examples/lineTimeSeries.html +0 -142
  89. data/vendor/assets/javascripts/nvd3/examples/lineWithFisheyeChart.html +0 -101
  90. data/vendor/assets/javascripts/nvd3/examples/lineWithFocusChart.html +0 -87
  91. data/vendor/assets/javascripts/nvd3/examples/multiBar.html +0 -92
  92. data/vendor/assets/javascripts/nvd3/examples/multiBarChart.html +0 -93
  93. data/vendor/assets/javascripts/nvd3/examples/multiBarHorizontalChart.html +0 -388
  94. data/vendor/assets/javascripts/nvd3/examples/multiChart.html +0 -93
  95. data/vendor/assets/javascripts/nvd3/examples/nations.json +0 -1
  96. data/vendor/assets/javascripts/nvd3/examples/pie.html +0 -93
  97. data/vendor/assets/javascripts/nvd3/examples/pieChart.html +0 -114
  98. data/vendor/assets/javascripts/nvd3/examples/scatter.html +0 -95
  99. data/vendor/assets/javascripts/nvd3/examples/scatterChart.html +0 -115
  100. data/vendor/assets/javascripts/nvd3/examples/scatterPlusLineChart.html +0 -116
  101. data/vendor/assets/javascripts/nvd3/examples/sparkline.html +0 -62
  102. data/vendor/assets/javascripts/nvd3/examples/sparklinePlus.html +0 -67
  103. data/vendor/assets/javascripts/nvd3/examples/stackedArea.html +0 -155
  104. data/vendor/assets/javascripts/nvd3/examples/stackedAreaChart.html +0 -245
  105. data/vendor/assets/javascripts/nvd3/examples/stream_layers.js +0 -35
  106. data/vendor/assets/javascripts/nvd3/src/models/backup/bullet.js +0 -250
  107. data/vendor/assets/javascripts/nvd3/src/models/backup/bulletChart.js +0 -349
@@ -1,129 +0,0 @@
1
- <!DOCTYPE html>
2
- <meta charset="utf-8">
3
-
4
- <link href="../src/d3.css" rel="stylesheet" type="text/css">
5
-
6
- <style>
7
-
8
- body {
9
- overflow-y:scroll;
10
- }
11
-
12
- text {
13
- font: 12px sans-serif;
14
- }
15
-
16
- svg {
17
- display: block;
18
- }
19
-
20
- #wrapper {
21
- width: 960;
22
- padding: 100px;
23
- }
24
-
25
- #chart1 {
26
- width: 960px;
27
- }
28
-
29
- #chart1 svg{
30
- height: 500px;
31
- min-width: 100px;
32
- min-height: 100px;
33
- /*
34
- margin: 10px;
35
- Minimum height and width is a good idea to prevent negative SVG dimensions...
36
- For example width should be =< margin.left + margin.right + 1,
37
- of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
38
- */
39
- }
40
-
41
- </style>
42
- <body>
43
- <div id="wrapper">
44
-
45
- <div id="chart1">
46
- <svg></svg>
47
- </div>
48
-
49
- </div>
50
-
51
- <script src="../lib/d3.v2.js"></script>
52
- <script src="../nv.d3.js"></script>
53
- <!-- including all the components so I don't have to minify every time I test in development -->
54
- <script src="../src/tooltip.js"></script>
55
- <script src="../src/models/axis.js"></script>
56
- <script src="../src/models/discreteBar.js"></script>
57
- <script src="../src/models/discreteBarChartWithEnabledTooltip.js"></script>
58
- <script>
59
-
60
-
61
-
62
-
63
-
64
- historicalBarChart = [
65
- {
66
- key: "Cumulative Return",
67
- values: [
68
- {
69
- "label" : "CDS / Options" ,
70
- "value" : -29.765957771107
71
- } ,
72
- {
73
- "label" : "Cash" ,
74
- "value" : 0
75
- } ,
76
- {
77
- "label" : "Corporate Bonds" ,
78
- "value" : 32.807804682612
79
- } ,
80
- {
81
- "label" : "Equity" ,
82
- "value" : 196.45946739256
83
- } ,
84
- {
85
- "label" : "Index Futures" ,
86
- "value" : 0.19434030906893
87
- } ,
88
- {
89
- "label" : "Options" ,
90
- "value" : -98.079782601442
91
- } ,
92
- {
93
- "label" : "Preferred" ,
94
- "value" : -13.925743130903
95
- } ,
96
- {
97
- "label" : "Not Available" ,
98
- "value" : -5.1387322875705
99
- }
100
- ]
101
- }
102
- ];
103
-
104
-
105
-
106
-
107
- nv.addGraph(function() {
108
- var chart = nv.models.discreteBarChart()
109
- .x(function(d) { return d.label })
110
- .y(function(d) { return d.value })
111
- .staggerLabels(true)
112
- //.staggerLabels(historicalBarChart[0].values.length > 8)
113
- .tooltips(true)
114
- .showValues(true)
115
-
116
-
117
- d3.select('#chart1 svg')
118
- .datum(historicalBarChart)
119
- .transition().duration(500)
120
- .call(chart);
121
-
122
- nv.utils.windowResize(chart.update);
123
-
124
- return chart;
125
- });
126
-
127
-
128
- </script>
129
- </body>
@@ -1,222 +0,0 @@
1
-
2
- nv.models.discreteBarChart = function() {
3
- var margin = {top: 30, right: 20, bottom: 50, left: 60},
4
- width = null,
5
- height = null,
6
- color = d3.scale.category20().range(),
7
- staggerLabels = false,
8
- tooltips = true,
9
- tooltip = function(key, x, y, e, graph) {
10
- return '<h3>' + x + '</h3>' +
11
- '<p>' + y + '</p>'
12
- };
13
-
14
-
15
- var discretebar = nv.models.discreteBar(),
16
- x = discretebar.xScale(),
17
- y = discretebar.yScale(),
18
- xAxis = nv.models.axis().scale(x).orient('bottom').highlightZero(false).showMaxMin(false),
19
- yAxis = nv.models.axis().scale(y).orient('left'),
20
- dispatch = d3.dispatch('tooltipShow', 'tooltipHide');
21
-
22
- xAxis.tickFormat(function(d) { return d });
23
- yAxis.tickFormat(d3.format(',.1f'));
24
-
25
-
26
- var showTooltip = function(e, offsetElement) {
27
- var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
28
- top = e.pos[1] + ( offsetElement.offsetTop || 0),
29
- x = xAxis.tickFormat()(discretebar.x()(e.point)),
30
- y = yAxis.tickFormat()(discretebar.y()(e.point)),
31
- content = tooltip(e.series.key, x, y, e, chart);
32
-
33
- nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement);
34
- };
35
-
36
-
37
- //TODO: let user select default
38
- var controlsData = [
39
- { key: 'Grouped' },
40
- { key: 'Stacked', disabled: true }
41
- ];
42
-
43
- function chart(selection) {
44
- selection.each(function(data) {
45
- var container = d3.select(this),
46
- that = this;
47
-
48
- var availableWidth = (width || parseInt(container.style('width')) || 960)
49
- - margin.left - margin.right,
50
- availableHeight = (height || parseInt(container.style('height')) || 400)
51
- - margin.top - margin.bottom;
52
-
53
-
54
- discretebar
55
- .width(availableWidth)
56
- .height(availableHeight);
57
-
58
-
59
- var wrap = container.selectAll('g.wrap.discreteBarWithAxes').data([data]);
60
- var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 discreteBarWithAxes').append('g');
61
- var defsEnter = gEnter.append('defs');
62
-
63
- gEnter.append('g').attr('class', 'x axis');
64
- gEnter.append('g').attr('class', 'y axis');
65
- gEnter.append('g').attr('class', 'barsWrap');
66
-
67
-
68
-
69
- var g = wrap.select('g');
70
-
71
-
72
- g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
73
-
74
- var barsWrap = g.select('.barsWrap')
75
- .datum(data.filter(function(d) { return !d.disabled }))
76
-
77
-
78
- d3.transition(barsWrap).call(discretebar);
79
-
80
-
81
- defsEnter.append('clipPath')
82
- .attr('id', 'x-label-clip-' + discretebar.id())
83
- .append('rect')
84
-
85
- g.select('#x-label-clip-' + discretebar.id() + ' rect')
86
- .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1))
87
- .attr('height', 16)
88
- .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 ));
89
-
90
- /*
91
- var evenLabelClips = defsEnter.append('clipPath')
92
- .attr('id', 'x-label-clip-even-' + discretebar.id())
93
- .selectAll('rect')
94
- .data(function(d) { return d[0].values.filter(function(d,i) { return i % 2 === 0 }) });
95
-
96
- evenLabelClips.enter().append('rect')
97
- .attr('width', x.rangeBand())
98
- .attr('height', 32)
99
- .attr('y', y.range()[0])
100
- .attr('x', function(d,i) { return x(discretebar.x()(d,i)) });
101
-
102
- var oddLabelClips = defsEnter.append('clipPath')
103
- .attr('id', 'x-label-clip-odd-' + discretebar.id())
104
- .selectAll('rect')
105
- .data(function(d) { return d[0].values.filter(function(d,i) { return i % 2 === 1 }) });
106
-
107
- oddLabelClips.enter().append('rect')
108
- .attr('width', x.rangeBand())
109
- .attr('height', 16)
110
- .attr('y', y.range()[0] + 16 + (staggerLabels ? 12: 0))
111
- .attr('x', function(d,i) { return x(discretebar.x()(d,i)) });
112
- */
113
-
114
-
115
-
116
- xAxis
117
- .ticks( availableWidth / 100 )
118
- .tickSize(-availableHeight, 0);
119
-
120
- g.select('.x.axis')
121
- .attr('transform', 'translate(0,' + (y.range()[0] + (discretebar.showValues() ? 16 : 0)) + ')')
122
- //d3.transition(g.select('.x.axis'))
123
- g.select('.x.axis').transition().duration(0)
124
- .call(xAxis);
125
-
126
-
127
- var xTicks = g.select('.x.axis').selectAll('g');
128
-
129
- if (staggerLabels)
130
- xTicks
131
- .selectAll('text')
132
- .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '0' : '12') + ')' })
133
-
134
- xTicks
135
- .selectAll('text')
136
- .attr('clip-path', function(d,i,j) { return 'url(#x-label-clip-' + discretebar.id() + ')' });
137
-
138
-
139
- yAxis
140
- .ticks( availableHeight / 36 )
141
- .tickSize( -availableWidth, 0);
142
-
143
- d3.transition(g.select('.y.axis'))
144
- .call(yAxis);
145
-
146
-
147
- discretebar.dispatch.on('elementMouseover.tooltip', function(e) {
148
- e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
149
- dispatch.tooltipShow(e);
150
- });
151
- if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, that.parentNode) } ); // TODO: maybe merge with above?
152
-
153
- discretebar.dispatch.on('elementMouseout.tooltip', function(e) {
154
- dispatch.tooltipHide(e);
155
- });
156
- if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup);
157
-
158
-
159
- //TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
160
- chart.update = function() { selection.transition().call(chart); };
161
- chart.container = this; // I need a reference to the container in order to have outside code check if the chart is visible or not
162
-
163
- });
164
-
165
- return chart;
166
- }
167
-
168
-
169
- chart.dispatch = dispatch;
170
- chart.discretebar = discretebar; // really just makign the accessible for discretebar.dispatch, may rethink slightly
171
- chart.xAxis = xAxis;
172
- chart.yAxis = yAxis;
173
-
174
- d3.rebind(chart, discretebar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'id', 'showValues', 'valueFormat');
175
-
176
-
177
- chart.margin = function(_) {
178
- if (!arguments.length) return margin;
179
- margin = _;
180
- return chart;
181
- };
182
-
183
- chart.width = function(_) {
184
- if (!arguments.length) return width;
185
- width = _;
186
- return chart;
187
- };
188
-
189
- chart.height = function(_) {
190
- if (!arguments.length) return height;
191
- height = _;
192
- return chart;
193
- };
194
-
195
- chart.color = function(_) {
196
- if (!arguments.length) return color;
197
- color = _;
198
- discretebar.color(_);
199
- return chart;
200
- };
201
-
202
- chart.staggerLabels = function(_) {
203
- if (!arguments.length) return staggerLabels;
204
- staggerLabels = _;
205
- return chart;
206
- };
207
-
208
- chart.tooltips = function(_) {
209
- if (!arguments.length) return tooltips;
210
- tooltips = _;
211
- return chart;
212
- };
213
-
214
- chart.tooltipContent = function(_) {
215
- if (!arguments.length) return tooltip;
216
- tooltip = _;
217
- return chart;
218
- };
219
-
220
-
221
- return chart;
222
- }
@@ -1,172 +0,0 @@
1
- <!DOCTYPE html>
2
- <meta charset="utf-8">
3
-
4
- <link href="../src/d3.css" rel="stylesheet" type="text/css">
5
-
6
- <style>
7
-
8
- body {
9
- overflow-y:scroll;
10
- }
11
-
12
- text {
13
- font: 12px sans-serif;
14
- }
15
-
16
- #chart1 {
17
- height: 500px;
18
- margin: 10px;
19
- min-width: 100px;
20
- min-height: 100px;
21
- /*
22
- Minimum height and width is a good idea to prevent negative SVG dimensions...
23
- For example width should be =< margin.left + margin.right + 1,
24
- of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
25
- */
26
- }
27
-
28
- </style>
29
- <body>
30
-
31
- <div id="chart1">
32
- </div>
33
-
34
- <script src="../lib/d3.v2.js"></script>
35
- <script src="../nv.d3.js"></script>
36
- <script src="../src/tooltip.js"></script>
37
- <script src="../src/models/axis.js"></script>
38
- <script src="../src/models/discreteBar.js"></script>
39
- <script src="../src/models/discreteBarWithAxes.js"></script>
40
- <script src="stream_layers.js"></script>
41
- <script>
42
-
43
-
44
-
45
- historicalBarChart = [
46
- {
47
- key: "Cumulative Return",
48
- values: [
49
- {
50
- "label" : "CDS / Options" ,
51
- "value" : -29.765957771107
52
- } ,
53
- {
54
- "label" : "Cash" ,
55
- "value" : 0
56
- } ,
57
- {
58
- "label" : "Corporate Bonds" ,
59
- "value" : 32.807804682612
60
- } ,
61
- {
62
- "label" : "Equity" ,
63
- "value" : 196.45946739256
64
- } ,
65
- {
66
- "label" : "Index Futures" ,
67
- "value" : 0.19434030906893
68
- } ,
69
- {
70
- "label" : "Options" ,
71
- "value" : -98.079782601442
72
- } ,
73
- {
74
- "label" : "Preferred" ,
75
- "value" : -13.925743130903
76
- } ,
77
- {
78
- "label" : "Not Available" ,
79
- "value" : -5.1387322875705
80
- }
81
- ]
82
- }
83
- ];
84
-
85
-
86
-
87
-
88
-
89
-
90
- var selector = '#chart1',
91
- chart = nv.models.discreteBarWithAxes()
92
- .color(d3.scale.category10().range())
93
- .x(function(d) { return d.label })
94
- .y(function(d) { return d.value }),
95
- data = historicalBarChart,
96
- xTickFormat = function(d) { return d },
97
- yTickFormat = d3.format(',.2f'),
98
- xAxisLabel = null,
99
- yAxisLabel = null,
100
- duration = 500;
101
-
102
- nv.addGraph({
103
- generate: function() {
104
- var container = d3.select(selector),
105
- width = function() { return parseInt(container.style('width')) },
106
- height = function() { return parseInt(container.style('height')) },
107
- svg = container.append('svg');
108
-
109
- chart
110
- .width(width)
111
- .height(height)
112
- .staggerLabels(true);
113
-
114
- chart.xAxis
115
- .tickFormat(xTickFormat);
116
-
117
- chart.yAxis
118
- .tickFormat(yTickFormat)
119
- .axisLabel(yAxisLabel);
120
-
121
- svg
122
- .attr('width', width())
123
- .attr('height', height())
124
- .datum(data)
125
- .transition().duration(duration).call(chart);
126
-
127
- return chart;
128
- },
129
- callback: function(chart) {
130
- var showTooltip = function(e) {
131
- var offsetElement = document.getElementById(selector.substr(1)),
132
- left = e.pos[0] + offsetElement.offsetLeft,
133
- top = e.pos[1] + offsetElement.offsetTop,
134
- formatY = chart.yAxis.tickFormat(), //Assumes using same format as axis, can customize to show higher precision, etc.
135
- formatX = chart.xAxis.tickFormat();
136
-
137
- // uses the chart's getX and getY, you may customize if x position is not the same as the value you want
138
- // ex. daily data without weekends, x is the index, while you want the date
139
- var content = '<h3>' + formatX(chart.x()(e.point)) + '</h3>' +
140
- '<p>' +
141
- formatY(chart.y()(e.point)) +
142
- '</p>';
143
-
144
- nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's');
145
- };
146
-
147
- chart.dispatch.on('tooltipShow', showTooltip);
148
- chart.dispatch.on('tooltipHide', nv.tooltip.cleanup);
149
-
150
-
151
- window.onresize= function() {
152
- // now that width and height are functions, should be automatic..of course you can always override them
153
-
154
- d3.select('#chart1 svg')
155
- .attr('width', chart.width()()) //need to set SVG dimensions, chart is not aware of the SVG component
156
- .attr('height', chart.height()())
157
- .transition().duration(duration)
158
- .call(chart);
159
-
160
- /*
161
- d3.select('#chart1 svg')
162
- .attr('width', chart.width()()) //need to set SVG dimensions, chart is not aware of the SVG component
163
- .attr('height', chart.height()())
164
- .call(chart);
165
- */
166
- };
167
- }
168
- });
169
-
170
-
171
-
172
- </script>