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,263 +0,0 @@
1
-
2
- nv.models.pie = function() {
3
- var margin = {top: 20, right: 20, bottom: 20, left: 20},
4
- width = 500,
5
- height = 500,
6
- animate = 2000,
7
- radius = Math.min(width-(margin.right+margin.left), height-(margin.top+margin.bottom)) / 2,
8
- label ='label',
9
- field ='y',
10
- id = Math.floor(Math.random() * 10000), //Create semi-unique ID in case user doesn't select one
11
- color = d3.scale.category20(),
12
- showLabels = true,
13
- donut = false,
14
- title = '';
15
-
16
- var lastWidth = 0,
17
- lastHeight = 0;
18
-
19
-
20
- var dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'tooltipShow', 'tooltipHide');
21
-
22
- function chart(selection) {
23
- selection.each(function(data) {
24
-
25
- var svg = d3.select(this)
26
- .on("click", function(d,i) {
27
- dispatch.chartClick({
28
- data: d,
29
- index: i,
30
- pos: d3.event,
31
- id: id
32
- });
33
- });
34
-
35
-
36
-
37
- var background = svg.selectAll('svg.margin').data([data]);
38
- var parent = background.enter();
39
- parent.append("text")
40
- .attr("class", "title")
41
- .attr("dy", ".91em")
42
- .attr("text-anchor", "start")
43
- .text(title);
44
- parent.append('svg')
45
- .attr('class','margin')
46
- .attr('x', margin.left)
47
- .attr('y', margin.top)
48
- .style('overflow','visible');
49
-
50
- var wrap = background.selectAll('g.wrap').data([data]);
51
- wrap.exit().remove();
52
- var wEnter = wrap.enter();
53
-
54
- wEnter
55
- .append('g')
56
- .attr('class', 'wrap')
57
- .attr('id','wrap-'+id)
58
- .append('g')
59
- .attr('class', 'pie');
60
-
61
-
62
-
63
- wrap
64
- .attr('width', width) //-(margin.left+margin.right))
65
- .attr('height', height) //-(margin.top+margin.bottom))
66
- .attr("transform", "translate(" + radius + "," + radius + ")");
67
-
68
-
69
-
70
-
71
- var arc = d3.svg.arc()
72
- .outerRadius((radius-(radius / 5)));
73
-
74
- if (donut) arc.innerRadius(radius / 2);
75
-
76
-
77
- // Setup the Pie chart and choose the data element
78
- var pie = d3.layout.pie()
79
- .value(function (d) { return d[field]; });
80
-
81
- var slices = background.select('.pie').selectAll(".slice")
82
- .data(pie);
83
-
84
- slices.exit().remove();
85
-
86
- var ae = slices.enter().append("svg:g")
87
- .attr("class", "slice")
88
- .on('mouseover', function(d,i){
89
- d3.select(this).classed('hover', true);
90
- dispatch.tooltipShow({
91
- label: d.data[label],
92
- value: d.data[field],
93
- data: d.data,
94
- index: i,
95
- pos: [d3.event.pageX, d3.event.pageY],
96
- id: id
97
- });
98
-
99
- })
100
- .on('mouseout', function(d,i){
101
- d3.select(this).classed('hover', false);
102
- dispatch.tooltipHide({
103
- label: d.data[label],
104
- value: d.data[field],
105
- data: d.data,
106
- index: i,
107
- id: id
108
- });
109
- })
110
- .on('click', function(d,i) {
111
- dispatch.elementClick({
112
- label: d.data[label],
113
- value: d.data[field],
114
- data: d.data,
115
- index: i,
116
- pos: d3.event,
117
- id: id
118
- });
119
- d3.event.stopPropagation();
120
- })
121
- .on('dblclick', function(d,i) {
122
- dispatch.elementDblClick({
123
- label: d.data[label],
124
- value: d.data[field],
125
- data: d.data,
126
- index: i,
127
- pos: d3.event,
128
- id: id
129
- });
130
- d3.event.stopPropagation();
131
- });
132
-
133
- var paths = ae.append("svg:path")
134
- .attr('class','path')
135
- .attr("fill", function(d, i) { return color(i); });
136
- //.attr('d', arc);
137
-
138
- slices.select('.path')
139
- .attr('d', arc)
140
- .transition()
141
- .ease("bounce")
142
- .duration(animate)
143
- .attrTween("d", tweenPie);
144
-
145
- if (showLabels) {
146
- // This does the normal label
147
- ae.append("text");
148
-
149
- slices.select("text")
150
- .transition()
151
- .duration(animate)
152
- .ease('bounce')
153
- .attr("transform", function(d) {
154
- d.outerRadius = radius + 10; // Set Outer Coordinate
155
- d.innerRadius = radius + 15; // Set Inner Coordinate
156
- return "translate(" + arc.centroid(d) + ")";
157
- })
158
- .attr("text-anchor", "middle") //center the text on it's origin
159
- .style("font", "bold 12px Arial")
160
- .text(function(d, i) { return d.data[label]; });
161
- }
162
-
163
-
164
- // Computes the angle of an arc, converting from radians to degrees.
165
- function angle(d) {
166
- var a = (d.startAngle + d.endAngle) * 90 / Math.PI - 90;
167
- return a > 90 ? a - 180 : a;
168
- }
169
-
170
-
171
-
172
-
173
-
174
- function tweenPie(b) {
175
- b.innerRadius = 0;
176
- var i = d3.interpolate({startAngle: 0, endAngle: 0}, b);
177
- return function(t) {
178
- return arc(i(t));
179
- };
180
- }
181
-
182
-
183
- });
184
-
185
- return chart;
186
- }
187
-
188
- chart.margin = function(_) {
189
- if (!arguments.length) return margin;
190
- margin = _;
191
- return chart;
192
- };
193
-
194
- chart.width = function(_) {
195
- if (!arguments.length) return width;
196
- if (margin.left + margin.right + 20 > _) {
197
- width = margin.left + margin.right + 20; // Min width
198
- } else {
199
- width = _;
200
- }
201
- radius = Math.min(width-(margin.left+margin.right), height-(margin.top+margin.bottom)) / 2;
202
- return chart;
203
- };
204
-
205
- chart.height = function(_) {
206
- if (!arguments.length) return height;
207
- if (margin.top + margin.bottom + 20 > _) {
208
- height = margin.top + margin.bottom + 20; // Min height
209
- } else {
210
- height = _;
211
- }
212
- radius = Math.min(width-(margin.left+margin.right), height-(margin.top+margin.bottom)) / 2;
213
- return chart;
214
- };
215
-
216
- chart.animate = function(_) {
217
- if (!arguments.length) return animate;
218
- animate = _;
219
- return chart;
220
- };
221
-
222
- chart.labelField = function(_) {
223
- if (!arguments.length) return (label);
224
- label = _;
225
- return chart;
226
- };
227
-
228
- chart.dataField = function(_) {
229
- if (!arguments.length) return (field);
230
- field = _;
231
- return chart;
232
- };
233
-
234
- chart.showLabels = function(_) {
235
- if (!arguments.length) return (showLabels);
236
- showLabels = _;
237
- return chart;
238
- };
239
-
240
- chart.donut = function(_) {
241
- if (!arguments.length) return (donut);
242
- donut = _;
243
- return chart;
244
- };
245
-
246
- chart.title = function(_) {
247
- if (!arguments.length) return (title);
248
- title = _;
249
- return chart;
250
- };
251
-
252
- chart.id = function(_) {
253
- if (!arguments.length) return id;
254
- id = _;
255
- return chart;
256
- };
257
-
258
- chart.dispatch = dispatch;
259
-
260
-
261
-
262
- return chart;
263
- }
@@ -1,110 +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
- margin-left: 100px;
26
- margin-top: 100px;
27
- }
28
- */
29
-
30
- #test1 {
31
- margin: 0;
32
- height: 500px;
33
- }
34
-
35
- #test1 svg {
36
- height: 500px;
37
- }
38
-
39
- </style>
40
-
41
- <body>
42
-
43
- <div id="offsetDiv">
44
- <div id="test1" class="chartWrap">
45
- <svg></svg>
46
- </div>
47
- </div>
48
-
49
- <script src="../lib/d3.v2.js"></script>
50
- <script src="../lib/fisheye.js"></script>
51
- <script src="../nv.d3.js"></script>
52
- <script src="../src/tooltip.js"></script>
53
- <script src="../src/models/legend.js"></script>
54
- <script src="../src/models/axis.js"></script>
55
- <script src="../src/models/distribution.js"></script>
56
- <script src="../src/models/scatter.js"></script>
57
- <script src="../src/models/scatterChart.js"></script>
58
- <script>
59
-
60
-
61
-
62
- //Format A
63
- nv.addGraph(function() {
64
- var chart = nv.models.scatterChart()
65
- .showDistX(true)
66
- .showDistY(true)
67
- //.height(500)
68
- .color(d3.scale.category10().range());
69
-
70
- chart.xAxis.tickFormat(d3.format('.02f'))
71
- chart.yAxis.tickFormat(d3.format('.02f'))
72
-
73
- d3.select('#test1 svg')
74
- .datum(randomData(4,40))
75
- .transition().duration(500)
76
- .call(chart);
77
-
78
- nv.utils.windowResize(chart.update);
79
-
80
- return chart;
81
- });
82
-
83
-
84
- function randomData(groups, points) { //# groups,# points per group
85
- var data = [],
86
- shapes = ['circle', 'cross', 'triangle-up', 'triangle-down', 'diamond', 'square'],
87
- random = d3.random.normal();
88
-
89
- for (i = 0; i < groups; i++) {
90
- data.push({
91
- key: 'Group ' + i,
92
- values: []
93
- });
94
-
95
- for (j = 0; j < points; j++) {
96
- data[i].values.push({
97
- x: random(),
98
- y: random(),
99
- size: Math.random(),
100
- shape: shapes[j % 6]
101
- });
102
- }
103
- }
104
-
105
- return data;
106
- }
107
-
108
-
109
-
110
- </script>
@@ -1,294 +0,0 @@
1
-
2
- nv.models.scatterChart = 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
- showDistX = false,
8
- showDistY = false,
9
- showLegend = true,
10
- tooltips = true,
11
- tooltipX = function(key, x, y) { return '<strong>' + x + '</strong>' },
12
- tooltipY = function(key, x, y) { return '<strong>' + y + '</strong>' },
13
- tooltip = function(key, x, y, e, graph) {
14
- return '<h3>' + key + '</h3>' +
15
- '<p>' + y + ' at ' + x + '</p>'
16
- };
17
-
18
-
19
- var scatter = nv.models.scatter(),
20
- x = scatter.xScale(),
21
- y = scatter.yScale(),
22
- xAxis = nv.models.axis().orient('bottom').scale(x).tickPadding(10),
23
- yAxis = nv.models.axis().orient('left').scale(y).tickPadding(10),
24
- legend = nv.models.legend().height(30),
25
- distX = nv.models.distribution().axis('x').scale(x),
26
- distY = nv.models.distribution().axis('y').scale(y),
27
- dispatch = d3.dispatch('tooltipShow', 'tooltipHide'),
28
- x0, y0; //TODO: abstract distribution component and have old scales stored there
29
-
30
- var showTooltip = function(e, offsetElement) {
31
- //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?)
32
-
33
- //var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
34
- //top = e.pos[1] + ( offsetElement.offsetTop || 0),
35
- var leftX = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
36
- topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0),
37
- leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ),
38
- topY = e.pos[1] + ( offsetElement.offsetTop || 0),
39
- xVal = xAxis.tickFormat()(scatter.x()(e.point)),
40
- yVal = yAxis.tickFormat()(scatter.y()(e.point)),
41
- contentX = tooltipX(e.series.key, xVal, yVal, e, chart),
42
- contentY = tooltipY(e.series.key, xVal, yVal, e, chart);
43
- //content = tooltip(e.series.key, xVal, yVal, e, chart);
44
-
45
- nv.tooltip.show([leftX, topX], contentX, 'n', 1);
46
- nv.tooltip.show([leftY, topY], contentY, 'e', 1);
47
- //nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's');
48
- };
49
-
50
-
51
- function chart(selection) {
52
- selection.each(function(data) {
53
- var container = d3.select(this),
54
- that = this;
55
-
56
- //TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
57
- chart.update = function() { selection.transition().call(chart) };
58
-
59
-
60
- var availableWidth = (width || parseInt(container.style('width')) || 960)
61
- - margin.left - margin.right,
62
- availableHeight = (height || parseInt(container.style('height')) || 400)
63
- - margin.top - margin.bottom;
64
-
65
-
66
-
67
- x0 = x0 || scatter.xScale();
68
- y0 = y0 || scatter.yScale();
69
-
70
-
71
-
72
- var wrap = container.selectAll('g.wrap.scatterChart').data([data]);
73
- var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 scatterChart chart-' + scatter.id()).append('g');
74
-
75
- gEnter.append('g').attr('class', 'legendWrap');
76
- gEnter.append('g').attr('class', 'x axis');
77
- gEnter.append('g').attr('class', 'y axis');
78
- gEnter.append('g').attr('class', 'scatterWrap');
79
- gEnter.append('g').attr('class', 'distWrap');
80
-
81
- var g = wrap.select('g')
82
-
83
- if (showLegend) {
84
- legend.width( availableWidth / 2 );
85
-
86
- wrap.select('.legendWrap')
87
- .datum(data)
88
- .call(legend);
89
-
90
- if ( margin.top != legend.height()) {
91
- margin.top = legend.height();
92
- availableHeight = (height || parseInt(container.style('height')) || 400)
93
- - margin.top - margin.bottom;
94
- }
95
-
96
- wrap.select('.legendWrap')
97
- .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')');
98
- }
99
-
100
-
101
- scatter
102
- .width(availableWidth)
103
- .height(availableHeight)
104
- .color(data.map(function(d,i) {
105
- return d.color || color[i % color.length];
106
- }).filter(function(d,i) { return !data[i].disabled }))
107
-
108
-
109
- g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
110
-
111
-
112
- var scatterWrap = wrap.select('.scatterWrap')
113
- .datum(data.filter(function(d) { return !d.disabled }));
114
- d3.transition(scatterWrap).call(scatter);
115
-
116
-
117
- xAxis
118
- .ticks( availableWidth / 100 )
119
- .tickSize( -availableHeight , 0);
120
-
121
- g.select('.x.axis')
122
- .attr('transform', 'translate(0,' + y.range()[0] + ')');
123
- d3.transition(g.select('.x.axis'))
124
- .call(xAxis);
125
-
126
-
127
- yAxis
128
- .ticks( availableHeight / 36 )
129
- .tickSize( -availableWidth, 0);
130
-
131
- d3.transition(g.select('.y.axis'))
132
- .call(yAxis);
133
-
134
-
135
- distX
136
- .width(availableWidth)
137
- .color(data.map(function(d,i) {
138
- return d.color || color[i % color.length];
139
- }).filter(function(d,i) { return !data[i].disabled }));
140
- gEnter.select('.distWrap').append('g')
141
- .attr('class', 'distributionX')
142
- .attr('transform', 'translate(0,' + y.range()[0] + ')');
143
- g.select('.distributionX')
144
- .datum(data.filter(function(d) { return !d.disabled }))
145
- .call(distX);
146
-
147
-
148
- distY
149
- .width(availableHeight)
150
- .color(data.map(function(d,i) {
151
- return d.color || color[i % color.length];
152
- }).filter(function(d,i) { return !data[i].disabled }));
153
- gEnter.select('.distWrap').append('g')
154
- .attr('class', 'distributionY')
155
- .attr('transform', 'translate(-' + distY.size() + ',0)');
156
- g.select('.distributionY')
157
- .datum(data.filter(function(d) { return !d.disabled }))
158
- .call(distY);
159
-
160
-
161
-
162
- legend.dispatch.on('legendClick', function(d,i, that) {
163
- d.disabled = !d.disabled;
164
-
165
- if (!data.filter(function(d) { return !d.disabled }).length) {
166
- data.map(function(d) {
167
- d.disabled = false;
168
- wrap.selectAll('.series').classed('disabled', false);
169
- return d;
170
- });
171
- }
172
-
173
- selection.transition().call(chart)
174
- });
175
-
176
- /*
177
- legend.dispatch.on('legendMouseover', function(d, i) {
178
- d.hover = true;
179
- selection.transition().call(chart)
180
- });
181
-
182
- legend.dispatch.on('legendMouseout', function(d, i) {
183
- d.hover = false;
184
- selection.transition().call(chart)
185
- });
186
- */
187
-
188
-
189
- scatter.dispatch.on('elementMouseover.tooltip', function(e) {
190
- d3.select('.chart-' + scatter.id() + ' .series-' + e.seriesIndex + ' .distx-' + e.pointIndex)
191
- .attr('y1', e.pos[1] - availableHeight);
192
- d3.select('.chart-' + scatter.id() + ' .series-' + e.seriesIndex + ' .disty-' + e.pointIndex)
193
- .attr('x2', e.pos[0] + distX.size());
194
-
195
- e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
196
- dispatch.tooltipShow(e);
197
- });
198
- if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, that.parentNode) } ); // TODO: maybe merge with above?
199
-
200
- scatter.dispatch.on('elementMouseout.tooltip', function(e) {
201
- dispatch.tooltipHide(e);
202
-
203
- d3.select('.chart-' + scatter.id() + ' .series-' + e.seriesIndex + ' .distx-' + e.pointIndex)
204
- .attr('y1', 0);
205
- d3.select('.chart-' + scatter.id() + ' .series-' + e.seriesIndex + ' .disty-' + e.pointIndex)
206
- .attr('x2', distY.size());
207
- });
208
- if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup);
209
-
210
-
211
- //store old scales for use in transitions on update, to animate from old to new positions, and sizes
212
- x0 = x.copy();
213
- y0 = y.copy();
214
-
215
- });
216
-
217
- return chart;
218
- }
219
-
220
-
221
- chart.dispatch = dispatch;
222
- chart.legend = legend;
223
- chart.xAxis = xAxis;
224
- chart.yAxis = yAxis;
225
-
226
- d3.rebind(chart, scatter, 'interactive', 'shape', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius', 'fisheye', 'fisheyeRadius');
227
-
228
-
229
- chart.margin = function(_) {
230
- if (!arguments.length) return margin;
231
- margin = _;
232
- return chart;
233
- };
234
-
235
- chart.width = function(_) {
236
- if (!arguments.length) return width;
237
- width = _;
238
- return chart;
239
- };
240
-
241
- chart.height = function(_) {
242
- if (!arguments.length) return height;
243
- height = _;
244
- return chart;
245
- };
246
-
247
- chart.color = function(_) {
248
- if (!arguments.length) return color;
249
- color = _;
250
- legend.color(_);
251
- distX.color(_);
252
- distY.color(_);
253
- return chart;
254
- };
255
-
256
- chart.showDistX = function(_) {
257
- if (!arguments.length) return showDistX;
258
- showDistX = _;
259
- return chart;
260
- };
261
-
262
- chart.showDistY = function(_) {
263
- if (!arguments.length) return showDistY;
264
- showDistY = _;
265
- return chart;
266
- };
267
-
268
- chart.showControls = function(_) {
269
- if (!arguments.length) return showControls;
270
- showControls = _;
271
- return chart;
272
- };
273
-
274
- chart.showLegend = function(_) {
275
- if (!arguments.length) return showLegend;
276
- showLegend = _;
277
- return chart;
278
- };
279
-
280
- chart.tooltips = function(_) {
281
- if (!arguments.length) return tooltips;
282
- tooltips = _;
283
- return chart;
284
- };
285
-
286
- chart.tooltipContent = function(_) {
287
- if (!arguments.length) return tooltip;
288
- tooltip = _;
289
- return chart;
290
- };
291
-
292
-
293
- return chart;
294
- }