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,144 +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/legend.js"></script>
38
- <script src="../src/models/axis.js"></script>
39
- <script src="../src/models/line.js"></script>
40
- <script src="../src/models/lineWithFourAxes.js"></script>
41
- <script>
42
-
43
- /************
44
- * Considering making an nv.charts object which will contain abstractions similar to the one below,
45
- * but with the usual d3 reusable style.
46
- * I could make this abstraction inside the layer above, but this layer incorporates some jQuery, so
47
- * thinking nv.charts can be the glue that's not 100% d3
48
- ************/
49
-
50
- var selector = '#chart1',
51
- chart = nv.models.lineWithLegend(),
52
- data = sinAndCos(),
53
- xTickFormat = d3.format(',r'),
54
- yTickFormat = d3.format(',.2f'),
55
- xAxisLabel = null,
56
- yAxisLabel = 'Voltage (v)',
57
- duration = 500;
58
-
59
- nv.addGraph({
60
- generate: function() {
61
- var container = d3.select(selector),
62
- width = function() { return parseInt(container.style('width')) },
63
- height = function() { return parseInt(container.style('height')) },
64
- svg = container.append('svg');
65
-
66
- chart
67
- .width(width)
68
- .height(height)
69
-
70
- chart.xAxis
71
- .tickFormat(xTickFormat);
72
-
73
- chart.yAxis
74
- .tickFormat(yTickFormat)
75
- .axisLabel(yAxisLabel);
76
-
77
- svg
78
- .attr('width', width())
79
- .attr('height', height())
80
- .datum(data)
81
- .transition().duration(duration).call(chart);
82
-
83
- return chart;
84
- },
85
- callback: function(chart) {
86
- var showTooltip = function(e) {
87
- var offsetElement = document.getElementById(selector.substr(1)),
88
- left = e.pos[0] + offsetElement.offsetLeft,
89
- top = e.pos[1] + offsetElement.offsetTop,
90
- formatY = chart.yAxis.tickFormat(), //Assumes using same format as axis, can customize to show higher precision, etc.
91
- formatX = chart.xAxis.tickFormat();
92
-
93
- // uses the chart's getX and getY, you may customize if x position is not the same as the value you want
94
- // ex. daily data without weekends, x is the index, while you want the date
95
- var content = '<h3>' + e.series.key + '</h3>' +
96
- '<p>' +
97
- formatY(chart.y()(e.point)) + ' at ' + formatX(chart.x()(e.point)) +
98
- '</p>';
99
-
100
- nv.tooltip.show([left, top], content);
101
- };
102
-
103
- chart.dispatch.on('tooltipShow', showTooltip);
104
- chart.dispatch.on('tooltipHide', nv.tooltip.cleanup);
105
-
106
-
107
- window.onresize =
108
- function() {
109
- // now that width and height are functions, should be automatic..of course you can always override them
110
- d3.select('#chart1 svg')
111
- .attr('width', chart.width()()) //need to set SVG dimensions, chart is not aware of the SVG component
112
- .attr('height', chart.height()())
113
- .call(chart);
114
- };
115
- }
116
- });
117
-
118
-
119
-
120
- function sinAndCos() {
121
- var sin = [],
122
- cos = [];
123
-
124
- for (var i = 0; i < 100; i++) {
125
- sin.push({x: i, y: Math.sin(i/10)});
126
- cos.push({x: i, y: .5 * Math.cos(i/10)});
127
- }
128
-
129
- return [
130
- {
131
- values: sin,
132
- key: "Sine Wave",
133
- color: "#ff7f0e"
134
- },
135
- {
136
- values: cos,
137
- key: "Cosine Wave",
138
- color: "#2ca02c"
139
- }
140
- ];
141
- }
142
-
143
-
144
- </script>
@@ -1,218 +0,0 @@
1
-
2
- nv.models.lineWithLegend = function() {
3
- var margin = {top: 60, right: 60, bottom: 40, left: 60},
4
- getWidth = function() { return 960 },
5
- getHeight = function() { return 500 },
6
- dotRadius = function() { return 2.5 },
7
- getX = function(d) { return d.x },
8
- getY = function(d) { return d.y },
9
- color = d3.scale.category20().range(),
10
- dispatch = d3.dispatch('tooltipShow', 'tooltipHide');
11
-
12
- var x = d3.scale.linear(),
13
- y = d3.scale.linear(),
14
- xAxis = nv.models.axis().scale(x).orient('bottom'),
15
- yAxis = nv.models.axis().scale(y).orient('left'),
16
- x2Axis = nv.models.axis().scale(x).orient('top'),
17
- y2Axis = nv.models.axis().scale(y).orient('right'),
18
- legend = nv.models.legend().height(30),
19
- lines = nv.models.line();
20
-
21
-
22
- function chart(selection) {
23
- selection.each(function(data) {
24
- var width = getWidth(),
25
- height = getHeight(),
26
- availableWidth = width - margin.left - margin.right,
27
- availableHeight = height - margin.top - margin.bottom;
28
-
29
- var series = data.filter(function(d) { return !d.disabled })
30
- .map(function(d) {
31
- return d.values.map(function(d,i) {
32
- return { x: getX(d,i), y: getY(d,i) }
33
- })
34
- });
35
-
36
- x .domain(d3.extent(d3.merge(series), function(d) { return d.x } ))
37
- .range([0, availableWidth]);
38
-
39
- y .domain(d3.extent(d3.merge(series), function(d) { return d.y } ))
40
- .range([availableHeight, 0]);
41
-
42
- lines
43
- .width(availableWidth)
44
- .height(availableHeight)
45
- .color(data.map(function(d,i) {
46
- return d.color || color[i % 10];
47
- }).filter(function(d,i) { return !data[i].disabled }))
48
-
49
-
50
- var wrap = d3.select(this).selectAll('g.wrap').data([data]);
51
- var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 lineWithLegend').append('g');
52
-
53
- gEnter.append('g').attr('class', 'x axis');
54
- gEnter.append('g').attr('class', 'y axis');
55
- gEnter.append('g').attr('class', 'x2 axis');
56
- gEnter.append('g').attr('class', 'y2 axis');
57
- gEnter.append('g').attr('class', 'linesWrap');
58
- gEnter.append('g').attr('class', 'legendWrap');
59
-
60
-
61
- legend.dispatch.on('legendClick', function(d,i) {
62
- d.disabled = !d.disabled;
63
-
64
- if (!data.filter(function(d) { return !d.disabled }).length) {
65
- data.map(function(d) {
66
- d.disabled = false;
67
- wrap.selectAll('.series').classed('disabled', false);
68
- return d;
69
- });
70
- }
71
-
72
- selection.transition().call(chart);
73
- });
74
-
75
- /*
76
- //
77
- legend.dispatch.on('legendMouseover', function(d, i) {
78
- d.hover = true;
79
- selection.transition().call(chart)
80
- });
81
-
82
- legend.dispatch.on('legendMouseout', function(d, i) {
83
- d.hover = false;
84
- selection.transition().call(chart)
85
- });
86
- */
87
-
88
- lines.dispatch.on('elementMouseover.tooltip', function(e) {
89
- dispatch.tooltipShow({
90
- point: e.point,
91
- series: e.series,
92
- pos: [e.pos[0] + margin.left, e.pos[1] + margin.top],
93
- seriesIndex: e.seriesIndex,
94
- pointIndex: e.pointIndex
95
- });
96
- });
97
-
98
- lines.dispatch.on('elementMouseout.tooltip', function(e) {
99
- dispatch.tooltipHide(e);
100
- });
101
-
102
-
103
- //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend
104
- margin.top = legend.height() + 20; // 20 is for the x2 axis... this should be done in a better place, but just doing this to show the 4 axes in an example
105
-
106
- var g = wrap.select('g')
107
- .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
108
-
109
-
110
- legend.width(width/2 - margin.right);
111
-
112
- g.select('.legendWrap')
113
- .datum(data)
114
- .attr('transform', 'translate(' + (width/2 - margin.left) + ',' + (-margin.top) +')')
115
- .call(legend);
116
-
117
-
118
- var linesWrap = g.select('.linesWrap')
119
- .datum(data.filter(function(d) { return !d.disabled }))
120
-
121
-
122
- d3.transition(linesWrap).call(lines);
123
-
124
-
125
- xAxis
126
- .domain(x.domain())
127
- .range(x.range())
128
- .ticks( width / 100 )
129
- .tickSize(-availableHeight, 0);
130
-
131
- g.select('.x.axis')
132
- .attr('transform', 'translate(0,' + y.range()[0] + ')');
133
- d3.transition(g.select('.x.axis'))
134
- .call(xAxis);
135
-
136
- yAxis
137
- .domain(y.domain())
138
- .range(y.range())
139
- .ticks( height / 36 )
140
- .tickSize(-availableWidth, 0);
141
-
142
- d3.transition(g.select('.y.axis'))
143
- .call(yAxis);
144
-
145
- x2Axis
146
- .domain(x.domain())
147
- .range(x.range())
148
- .ticks( width / 100 )
149
- .tickSize(-availableHeight, 0);
150
-
151
- d3.transition(g.select('.x2.axis'))
152
- .call(x2Axis);
153
-
154
- y2Axis
155
- .domain(y.domain())
156
- .range(y.range())
157
- .ticks( height / 36 )
158
- .tickSize(-availableWidth, 0);
159
-
160
- g.select('.y2.axis')
161
- .attr('transform', 'translate('+ x.range()[1] + ',0)');
162
- d3.transition(g.select('.y2.axis'))
163
- .call(y2Axis);
164
- });
165
-
166
- return chart;
167
- }
168
-
169
- chart.dispatch = dispatch;
170
- chart.legend = legend;
171
- chart.xAxis = xAxis;
172
- chart.yAxis = yAxis;
173
-
174
- d3.rebind(chart, lines, 'interactive');
175
- //consider rebinding x and y as well
176
-
177
- chart.x = function(_) {
178
- if (!arguments.length) return getX;
179
- getX = _;
180
- lines.x(_);
181
- return chart;
182
- };
183
-
184
- chart.y = function(_) {
185
- if (!arguments.length) return getY;
186
- getY = _;
187
- lines.y(_);
188
- return chart;
189
- };
190
-
191
- chart.margin = function(_) {
192
- if (!arguments.length) return margin;
193
- margin = _;
194
- return chart;
195
- };
196
-
197
- chart.width = function(_) {
198
- if (!arguments.length) return getWidth;
199
- getWidth = d3.functor(_);
200
- return chart;
201
- };
202
-
203
- chart.height = function(_) {
204
- if (!arguments.length) return getHeight;
205
- getHeight = d3.functor(_);
206
- return chart;
207
- };
208
-
209
- chart.dotRadius = function(_) {
210
- if (!arguments.length) return dotRadius;
211
- dotRadius = d3.functor(_);
212
- lines.dotRadius = _;
213
- return chart;
214
- };
215
-
216
-
217
- return chart;
218
- }
@@ -1,142 +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
- #chart1 {
21
- height: 500px;
22
- margin: 10px;
23
- min-width: 100px;
24
- min-height: 100px;
25
- /*
26
- Minimum height and width is a good idea to prevent negative SVG dimensions...
27
- For example width should be =< margin.left + margin.right + 1,
28
- of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
29
- */
30
- }
31
-
32
- </style>
33
- <body>
34
-
35
- <div id="chart1">
36
- </div>
37
-
38
- <script src="../lib/d3.v2.js"></script>
39
- <script src="../nv.d3.js"></script>
40
- <script src="../src/tooltip.js"></script>
41
- <script src="../src/models/legend.js"></script>
42
- <script src="../src/models/axis.js"></script>
43
- <script src="../src/models/scatter.js"></script>
44
- <script src="../src/models/line.js"></script>
45
- <script src="../src/models/lineWithLegend.js"></script>
46
- <script>
47
-
48
-
49
- var selector = '#chart1',
50
- chart = nv.models.lineWithLegend(),
51
- data = sinAndCos(),
52
- xTickFormat = d3.format(',r'),
53
- yTickFormat = d3.format(',.2f'),
54
- xAxisLabel = null,
55
- yAxisLabel = 'Voltage (v)',
56
- duration = 500;
57
-
58
- nv.addGraph({
59
- generate: function() {
60
- var container = d3.select(selector),
61
- width = function() { return parseInt(container.style('width')) },
62
- height = function() { return parseInt(container.style('height')) },
63
- svg = container.append('svg').style('height', '500px');
64
-
65
- chart
66
- //.width(width)
67
- //.height(height);
68
-
69
- chart.xAxis
70
- .tickFormat(xTickFormat);
71
-
72
- chart.yAxis
73
- .tickFormat(yTickFormat)
74
- .axisLabel(yAxisLabel);
75
-
76
- svg
77
- //.attr('width', width())
78
- //.attr('height', height())
79
- .datum(data)
80
- .transition().duration(duration).call(chart);
81
-
82
- return chart;
83
- },
84
- callback: function(chart) {
85
- var showTooltip = function(e) {
86
- var offsetElement = document.getElementById(selector.substr(1)),
87
- left = e.pos[0] + offsetElement.offsetLeft,
88
- top = e.pos[1] + offsetElement.offsetTop,
89
- formatY = chart.yAxis.tickFormat(), //Assumes using same format as axis, can customize to show higher precision, etc.
90
- formatX = chart.xAxis.tickFormat();
91
-
92
- // uses the chart's getX and getY, you may customize if x position is not the same as the value you want
93
- // ex. daily data without weekends, x is the index, while you want the date
94
- var content = '<h3>' + e.series.key + '</h3>' +
95
- '<p>' +
96
- formatY(chart.y()(e.point)) + ' at ' + formatX(chart.x()(e.point)) +
97
- '</p>';
98
-
99
- nv.tooltip.show([left, top], content);
100
- };
101
-
102
- chart.dispatch.on('tooltipShow', showTooltip);
103
- chart.dispatch.on('tooltipHide', nv.tooltip.cleanup);
104
-
105
-
106
- window.onresize= function() {
107
- // now that width and height are functions, should be automatic..of course you can always override them
108
- d3.select('#chart1 svg')
109
- //.attr('width', chart.width()()) //need to set SVG dimensions, chart is not aware of the SVG component
110
- //.attr('height', chart.height()())
111
- .call(chart);
112
- };
113
- }
114
- });
115
-
116
-
117
-
118
- function sinAndCos() {
119
- var sin = [],
120
- cos = [];
121
-
122
- for (var i = 0; i < 100; i++) {
123
- sin.push({x: i, y: Math.sin(i/10)});
124
- cos.push({x: i, y: .5 * Math.cos(i/10)});
125
- }
126
-
127
- return [
128
- {
129
- values: sin,
130
- key: "Sine Wave",
131
- color: "#ff7f0e"
132
- },
133
- {
134
- values: cos,
135
- key: "Cosine Wave",
136
- color: "#2ca02c"
137
- }
138
- ];
139
- }
140
-
141
-
142
- </script>