pyk 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/app/assets/javascripts/lib/chardinjs.min.js +2 -0
- data/app/assets/javascripts/lib/crossfilter.js +1383 -1
- data/app/assets/javascripts/lib/{d3.js → d3.v3.js} +0 -0
- data/app/assets/javascripts/lib/dc.js +3492 -757
- data/app/assets/javascripts/lib/jquery.gridster.js +2 -3621
- data/app/assets/javascripts/lib/markermanager.js +2 -980
- data/app/assets/javascripts/lib/underscore.js +1276 -0
- data/app/assets/javascripts/nvd3/lib/colorbrewer.js +302 -0
- data/app/assets/javascripts/nvd3/lib/crossfilter.js +1180 -0
- data/app/assets/javascripts/nvd3/lib/crossfilter.min.js +1 -0
- data/app/assets/javascripts/nvd3/lib/d3.v2.js +7033 -0
- data/app/assets/javascripts/nvd3/lib/d3.v2.min.js +4 -0
- data/app/assets/javascripts/nvd3/lib/d3.v3.js +8436 -0
- data/app/assets/javascripts/nvd3/lib/fisheye.js +86 -0
- data/app/assets/javascripts/nvd3/lib/hive.js +80 -0
- data/app/assets/javascripts/nvd3/lib/horizon.js +192 -0
- data/app/assets/javascripts/nvd3/lib/sankey.js +292 -0
- data/app/assets/javascripts/nvd3/nv.d3.js +14312 -0
- data/app/assets/javascripts/nvd3/nv.d3.min.js +6 -0
- data/app/assets/javascripts/nvd3/src/core.js +122 -0
- data/app/assets/javascripts/nvd3/src/interactiveLayer.js +251 -0
- data/app/assets/javascripts/nvd3/src/models/axis.js +405 -0
- data/app/assets/javascripts/nvd3/src/models/backup/bullet.js +250 -0
- data/app/assets/javascripts/nvd3/src/models/backup/bulletChart.js +349 -0
- data/app/assets/javascripts/nvd3/src/models/boilerplate.js +104 -0
- data/app/assets/javascripts/nvd3/src/models/bullet.js +385 -0
- data/app/assets/javascripts/nvd3/src/models/bulletChart.js +343 -0
- data/app/assets/javascripts/nvd3/src/models/cumulativeLineChart.js +782 -0
- data/app/assets/javascripts/nvd3/src/models/discreteBar.js +349 -0
- data/app/assets/javascripts/nvd3/src/models/discreteBarChart.js +333 -0
- data/app/assets/javascripts/nvd3/src/models/distribution.js +148 -0
- data/app/assets/javascripts/nvd3/src/models/historicalBar.js +331 -0
- data/app/assets/javascripts/nvd3/src/models/historicalBarChart.js +419 -0
- data/app/assets/javascripts/nvd3/src/models/indentedTree.js +337 -0
- data/app/assets/javascripts/nvd3/src/models/legend.js +270 -0
- data/app/assets/javascripts/nvd3/src/models/line.js +284 -0
- data/app/assets/javascripts/nvd3/src/models/lineChart.js +465 -0
- data/app/assets/javascripts/nvd3/src/models/linePlusBarChart.js +433 -0
- data/app/assets/javascripts/nvd3/src/models/linePlusBarWithFocusChart.js +658 -0
- data/app/assets/javascripts/nvd3/src/models/lineWithFisheye.js +200 -0
- data/app/assets/javascripts/nvd3/src/models/lineWithFisheyeChart.js +297 -0
- data/app/assets/javascripts/nvd3/src/models/lineWithFocusChart.js +574 -0
- data/app/assets/javascripts/nvd3/src/models/multiBar.js +461 -0
- data/app/assets/javascripts/nvd3/src/models/multiBarChart.js +524 -0
- data/app/assets/javascripts/nvd3/src/models/multiBarHorizontal.js +424 -0
- data/app/assets/javascripts/nvd3/src/models/multiBarHorizontalChart.js +434 -0
- data/app/assets/javascripts/nvd3/src/models/multiBarTimeSeries.js +384 -0
- data/app/assets/javascripts/nvd3/src/models/multiBarTimeSeriesChart.js +405 -0
- data/app/assets/javascripts/nvd3/src/models/multiChart.js +452 -0
- data/app/assets/javascripts/nvd3/src/models/ohlcBar.js +380 -0
- data/app/assets/javascripts/nvd3/src/models/parallelCoordinates.js +239 -0
- data/app/assets/javascripts/nvd3/src/models/pie.js +398 -0
- data/app/assets/javascripts/nvd3/src/models/pieChart.js +292 -0
- data/app/assets/javascripts/nvd3/src/models/scatter.js +674 -0
- data/app/assets/javascripts/nvd3/src/models/scatterChart.js +628 -0
- data/app/assets/javascripts/nvd3/src/models/scatterPlusLineChart.js +620 -0
- data/app/assets/javascripts/nvd3/src/models/sparkline.js +194 -0
- data/app/assets/javascripts/nvd3/src/models/sparklinePlus.js +295 -0
- data/app/assets/javascripts/nvd3/src/models/stackedArea.js +368 -0
- data/app/assets/javascripts/nvd3/src/models/stackedAreaChart.js +629 -0
- data/app/assets/javascripts/nvd3/src/tooltip.js +490 -0
- data/app/assets/javascripts/nvd3/src/utils.js +152 -0
- data/app/assets/javascripts/pyk.js +1 -0
- data/app/assets/stylesheets/lib/chardinjs.css +82 -0
- data/app/assets/stylesheets/nvd3/nv.d3.css +769 -0
- data/app/assets/stylesheets/pyk.css.scss +1 -0
- metadata +61 -2
@@ -0,0 +1,270 @@
|
|
1
|
+
nv.models.legend = function() {
|
2
|
+
"use strict";
|
3
|
+
//============================================================
|
4
|
+
// Public Variables with Default Settings
|
5
|
+
//------------------------------------------------------------
|
6
|
+
|
7
|
+
var margin = {top: 5, right: 0, bottom: 5, left: 0}
|
8
|
+
, width = 400
|
9
|
+
, height = 20
|
10
|
+
, getKey = function(d) { return d.key }
|
11
|
+
, color = nv.utils.defaultColor()
|
12
|
+
, align = true
|
13
|
+
, rightAlign = true
|
14
|
+
, updateState = true //If true, legend will update data.disabled and trigger a 'stateChange' dispatch.
|
15
|
+
, radioButtonMode = false //If true, clicking legend items will cause it to behave like a radio button. (only one can be selected at a time)
|
16
|
+
, dispatch = d3.dispatch('legendClick', 'legendDblclick', 'legendMouseover', 'legendMouseout', 'stateChange')
|
17
|
+
;
|
18
|
+
|
19
|
+
//============================================================
|
20
|
+
|
21
|
+
|
22
|
+
function chart(selection) {
|
23
|
+
selection.each(function(data) {
|
24
|
+
var availableWidth = width - margin.left - margin.right,
|
25
|
+
container = d3.select(this);
|
26
|
+
|
27
|
+
|
28
|
+
//------------------------------------------------------------
|
29
|
+
// Setup containers and skeleton of chart
|
30
|
+
|
31
|
+
var wrap = container.selectAll('g.nv-legend').data([data]);
|
32
|
+
var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-legend').append('g');
|
33
|
+
var g = wrap.select('g');
|
34
|
+
|
35
|
+
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
|
36
|
+
|
37
|
+
//------------------------------------------------------------
|
38
|
+
|
39
|
+
|
40
|
+
var series = g.selectAll('.nv-series')
|
41
|
+
.data(function(d) { return d });
|
42
|
+
var seriesEnter = series.enter().append('g').attr('class', 'nv-series')
|
43
|
+
.on('mouseover', function(d,i) {
|
44
|
+
dispatch.legendMouseover(d,i); //TODO: Make consistent with other event objects
|
45
|
+
})
|
46
|
+
.on('mouseout', function(d,i) {
|
47
|
+
dispatch.legendMouseout(d,i);
|
48
|
+
})
|
49
|
+
.on('click', function(d,i) {
|
50
|
+
dispatch.legendClick(d,i);
|
51
|
+
if (updateState) {
|
52
|
+
if (radioButtonMode) {
|
53
|
+
//Radio button mode: set every series to disabled,
|
54
|
+
// and enable the clicked series.
|
55
|
+
data.forEach(function(series) { series.disabled = true});
|
56
|
+
d.disabled = false;
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
d.disabled = !d.disabled;
|
60
|
+
if (data.every(function(series) { return series.disabled})) {
|
61
|
+
//the default behavior of NVD3 legends is, if every single series
|
62
|
+
// is disabled, turn all series' back on.
|
63
|
+
data.forEach(function(series) { series.disabled = false});
|
64
|
+
}
|
65
|
+
}
|
66
|
+
dispatch.stateChange({
|
67
|
+
disabled: data.map(function(d) { return !!d.disabled })
|
68
|
+
});
|
69
|
+
}
|
70
|
+
})
|
71
|
+
.on('dblclick', function(d,i) {
|
72
|
+
dispatch.legendDblclick(d,i);
|
73
|
+
if (updateState) {
|
74
|
+
//the default behavior of NVD3 legends, when double clicking one,
|
75
|
+
// is to set all other series' to false, and make the double clicked series enabled.
|
76
|
+
data.forEach(function(series) {
|
77
|
+
series.disabled = true;
|
78
|
+
});
|
79
|
+
d.disabled = false;
|
80
|
+
dispatch.stateChange({
|
81
|
+
disabled: data.map(function(d) { return !!d.disabled })
|
82
|
+
});
|
83
|
+
}
|
84
|
+
});
|
85
|
+
seriesEnter.append('circle')
|
86
|
+
.style('stroke-width', 2)
|
87
|
+
.attr('class','nv-legend-symbol')
|
88
|
+
.attr('r', 5);
|
89
|
+
seriesEnter.append('text')
|
90
|
+
.attr('text-anchor', 'start')
|
91
|
+
.attr('class','nv-legend-text')
|
92
|
+
.attr('dy', '.32em')
|
93
|
+
.attr('dx', '8');
|
94
|
+
series.classed('disabled', function(d) { return d.disabled });
|
95
|
+
series.exit().remove();
|
96
|
+
series.select('circle')
|
97
|
+
.style('fill', function(d,i) { return d.color || color(d,i)})
|
98
|
+
.style('stroke', function(d,i) { return d.color || color(d, i) });
|
99
|
+
series.select('text').text(getKey);
|
100
|
+
|
101
|
+
|
102
|
+
//TODO: implement fixed-width and max-width options (max-width is especially useful with the align option)
|
103
|
+
|
104
|
+
// NEW ALIGNING CODE, TODO: clean up
|
105
|
+
if (align) {
|
106
|
+
|
107
|
+
var seriesWidths = [];
|
108
|
+
series.each(function(d,i) {
|
109
|
+
var legendText = d3.select(this).select('text');
|
110
|
+
var nodeTextLength;
|
111
|
+
try {
|
112
|
+
nodeTextLength = legendText.node().getComputedTextLength();
|
113
|
+
}
|
114
|
+
catch(e) {
|
115
|
+
nodeTextLength = nv.utils.calcApproxTextWidth(legendText);
|
116
|
+
}
|
117
|
+
|
118
|
+
seriesWidths.push(nodeTextLength + 28); // 28 is ~ the width of the circle plus some padding
|
119
|
+
});
|
120
|
+
|
121
|
+
var seriesPerRow = 0;
|
122
|
+
var legendWidth = 0;
|
123
|
+
var columnWidths = [];
|
124
|
+
|
125
|
+
while ( legendWidth < availableWidth && seriesPerRow < seriesWidths.length) {
|
126
|
+
columnWidths[seriesPerRow] = seriesWidths[seriesPerRow];
|
127
|
+
legendWidth += seriesWidths[seriesPerRow++];
|
128
|
+
}
|
129
|
+
if (seriesPerRow === 0) seriesPerRow = 1; //minimum of one series per row
|
130
|
+
|
131
|
+
|
132
|
+
while ( legendWidth > availableWidth && seriesPerRow > 1 ) {
|
133
|
+
columnWidths = [];
|
134
|
+
seriesPerRow--;
|
135
|
+
|
136
|
+
for (var k = 0; k < seriesWidths.length; k++) {
|
137
|
+
if (seriesWidths[k] > (columnWidths[k % seriesPerRow] || 0) )
|
138
|
+
columnWidths[k % seriesPerRow] = seriesWidths[k];
|
139
|
+
}
|
140
|
+
|
141
|
+
legendWidth = columnWidths.reduce(function(prev, cur, index, array) {
|
142
|
+
return prev + cur;
|
143
|
+
});
|
144
|
+
}
|
145
|
+
|
146
|
+
var xPositions = [];
|
147
|
+
for (var i = 0, curX = 0; i < seriesPerRow; i++) {
|
148
|
+
xPositions[i] = curX;
|
149
|
+
curX += columnWidths[i];
|
150
|
+
}
|
151
|
+
|
152
|
+
series
|
153
|
+
.attr('transform', function(d, i) {
|
154
|
+
return 'translate(' + xPositions[i % seriesPerRow] + ',' + (5 + Math.floor(i / seriesPerRow) * 20) + ')';
|
155
|
+
});
|
156
|
+
|
157
|
+
//position legend as far right as possible within the total width
|
158
|
+
if (rightAlign) {
|
159
|
+
g.attr('transform', 'translate(' + (width - margin.right - legendWidth) + ',' + margin.top + ')');
|
160
|
+
}
|
161
|
+
else {
|
162
|
+
g.attr('transform', 'translate(0' + ',' + margin.top + ')');
|
163
|
+
}
|
164
|
+
|
165
|
+
height = margin.top + margin.bottom + (Math.ceil(seriesWidths.length / seriesPerRow) * 20);
|
166
|
+
|
167
|
+
} else {
|
168
|
+
|
169
|
+
var ypos = 5,
|
170
|
+
newxpos = 5,
|
171
|
+
maxwidth = 0,
|
172
|
+
xpos;
|
173
|
+
series
|
174
|
+
.attr('transform', function(d, i) {
|
175
|
+
var length = d3.select(this).select('text').node().getComputedTextLength() + 28;
|
176
|
+
xpos = newxpos;
|
177
|
+
|
178
|
+
if (width < margin.left + margin.right + xpos + length) {
|
179
|
+
newxpos = xpos = 5;
|
180
|
+
ypos += 20;
|
181
|
+
}
|
182
|
+
|
183
|
+
newxpos += length;
|
184
|
+
if (newxpos > maxwidth) maxwidth = newxpos;
|
185
|
+
|
186
|
+
return 'translate(' + xpos + ',' + ypos + ')';
|
187
|
+
});
|
188
|
+
|
189
|
+
//position legend as far right as possible within the total width
|
190
|
+
g.attr('transform', 'translate(' + (width - margin.right - maxwidth) + ',' + margin.top + ')');
|
191
|
+
|
192
|
+
height = margin.top + margin.bottom + ypos + 15;
|
193
|
+
|
194
|
+
}
|
195
|
+
|
196
|
+
});
|
197
|
+
|
198
|
+
return chart;
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
//============================================================
|
203
|
+
// Expose Public Variables
|
204
|
+
//------------------------------------------------------------
|
205
|
+
|
206
|
+
chart.dispatch = dispatch;
|
207
|
+
chart.options = nv.utils.optionsFunc.bind(chart);
|
208
|
+
|
209
|
+
chart.margin = function(_) {
|
210
|
+
if (!arguments.length) return margin;
|
211
|
+
margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
|
212
|
+
margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
|
213
|
+
margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
|
214
|
+
margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
|
215
|
+
return chart;
|
216
|
+
};
|
217
|
+
|
218
|
+
chart.width = function(_) {
|
219
|
+
if (!arguments.length) return width;
|
220
|
+
width = _;
|
221
|
+
return chart;
|
222
|
+
};
|
223
|
+
|
224
|
+
chart.height = function(_) {
|
225
|
+
if (!arguments.length) return height;
|
226
|
+
height = _;
|
227
|
+
return chart;
|
228
|
+
};
|
229
|
+
|
230
|
+
chart.key = function(_) {
|
231
|
+
if (!arguments.length) return getKey;
|
232
|
+
getKey = _;
|
233
|
+
return chart;
|
234
|
+
};
|
235
|
+
|
236
|
+
chart.color = function(_) {
|
237
|
+
if (!arguments.length) return color;
|
238
|
+
color = nv.utils.getColor(_);
|
239
|
+
return chart;
|
240
|
+
};
|
241
|
+
|
242
|
+
chart.align = function(_) {
|
243
|
+
if (!arguments.length) return align;
|
244
|
+
align = _;
|
245
|
+
return chart;
|
246
|
+
};
|
247
|
+
|
248
|
+
chart.rightAlign = function(_) {
|
249
|
+
if (!arguments.length) return rightAlign;
|
250
|
+
rightAlign = _;
|
251
|
+
return chart;
|
252
|
+
};
|
253
|
+
|
254
|
+
chart.updateState = function(_) {
|
255
|
+
if (!arguments.length) return updateState;
|
256
|
+
updateState = _;
|
257
|
+
return chart;
|
258
|
+
};
|
259
|
+
|
260
|
+
chart.radioButtonMode = function(_) {
|
261
|
+
if (!arguments.length) return radioButtonMode;
|
262
|
+
radioButtonMode = _;
|
263
|
+
return chart;
|
264
|
+
};
|
265
|
+
|
266
|
+
//============================================================
|
267
|
+
|
268
|
+
|
269
|
+
return chart;
|
270
|
+
}
|
@@ -0,0 +1,284 @@
|
|
1
|
+
|
2
|
+
nv.models.line = function() {
|
3
|
+
"use strict";
|
4
|
+
//============================================================
|
5
|
+
// Public Variables with Default Settings
|
6
|
+
//------------------------------------------------------------
|
7
|
+
|
8
|
+
var scatter = nv.models.scatter()
|
9
|
+
;
|
10
|
+
|
11
|
+
var margin = {top: 0, right: 0, bottom: 0, left: 0}
|
12
|
+
, width = 960
|
13
|
+
, height = 500
|
14
|
+
, color = nv.utils.defaultColor() // a function that returns a color
|
15
|
+
, getX = function(d) { return d.x } // accessor to get the x value from a data point
|
16
|
+
, getY = function(d) { return d.y } // accessor to get the y value from a data point
|
17
|
+
, defined = function(d,i) { return !isNaN(getY(d,i)) && getY(d,i) !== null } // allows a line to be not continuous when it is not defined
|
18
|
+
, isArea = function(d) { return d.area } // decides if a line is an area or just a line
|
19
|
+
, clipEdge = false // if true, masks lines within x and y scale
|
20
|
+
, x //can be accessed via chart.xScale()
|
21
|
+
, y //can be accessed via chart.yScale()
|
22
|
+
, interpolate = "linear" // controls the line interpolation
|
23
|
+
;
|
24
|
+
|
25
|
+
scatter
|
26
|
+
.size(16) // default size
|
27
|
+
.sizeDomain([16,256]) //set to speed up calculation, needs to be unset if there is a custom size accessor
|
28
|
+
;
|
29
|
+
|
30
|
+
//============================================================
|
31
|
+
|
32
|
+
|
33
|
+
//============================================================
|
34
|
+
// Private Variables
|
35
|
+
//------------------------------------------------------------
|
36
|
+
|
37
|
+
var x0, y0 //used to store previous scales
|
38
|
+
;
|
39
|
+
|
40
|
+
//============================================================
|
41
|
+
|
42
|
+
|
43
|
+
function chart(selection) {
|
44
|
+
selection.each(function(data) {
|
45
|
+
var availableWidth = width - margin.left - margin.right,
|
46
|
+
availableHeight = height - margin.top - margin.bottom,
|
47
|
+
container = d3.select(this);
|
48
|
+
|
49
|
+
//------------------------------------------------------------
|
50
|
+
// Setup Scales
|
51
|
+
|
52
|
+
x = scatter.xScale();
|
53
|
+
y = scatter.yScale();
|
54
|
+
|
55
|
+
x0 = x0 || x;
|
56
|
+
y0 = y0 || y;
|
57
|
+
|
58
|
+
//------------------------------------------------------------
|
59
|
+
|
60
|
+
|
61
|
+
//------------------------------------------------------------
|
62
|
+
// Setup containers and skeleton of chart
|
63
|
+
|
64
|
+
var wrap = container.selectAll('g.nv-wrap.nv-line').data([data]);
|
65
|
+
var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-line');
|
66
|
+
var defsEnter = wrapEnter.append('defs');
|
67
|
+
var gEnter = wrapEnter.append('g');
|
68
|
+
var g = wrap.select('g')
|
69
|
+
|
70
|
+
gEnter.append('g').attr('class', 'nv-groups');
|
71
|
+
gEnter.append('g').attr('class', 'nv-scatterWrap');
|
72
|
+
|
73
|
+
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
|
74
|
+
|
75
|
+
//------------------------------------------------------------
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
scatter
|
81
|
+
.width(availableWidth)
|
82
|
+
.height(availableHeight)
|
83
|
+
|
84
|
+
var scatterWrap = wrap.select('.nv-scatterWrap');
|
85
|
+
//.datum(data); // Data automatically trickles down from the wrap
|
86
|
+
|
87
|
+
scatterWrap.transition().call(scatter);
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
defsEnter.append('clipPath')
|
92
|
+
.attr('id', 'nv-edge-clip-' + scatter.id())
|
93
|
+
.append('rect');
|
94
|
+
|
95
|
+
wrap.select('#nv-edge-clip-' + scatter.id() + ' rect')
|
96
|
+
.attr('width', availableWidth)
|
97
|
+
.attr('height', availableHeight);
|
98
|
+
|
99
|
+
g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : '');
|
100
|
+
scatterWrap
|
101
|
+
.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : '');
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
var groups = wrap.select('.nv-groups').selectAll('.nv-group')
|
107
|
+
.data(function(d) { return d }, function(d) { return d.key });
|
108
|
+
groups.enter().append('g')
|
109
|
+
.style('stroke-opacity', 1e-6)
|
110
|
+
.style('fill-opacity', 1e-6);
|
111
|
+
groups.exit()
|
112
|
+
.transition()
|
113
|
+
.style('stroke-opacity', 1e-6)
|
114
|
+
.style('fill-opacity', 1e-6)
|
115
|
+
.remove();
|
116
|
+
groups
|
117
|
+
.attr('class', function(d,i) { return 'nv-group nv-series-' + i })
|
118
|
+
.classed('hover', function(d) { return d.hover })
|
119
|
+
.style('fill', function(d,i){ return color(d, i) })
|
120
|
+
.style('stroke', function(d,i){ return color(d, i)});
|
121
|
+
groups
|
122
|
+
.transition()
|
123
|
+
.style('stroke-opacity', 1)
|
124
|
+
.style('fill-opacity', .5);
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
var areaPaths = groups.selectAll('path.nv-area')
|
129
|
+
.data(function(d) { return isArea(d) ? [d] : [] }); // this is done differently than lines because I need to check if series is an area
|
130
|
+
areaPaths.enter().append('path')
|
131
|
+
.attr('class', 'nv-area')
|
132
|
+
.attr('d', function(d) {
|
133
|
+
return d3.svg.area()
|
134
|
+
.interpolate(interpolate)
|
135
|
+
.defined(defined)
|
136
|
+
.x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) })
|
137
|
+
.y0(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) })
|
138
|
+
.y1(function(d,i) { return y0( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) })
|
139
|
+
//.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this
|
140
|
+
.apply(this, [d.values])
|
141
|
+
});
|
142
|
+
groups.exit().selectAll('path.nv-area')
|
143
|
+
.remove();
|
144
|
+
|
145
|
+
areaPaths
|
146
|
+
.transition()
|
147
|
+
.attr('d', function(d) {
|
148
|
+
return d3.svg.area()
|
149
|
+
.interpolate(interpolate)
|
150
|
+
.defined(defined)
|
151
|
+
.x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) })
|
152
|
+
.y0(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) })
|
153
|
+
.y1(function(d,i) { return y( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) })
|
154
|
+
//.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this
|
155
|
+
.apply(this, [d.values])
|
156
|
+
});
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
var linePaths = groups.selectAll('path.nv-line')
|
161
|
+
.data(function(d) { return [d.values] });
|
162
|
+
linePaths.enter().append('path')
|
163
|
+
.attr('class', 'nv-line')
|
164
|
+
.attr('d',
|
165
|
+
d3.svg.line()
|
166
|
+
.interpolate(interpolate)
|
167
|
+
.defined(defined)
|
168
|
+
.x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) })
|
169
|
+
.y(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) })
|
170
|
+
);
|
171
|
+
groups.exit().selectAll('path.nv-line')
|
172
|
+
.transition()
|
173
|
+
.attr('d',
|
174
|
+
d3.svg.line()
|
175
|
+
.interpolate(interpolate)
|
176
|
+
.defined(defined)
|
177
|
+
.x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) })
|
178
|
+
.y(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) })
|
179
|
+
);
|
180
|
+
linePaths
|
181
|
+
.transition()
|
182
|
+
.attr('d',
|
183
|
+
d3.svg.line()
|
184
|
+
.interpolate(interpolate)
|
185
|
+
.defined(defined)
|
186
|
+
.x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) })
|
187
|
+
.y(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) })
|
188
|
+
);
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
//store old scales for use in transitions on update
|
193
|
+
x0 = x.copy();
|
194
|
+
y0 = y.copy();
|
195
|
+
|
196
|
+
});
|
197
|
+
|
198
|
+
return chart;
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
//============================================================
|
203
|
+
// Expose Public Variables
|
204
|
+
//------------------------------------------------------------
|
205
|
+
|
206
|
+
chart.dispatch = scatter.dispatch;
|
207
|
+
chart.scatter = scatter;
|
208
|
+
|
209
|
+
d3.rebind(chart, scatter, 'id', 'interactive', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange',
|
210
|
+
'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'useVoronoi', 'clipRadius', 'padData','highlightPoint','clearHighlights');
|
211
|
+
|
212
|
+
chart.options = nv.utils.optionsFunc.bind(chart);
|
213
|
+
|
214
|
+
chart.margin = function(_) {
|
215
|
+
if (!arguments.length) return margin;
|
216
|
+
margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
|
217
|
+
margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
|
218
|
+
margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
|
219
|
+
margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
|
220
|
+
return chart;
|
221
|
+
};
|
222
|
+
|
223
|
+
chart.width = function(_) {
|
224
|
+
if (!arguments.length) return width;
|
225
|
+
width = _;
|
226
|
+
return chart;
|
227
|
+
};
|
228
|
+
|
229
|
+
chart.height = function(_) {
|
230
|
+
if (!arguments.length) return height;
|
231
|
+
height = _;
|
232
|
+
return chart;
|
233
|
+
};
|
234
|
+
|
235
|
+
chart.x = function(_) {
|
236
|
+
if (!arguments.length) return getX;
|
237
|
+
getX = _;
|
238
|
+
scatter.x(_);
|
239
|
+
return chart;
|
240
|
+
};
|
241
|
+
|
242
|
+
chart.y = function(_) {
|
243
|
+
if (!arguments.length) return getY;
|
244
|
+
getY = _;
|
245
|
+
scatter.y(_);
|
246
|
+
return chart;
|
247
|
+
};
|
248
|
+
|
249
|
+
chart.clipEdge = function(_) {
|
250
|
+
if (!arguments.length) return clipEdge;
|
251
|
+
clipEdge = _;
|
252
|
+
return chart;
|
253
|
+
};
|
254
|
+
|
255
|
+
chart.color = function(_) {
|
256
|
+
if (!arguments.length) return color;
|
257
|
+
color = nv.utils.getColor(_);
|
258
|
+
scatter.color(color);
|
259
|
+
return chart;
|
260
|
+
};
|
261
|
+
|
262
|
+
chart.interpolate = function(_) {
|
263
|
+
if (!arguments.length) return interpolate;
|
264
|
+
interpolate = _;
|
265
|
+
return chart;
|
266
|
+
};
|
267
|
+
|
268
|
+
chart.defined = function(_) {
|
269
|
+
if (!arguments.length) return defined;
|
270
|
+
defined = _;
|
271
|
+
return chart;
|
272
|
+
};
|
273
|
+
|
274
|
+
chart.isArea = function(_) {
|
275
|
+
if (!arguments.length) return isArea;
|
276
|
+
isArea = d3.functor(_);
|
277
|
+
return chart;
|
278
|
+
};
|
279
|
+
|
280
|
+
//============================================================
|
281
|
+
|
282
|
+
|
283
|
+
return chart;
|
284
|
+
}
|