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,418 +0,0 @@
1
-
2
- nv.models.scatterFisheyeChart = function() {
3
- var margin = {top: 30, right: 20, bottom: 50, left: 60},
4
- width = null,
5
- height = null,
6
- color = nv.utils.defaultColor(),
7
- showDistX = false,
8
- showDistY = false,
9
- showLegend = true,
10
- showControls = true,
11
- fisheye = 0,
12
- tooltips = true,
13
- tooltipX = function(key, x, y) { return '<strong>' + x + '</strong>' },
14
- tooltipY = function(key, x, y) { return '<strong>' + y + '</strong>' },
15
- tooltip = function(key, x, y, e, graph) {
16
- return '<h3>' + key + '</h3>' +
17
- '<p>' + y + ' at ' + x + '</p>'
18
- },
19
- noData = "No Data Available."
20
- ;
21
-
22
- var x = d3.fisheye.scale(d3.scale.linear).distortion(0),
23
- y = d3.fisheye.scale(d3.scale.linear).distortion(0);
24
-
25
- var scatter = nv.models.scatter().xScale(x).yScale(y),
26
- //x = scatter.xScale(),
27
- //y = scatter.yScale(),
28
- xAxis = nv.models.axis().orient('bottom').scale(x).tickPadding(10),
29
- yAxis = nv.models.axis().orient('left').scale(y).tickPadding(10),
30
- legend = nv.models.legend().height(30),
31
- controls = nv.models.legend().height(30),
32
- dispatch = d3.dispatch('tooltipShow', 'tooltipHide'),
33
- x0, y0; //TODO: abstract distribution component and have old scales stored there
34
-
35
- var showTooltip = function(e, offsetElement) {
36
- //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?)
37
-
38
- //var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
39
- //top = e.pos[1] + ( offsetElement.offsetTop || 0),
40
- var leftX = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
41
- topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0),
42
- leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ),
43
- topY = e.pos[1] + ( offsetElement.offsetTop || 0),
44
- xVal = xAxis.tickFormat()(scatter.x()(e.point, e.pointIndex)),
45
- yVal = yAxis.tickFormat()(scatter.y()(e.point, e.pointIndex)),
46
- contentX = tooltipX(e.series.key, xVal, yVal, e, chart),
47
- contentY = tooltipY(e.series.key, xVal, yVal, e, chart);
48
- //content = tooltip(e.series.key, xVal, yVal, e, chart);
49
-
50
- nv.tooltip.show([leftX, topX], contentX, 'n', 1, offsetElement);
51
- nv.tooltip.show([leftY, topY], contentY, 'e', 1, offsetElement);
52
- //nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's');
53
- };
54
-
55
- var controlsData = [
56
- { key: 'Magnify', disabled: true }
57
- ];
58
-
59
- function chart(selection) {
60
- selection.each(function(data) {
61
- var container = d3.select(this),
62
- that = this;
63
-
64
- //TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
65
- chart.update = function() { selection.transition().call(chart) };
66
-
67
-
68
- var availableWidth = (width || parseInt(container.style('width')) || 960)
69
- - margin.left - margin.right,
70
- availableHeight = (height || parseInt(container.style('height')) || 400)
71
- - margin.top - margin.bottom;
72
-
73
-
74
- //------------------------------------------------------------
75
- // Display No Data message if there's nothing to show.
76
-
77
- if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
78
- container.append('text')
79
- .attr('class', 'nvd3 nv-noData')
80
- .attr('x', availableWidth / 2)
81
- .attr('y', availableHeight / 2)
82
- .attr('dy', '-.7em')
83
- .style('text-anchor', 'middle')
84
- .text(noData);
85
- return chart;
86
- } else {
87
- container.select('.nv-noData').remove();
88
- }
89
-
90
- //------------------------------------------------------------
91
-
92
-
93
-
94
- x0 = x0 || scatter.xScale();
95
- y0 = y0 || scatter.yScale();
96
-
97
-
98
- var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]);
99
- var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id()).append('g');
100
-
101
-
102
- gEnter.append('rect')
103
- .attr('class', 'nvd3 nv-background')
104
- .attr('width', availableWidth)
105
- .attr('height', availableHeight);
106
-
107
-
108
- gEnter.append('g').attr('class', 'nv-legendWrap');
109
- gEnter.append('g').attr('class', 'nv-x nv-axis');
110
- gEnter.append('g').attr('class', 'nv-y nv-axis');
111
- gEnter.append('g').attr('class', 'nv-scatterWrap');
112
- gEnter.append('g').attr('class', 'nv-controlsWrap');
113
- //gEnter.append('g').attr('class', 'nv-distWrap');
114
-
115
- var g = wrap.select('g')
116
-
117
- if (showLegend) {
118
- legend.width( availableWidth / 2 );
119
-
120
- wrap.select('.nv-legendWrap')
121
- .datum(data)
122
- .call(legend);
123
-
124
- if ( margin.top != legend.height()) {
125
- margin.top = legend.height();
126
- availableHeight = (height || parseInt(container.style('height')) || 400)
127
- - margin.top - margin.bottom;
128
- }
129
-
130
- wrap.select('.nv-legendWrap')
131
- .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')');
132
- }
133
-
134
-
135
- scatter
136
- .width(availableWidth)
137
- .height(availableHeight)
138
- .color(data.map(function(d,i) {
139
- return d.color || color(d, i);
140
- }).filter(function(d,i) { return !data[i].disabled }))
141
-
142
-
143
- if (showControls) {
144
- controls.width(180).color(['#444']);
145
- g.select('.nv-controlsWrap')
146
- .datum(controlsData)
147
- .attr('transform', 'translate(0,' + (-margin.top) +')')
148
- .call(controls);
149
- }
150
-
151
-
152
- g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
153
-
154
-
155
- var scatterWrap = wrap.select('.nv-scatterWrap')
156
- .datum(data.filter(function(d) { return !d.disabled }));
157
- d3.transition(scatterWrap).call(scatter);
158
-
159
-
160
- xAxis
161
- .ticks( availableWidth / 100 )
162
- .tickSize( -availableHeight , 0);
163
-
164
- g.select('.nv-x.nv-axis')
165
- .attr('transform', 'translate(0,' + y.range()[0] + ')');
166
- d3.transition(g.select('.nv-x.nv-axis'))
167
- .call(xAxis);
168
-
169
-
170
- yAxis
171
- .ticks( availableHeight / 36 )
172
- .tickSize( -availableWidth, 0);
173
-
174
- d3.transition(g.select('.nv-y.nv-axis'))
175
- .call(yAxis);
176
-
177
-
178
-
179
-
180
- //TODO abstract Distribution into its own component
181
- if ( showDistX || showDistY) {
182
- var distWrap = scatterWrap.selectAll('g.nv-distribution')
183
- .data(function(d) { return d }, function(d) { return d.key });
184
-
185
- distWrap.enter().append('g').attr('class', function(d,i) { return 'nv-distribution nv-series-' + i })
186
-
187
- distWrap.style('stroke', function(d,i) { return color.filter(function(d,i) { return data[i] && !data[i].disabled })[i % color.length] })
188
- }
189
-
190
- if (showDistX) {
191
- var distX = distWrap.selectAll('line.nv-distX')
192
- .data(function(d) { return d.values })
193
- distX.enter().append('line')
194
- .attr('x1', function(d,i) { return x0(scatter.x()(d,i)) })
195
- .attr('x2', function(d,i) { return x0(scatter.x()(d,i)) })
196
- //d3.transition(distX.exit())
197
- d3.transition(distWrap.exit().selectAll('line.nv-distX'))
198
- .attr('x1', function(d,i) { return x(scatter.x()(d,i)) })
199
- .attr('x2', function(d,i) { return x(scatter.x()(d,i)) })
200
- .remove();
201
- distX
202
- .attr('class', function(d,i) { return 'nv-distX nv-distX-' + i })
203
- .attr('y1', y.range()[0])
204
- .attr('y2', y.range()[0] + 8);
205
- d3.transition(distX)
206
- .attr('x1', function(d,i) { return x(scatter.x()(d,i)) })
207
- .attr('x2', function(d,i) { return x(scatter.x()(d,i)) })
208
- }
209
-
210
-
211
- if (showDistY) {
212
- var distY = distWrap.selectAll('line.nv-distY')
213
- .data(function(d) { return d.values })
214
- distY.enter().append('line')
215
- .attr('y1', function(d,i) { return y0(scatter.y()(d,i)) })
216
- .attr('y2', function(d,i) { return y0(scatter.y()(d,i)) });
217
- //d3.transition(distY.exit())
218
- d3.transition(distWrap.exit().selectAll('line.nv-distY'))
219
- .attr('y1', function(d,i) { return y(scatter.y()(d,i)) })
220
- .attr('y2', function(d,i) { return y(scatter.y()(d,i)) })
221
- .remove();
222
- distY
223
- .attr('class', function(d,i) { return 'nv-distY nv-distY-' + i })
224
- .attr('x1', x.range()[0])
225
- .attr('x2', x.range()[0] - 8)
226
- d3.transition(distY)
227
- .attr('y1', function(d,i) { return y(scatter.y()(d,i)) })
228
- .attr('y2', function(d,i) { return y(scatter.y()(d,i)) });
229
- }
230
-
231
-
232
-
233
-
234
- legend.dispatch.on('legendClick', function(d,i, that) {
235
- d.disabled = !d.disabled;
236
-
237
- if (!data.filter(function(d) { return !d.disabled }).length) {
238
- data.map(function(d) {
239
- d.disabled = false;
240
- wrap.selectAll('.nv-series').classed('disabled', false);
241
- return d;
242
- });
243
- }
244
-
245
- selection.transition().call(chart)
246
- });
247
-
248
- controls.dispatch.on('legendClick', function(d,i) {
249
- d.disabled = !d.disabled;
250
-
251
- fisheye = d.disabled ? 0 : 2.5;
252
- g.select('.nv-background').style('pointer-events', d.disabled ? 'none' : 'all');
253
- scatter.interactive(d.disabled);
254
- tooltips = d.disabled;
255
-
256
- if (d.disabled) {
257
- x.distortion(fisheye).focus(0);
258
- y.distortion(fisheye).focus(0);
259
-
260
- scatterWrap.call(scatter);
261
- g.select('.nv-x.nv-axis').call(xAxis);
262
- g.select('.nv-y.nv-axis').call(yAxis);
263
- }
264
-
265
- selection.transition().call(chart);
266
- });
267
-
268
- /*
269
- legend.dispatch.on('legendMouseover', function(d, i) {
270
- d.hover = true;
271
- selection.transition().call(chart)
272
- });
273
-
274
- legend.dispatch.on('legendMouseout', function(d, i) {
275
- d.hover = false;
276
- selection.transition().call(chart)
277
- });
278
- */
279
-
280
-
281
- scatter.dispatch.on('elementMouseover.tooltip', function(e) {
282
- //scatterWrap.select('.series-' + e.seriesIndex + ' .distX-' + e.pointIndex)
283
- d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distX-' + e.pointIndex)
284
- .attr('y1', e.pos[1]);
285
- //scatterWrap.select('.series-' + e.seriesIndex + ' .distY-' + e.pointIndex)
286
- d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distY-' + e.pointIndex)
287
- .attr('x1', e.pos[0]);
288
-
289
- e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
290
- dispatch.tooltipShow(e);
291
- });
292
- //if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, container[0][0].parentNode) } ); // TODO: maybe merge with above?
293
- dispatch.on('tooltipShow', function(e) {
294
- if (tooltips) showTooltip(e, that.parentNode);
295
- });
296
-
297
- scatter.dispatch.on('elementMouseout.tooltip', function(e) {
298
- dispatch.tooltipHide(e);
299
-
300
- //scatterWrap.select('.series-' + e.seriesIndex + ' .distX-' + e.pointIndex)
301
- d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distX-' + e.pointIndex)
302
- .attr('y1', y.range()[0]);
303
- //scatterWrap.select('.series-' + e.seriesIndex + ' .distY-' + e.pointIndex)
304
- d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distY-' + e.pointIndex)
305
- .attr('x1', x.range()[0]);
306
- });
307
- dispatch.on('tooltipHide', nv.tooltip.cleanup);
308
-
309
-
310
-
311
- //TODO: get distributions to work with fisheye
312
- g.select('.nv-background').on('mousemove', updateFisheye);
313
- g.select('.nv-point-paths').on('mousemove', updateFisheye);
314
-
315
- function updateFisheye() {
316
- var mouse = d3.mouse(this);
317
- x.distortion(fisheye).focus(mouse[0]);
318
- y.distortion(fisheye).focus(mouse[1]);
319
-
320
- scatterWrap.call(scatter);
321
- g.select('.nv-x.nv-axis').call(xAxis);
322
- g.select('.nv-y.nv-axis').call(yAxis);
323
- }
324
-
325
- //store old scales for use in transitions on update, to animate from old to new positions, and sizes
326
- x0 = x.copy();
327
- y0 = y.copy();
328
-
329
- });
330
-
331
- return chart;
332
- }
333
-
334
-
335
- chart.dispatch = dispatch;
336
- chart.legend = legend;
337
- chart.xAxis = xAxis;
338
- chart.yAxis = yAxis;
339
-
340
- d3.rebind(chart, scatter, 'interactive', 'shape', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius', 'fisheye', 'fisheyeRadius');
341
-
342
-
343
- chart.margin = function(_) {
344
- if (!arguments.length) return margin;
345
- margin = _;
346
- return chart;
347
- };
348
-
349
- chart.width = function(_) {
350
- if (!arguments.length) return width;
351
- width = _;
352
- return chart;
353
- };
354
-
355
- chart.height = function(_) {
356
- if (!arguments.length) return height;
357
- height = _;
358
- return chart;
359
- };
360
-
361
- chart.color = function(_) {
362
- if (!arguments.length) return color;
363
- color = nv.utils.getColor(_);
364
- legend.color(color);
365
- return chart;
366
- };
367
-
368
- chart.showDistX = function(_) {
369
- if (!arguments.length) return showDistX;
370
- showDistX = _;
371
- return chart;
372
- };
373
-
374
- chart.showDistY = function(_) {
375
- if (!arguments.length) return showDistY;
376
- showDistY = _;
377
- return chart;
378
- };
379
-
380
- chart.showControls = function(_) {
381
- if (!arguments.length) return showControls;
382
- showControls = _;
383
- return chart;
384
- };
385
-
386
- chart.showLegend = function(_) {
387
- if (!arguments.length) return showLegend;
388
- showLegend = _;
389
- return chart;
390
- };
391
-
392
- chart.fisheye = function(_) {
393
- if (!arguments.length) return fisheye;
394
- fisheye = _;
395
- return chart;
396
- };
397
-
398
- chart.tooltips = function(_) {
399
- if (!arguments.length) return tooltips;
400
- tooltips = _;
401
- return chart;
402
- };
403
-
404
- chart.tooltipContent = function(_) {
405
- if (!arguments.length) return tooltip;
406
- tooltip = _;
407
- return chart;
408
- };
409
-
410
- chart.noData = function(_) {
411
- if (!arguments.length) return noData;
412
- noData = _;
413
- return chart;
414
- };
415
-
416
-
417
- return chart;
418
- }
@@ -1,167 +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
- margin: 0;
11
- padding: 0;
12
- }
13
-
14
- svg {
15
- overflow: hidden;
16
- }
17
-
18
- div {
19
- border: 0;
20
- margin: 0;
21
- }
22
-
23
-
24
- #offsetDiv {
25
- }
26
-
27
-
28
- #test1 {
29
- margin: 0;
30
- }
31
-
32
-
33
- </style>
34
-
35
- <body>
36
-
37
- <div id="offsetDiv">
38
- <div id="test1" class="chartWrap">
39
- <svg></svg>
40
- </div>
41
- </div>
42
-
43
- <script src="../lib/d3.v2.js"></script>
44
- <script src="../nv.d3.js"></script>
45
- <script src="../src/tooltip.js"></script>
46
- <script src="../src/models/legend.js"></script>
47
- <script src="../src/models/axis.js"></script>
48
- <script src="../src/models/scatter.js"></script>
49
- <script src="../src/models/scatterWithLegend.js"></script>
50
- <script>
51
-
52
-
53
-
54
- //Format A
55
- nv.addGraph({
56
- generate: function() {
57
- var width = nv.utils.windowSize().width - 40,
58
- height = nv.utils.windowSize().height - 40;
59
-
60
- var chart = nv.models.scatterWithLegend()
61
- .width(width)
62
- .height(height)
63
- .showDistX(true)
64
- .showDistY(true)
65
- .color(d3.scale.category10().range());
66
- //.width(width)
67
- //.height(height)
68
- //.forceX([-4,4])
69
- //.forceY([-4,4])
70
- //.margin({top: 20, right: 10, bottom: 50, left: 80})
71
-
72
-
73
- //chart.xaxis.tickFormat(d3.format(".02f"))
74
-
75
- var svg =d3.select('#test1 svg')
76
- .datum(randomData());
77
-
78
-
79
- svg.transition().duration(500)
80
- .attr('width', width)
81
- .attr('height', height)
82
- .call(chart)
83
- //.attr('width', wid0th)
84
- //.attr('height', height)
85
-
86
- return chart;
87
- },
88
- callback: function(graph) {
89
-
90
- graph.dispatch.on('tooltipShow', function(e) {
91
- var offsetElement = document.getElementById("test1"),
92
- left = e.pos[0] + offsetElement.offsetLeft,
93
- top = e.pos[1] + offsetElement.offsetTop,
94
- formatter = d3.format(".2f");
95
-
96
-
97
- /*
98
- var content = '<h3>' + e.series.key + '</h3>' +
99
- '<p>' +
100
- '<span class="value"><span class="label">x:</span><span class="val">' + formatter(e.point.x) + '</span></span><br>' +
101
- '<s0pan class="value"><span class="label">y:</span><span class="val">' + formatter(e.point.y) + '</span></span>' +
102
- '</p>';
103
-
104
- nvtooltip.show([left, top], content);
105
- */
106
-
107
- var contentX = '<strong>' + formatter(e.point.x) + '</strong>';
108
- var contentY = '<strong>' + formatter(e.point.y) + '</strong>';
109
- var height = nv.utils.windowSize().height - 40;
110
-
111
- nv.tooltip.show([left, height - 50], contentX, 'n', 1);
112
- nv.tooltip.show([5, top], contentY, 'w', 1);
113
- });
114
-
115
-
116
- graph.dispatch.on('tooltipHide', function(e) {
117
- nv.tooltip.cleanup();
118
- });
119
-
120
- window.onresize = function() {
121
- var width = nv.utils.windowSize().width - 40,
122
- height = nv.utils.windowSize().height - 40,
123
- margin = graph.margin();
124
-
125
-
126
- if (width < margin.left + margin.right + 20)
127
- width = margin.left + margin.right + 20;
128
-
129
- if (height < margin.top + margin.bottom + 20)
130
- height = margin.top + margin.bottom + 20;
131
-
132
-
133
- graph
134
- .width(width)
135
- .height(height);
136
-
137
- d3.select('#test1 svg')
138
- .attr('width', width)
139
- .attr('height', height)
140
- .call(graph);
141
-
142
- };
143
- }
144
- });
145
-
146
-
147
- function randomData() {
148
- var data = [],
149
- random = d3.random.normal();
150
-
151
- for (i = 0; i < 2; i++) {
152
- data.push({
153
- key: 'Group ' + i,
154
- values: []
155
- });
156
-
157
- for (j = 0; j < 100; j++) {
158
- data[i].values.push({x: random(), y: random(), size: Math.random()});
159
- }
160
- }
161
-
162
- return data;
163
- }
164
-
165
-
166
-
167
- </script>