chartx 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.gitmodules +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +145 -0
- data/Rakefile +1 -0
- data/chartx.gemspec +40 -0
- data/lib/chartx/engine.rb +11 -0
- data/lib/chartx/helper.rb +184 -0
- data/lib/chartx/version.rb +3 -0
- data/lib/chartx.rb +3 -0
- data/screenshots/barchart.png +0 -0
- data/screenshots/bulletchart.png +0 -0
- data/screenshots/horizontalbarchart.png +0 -0
- data/screenshots/linechart.png +0 -0
- data/screenshots/linewithfocuschart.png +0 -0
- data/screenshots/multibarchart2.png +0 -0
- data/screenshots/piechart.png +0 -0
- data/screenshots/scatterchart.png +0 -0
- data/screenshots/stackedareachart.png +0 -0
- data/screenshots/stackedareachart3.png +0 -0
- data/vendor/assets/javascripts/chartx-core.js +9 -0
- data/vendor/assets/javascripts/chartx-models.js +2 -0
- data/vendor/assets/javascripts/nvd3/.gitignore +27 -0
- data/vendor/assets/javascripts/nvd3/.jshintrc +3 -0
- data/vendor/assets/javascripts/nvd3/LICENSE.md +49 -0
- data/vendor/assets/javascripts/nvd3/README.md +1 -0
- data/vendor/assets/javascripts/nvd3/lib/cie.js +155 -0
- data/vendor/assets/javascripts/nvd3/lib/crossfilter.js +1180 -0
- data/vendor/assets/javascripts/nvd3/lib/crossfilter.min.js +1 -0
- data/vendor/assets/javascripts/nvd3/lib/d3.js +8798 -0
- data/vendor/assets/javascripts/nvd3/lib/d3.min.js +5 -0
- data/vendor/assets/javascripts/nvd3/lib/fisheye.js +86 -0
- data/vendor/assets/javascripts/nvd3/lib/hive.js +80 -0
- data/vendor/assets/javascripts/nvd3/lib/horizon.js +192 -0
- data/vendor/assets/javascripts/nvd3/lib/sankey.js +292 -0
- data/vendor/assets/javascripts/nvd3/nv.d3.js +13048 -0
- data/vendor/assets/javascripts/nvd3/nv.d3.min.js +6 -0
- data/vendor/assets/javascripts/nvd3/src/core.js +118 -0
- data/vendor/assets/javascripts/nvd3/src/intro.js +1 -0
- data/vendor/assets/javascripts/nvd3/src/models/axis.js +398 -0
- data/vendor/assets/javascripts/nvd3/src/models/boilerplate.js +102 -0
- data/vendor/assets/javascripts/nvd3/src/models/bullet.js +377 -0
- data/vendor/assets/javascripts/nvd3/src/models/bulletChart.js +341 -0
- data/vendor/assets/javascripts/nvd3/src/models/cumulativeLineChart.js +685 -0
- data/vendor/assets/javascripts/nvd3/src/models/discreteBar.js +327 -0
- data/vendor/assets/javascripts/nvd3/src/models/discreteBarChart.js +290 -0
- data/vendor/assets/javascripts/nvd3/src/models/distribution.js +146 -0
- data/vendor/assets/javascripts/nvd3/src/models/historicalBar.js +289 -0
- data/vendor/assets/javascripts/nvd3/src/models/historicalBarChart.js +421 -0
- data/vendor/assets/javascripts/nvd3/src/models/indentedTree.js +317 -0
- data/vendor/assets/javascripts/nvd3/src/models/legend.js +207 -0
- data/vendor/assets/javascripts/nvd3/src/models/line.js +284 -0
- data/vendor/assets/javascripts/nvd3/src/models/lineChart.js +421 -0
- data/vendor/assets/javascripts/nvd3/src/models/linePlusBarChart.js +455 -0
- data/vendor/assets/javascripts/nvd3/src/models/linePlusBarWithFocusChart.js +665 -0
- data/vendor/assets/javascripts/nvd3/src/models/lineWithFisheye.js +197 -0
- data/vendor/assets/javascripts/nvd3/src/models/lineWithFisheyeChart.js +319 -0
- data/vendor/assets/javascripts/nvd3/src/models/lineWithFocusChart.js +560 -0
- data/vendor/assets/javascripts/nvd3/src/models/multiBar.js +442 -0
- data/vendor/assets/javascripts/nvd3/src/models/multiBarChart.js +506 -0
- data/vendor/assets/javascripts/nvd3/src/models/multiBarHorizontal.js +420 -0
- data/vendor/assets/javascripts/nvd3/src/models/multiBarHorizontalChart.js +448 -0
- data/vendor/assets/javascripts/nvd3/src/models/multiBarTimeSeries.js +371 -0
- data/vendor/assets/javascripts/nvd3/src/models/multiBarTimeSeriesChart.js +403 -0
- data/vendor/assets/javascripts/nvd3/src/models/multiChart.js +444 -0
- data/vendor/assets/javascripts/nvd3/src/models/ohlcBar.js +365 -0
- data/vendor/assets/javascripts/nvd3/src/models/parallelCoordinates.js +238 -0
- data/vendor/assets/javascripts/nvd3/src/models/pie.js +386 -0
- data/vendor/assets/javascripts/nvd3/src/models/pieChart.js +302 -0
- data/vendor/assets/javascripts/nvd3/src/models/scatter.js +660 -0
- data/vendor/assets/javascripts/nvd3/src/models/scatterChart.js +614 -0
- data/vendor/assets/javascripts/nvd3/src/models/scatterPlusLineChart.js +610 -0
- data/vendor/assets/javascripts/nvd3/src/models/sparkline.js +179 -0
- data/vendor/assets/javascripts/nvd3/src/models/sparklinePlus.js +293 -0
- data/vendor/assets/javascripts/nvd3/src/models/stackedArea.js +336 -0
- data/vendor/assets/javascripts/nvd3/src/models/stackedAreaChart.js +490 -0
- data/vendor/assets/javascripts/nvd3/src/nv.d3.css +704 -0
- data/vendor/assets/javascripts/nvd3/src/outro.js +1 -0
- data/vendor/assets/javascripts/nvd3/src/tooltip.js +133 -0
- data/vendor/assets/javascripts/nvd3/src/utils.js +118 -0
- data/vendor/assets/javascripts/set-env.js.erb +1 -0
- data/vendor/assets/stylesheets/chartx.css +3 -0
- metadata +189 -0
@@ -0,0 +1,197 @@
|
|
1
|
+
|
2
|
+
nv.models.lineWithFisheye = function() {
|
3
|
+
//Default Settings
|
4
|
+
var margin = {top: 0, right: 0, bottom: 0, left: 0},
|
5
|
+
width = 960,
|
6
|
+
height = 500,
|
7
|
+
color = nv.utils.defaultColor(), // function that returns colors
|
8
|
+
id = Math.floor(Math.random() * 10000), //Create semi-unique ID incase user doesn't select one
|
9
|
+
getX = function(d) { return d.x }, // accessor to get the x value from a data point
|
10
|
+
getY = function(d) { return d.y }, // accessor to get the y value from a data point
|
11
|
+
clipEdge = false, // if true, masks lines within x and y scale
|
12
|
+
interpolate = "linear"; // controls the line interpolation
|
13
|
+
|
14
|
+
|
15
|
+
var scatter = nv.models.scatter()
|
16
|
+
.id(id)
|
17
|
+
.size(16) // default size
|
18
|
+
.sizeDomain([16,256]), //set to speed up calculation, needs to be unset if there is a custom size accessor
|
19
|
+
//x = scatter.xScale(),
|
20
|
+
//y = scatter.yScale(),
|
21
|
+
x, y,
|
22
|
+
x0, y0, timeoutID;
|
23
|
+
|
24
|
+
|
25
|
+
function chart(selection) {
|
26
|
+
selection.each(function(data) {
|
27
|
+
var availableWidth = width - margin.left - margin.right,
|
28
|
+
availableHeight = height - margin.top - margin.bottom;
|
29
|
+
|
30
|
+
//get the scales inscase scatter scale was set manually
|
31
|
+
x = x || scatter.xScale();
|
32
|
+
y = y || scatter.yScale();
|
33
|
+
|
34
|
+
//store old scales if they exist
|
35
|
+
x0 = x0 || x;
|
36
|
+
y0 = y0 || y;
|
37
|
+
|
38
|
+
|
39
|
+
var wrap = d3.select(this).selectAll('g.nv-wrap.nv-line').data([data]);
|
40
|
+
var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-line');
|
41
|
+
var defsEnter = wrapEnter.append('defs');
|
42
|
+
var gEnter = wrapEnter.append('g');
|
43
|
+
var g = wrap.select('g')
|
44
|
+
|
45
|
+
wrapEnter.append('g').attr('class', 'nv-scatterWrap');
|
46
|
+
var scatterWrap = wrap.select('.nv-scatterWrap').datum(data);
|
47
|
+
|
48
|
+
gEnter.append('g').attr('class', 'nv-groups');
|
49
|
+
|
50
|
+
|
51
|
+
scatter
|
52
|
+
.width(availableWidth)
|
53
|
+
.height(availableHeight)
|
54
|
+
|
55
|
+
d3.transition(scatterWrap).call(scatter);
|
56
|
+
|
57
|
+
|
58
|
+
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
|
59
|
+
|
60
|
+
|
61
|
+
defsEnter.append('clipPath')
|
62
|
+
.attr('id', 'nv-edge-clip-' + id)
|
63
|
+
.append('rect');
|
64
|
+
|
65
|
+
wrap.select('#nv-edge-clip-' + id + ' rect')
|
66
|
+
.attr('width', availableWidth)
|
67
|
+
.attr('height', availableHeight);
|
68
|
+
|
69
|
+
g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');
|
70
|
+
scatterWrap
|
71
|
+
.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
var groups = wrap.select('.nv-groups').selectAll('.nv-group')
|
77
|
+
.data(function(d) { return d }, function(d) { return d.key });
|
78
|
+
groups.enter().append('g')
|
79
|
+
.style('stroke-opacity', 1e-6)
|
80
|
+
.style('fill-opacity', 1e-6);
|
81
|
+
d3.transition(groups.exit())
|
82
|
+
.style('stroke-opacity', 1e-6)
|
83
|
+
.style('fill-opacity', 1e-6)
|
84
|
+
.remove();
|
85
|
+
groups
|
86
|
+
.attr('class', function(d,i) { return 'nv-group nv-series-' + i })
|
87
|
+
.classed('hover', function(d) { return d.hover })
|
88
|
+
.style('fill', function(d,i){ return color(d, i) })
|
89
|
+
.style('stroke', function(d,i){ return color(d, i) })
|
90
|
+
d3.transition(groups)
|
91
|
+
.style('stroke-opacity', 1)
|
92
|
+
.style('fill-opacity', .5)
|
93
|
+
|
94
|
+
|
95
|
+
var paths = groups.selectAll('path')
|
96
|
+
.data(function(d, i) { return [d.values] });
|
97
|
+
paths.enter().append('path')
|
98
|
+
.attr('class', 'nv-line')
|
99
|
+
.attr('d', d3.svg.line()
|
100
|
+
.interpolate(interpolate)
|
101
|
+
.x(function(d,i) { return x0(getX(d,i)) })
|
102
|
+
.y(function(d,i) { return y0(getY(d,i)) })
|
103
|
+
);
|
104
|
+
d3.transition(groups.exit().selectAll('path'))
|
105
|
+
.attr('d', d3.svg.line()
|
106
|
+
.interpolate(interpolate)
|
107
|
+
.x(function(d,i) { return x(getX(d,i)) })
|
108
|
+
.y(function(d,i) { return y(getY(d,i)) })
|
109
|
+
)
|
110
|
+
.remove(); // redundant? line is already being removed
|
111
|
+
d3.transition(paths)
|
112
|
+
.attr('d', d3.svg.line()
|
113
|
+
.interpolate(interpolate)
|
114
|
+
.x(function(d,i) { return x(getX(d,i)) })
|
115
|
+
.y(function(d,i) { return y(getY(d,i)) })
|
116
|
+
);
|
117
|
+
|
118
|
+
|
119
|
+
//store old scales for use in transitions on update, to animate from old to new positions
|
120
|
+
x0 = x.copy();
|
121
|
+
y0 = y.copy();
|
122
|
+
|
123
|
+
});
|
124
|
+
|
125
|
+
return chart;
|
126
|
+
}
|
127
|
+
|
128
|
+
|
129
|
+
chart.dispatch = scatter.dispatch;
|
130
|
+
|
131
|
+
d3.rebind(chart, scatter, 'interactive', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius');
|
132
|
+
|
133
|
+
chart.margin = function(_) {
|
134
|
+
if (!arguments.length) return margin;
|
135
|
+
margin = _;
|
136
|
+
return chart;
|
137
|
+
};
|
138
|
+
|
139
|
+
chart.width = function(_) {
|
140
|
+
if (!arguments.length) return width;
|
141
|
+
width = _;
|
142
|
+
return chart;
|
143
|
+
};
|
144
|
+
|
145
|
+
chart.height = function(_) {
|
146
|
+
if (!arguments.length) return height;
|
147
|
+
height = _;
|
148
|
+
return chart;
|
149
|
+
};
|
150
|
+
|
151
|
+
chart.x = function(_) {
|
152
|
+
if (!arguments.length) return getX;
|
153
|
+
getX = _;
|
154
|
+
scatter.x(_);
|
155
|
+
return chart;
|
156
|
+
};
|
157
|
+
|
158
|
+
chart.y = function(_) {
|
159
|
+
if (!arguments.length) return getY;
|
160
|
+
getY = _;
|
161
|
+
scatter.y(_);
|
162
|
+
return chart;
|
163
|
+
};
|
164
|
+
|
165
|
+
chart.clipEdge = function(_) {
|
166
|
+
if (!arguments.length) return clipEdge;
|
167
|
+
clipEdge = _;
|
168
|
+
return chart;
|
169
|
+
};
|
170
|
+
|
171
|
+
chart.color = function(_) {
|
172
|
+
if (!arguments.length) return color;
|
173
|
+
color = nv.utils.getColor(_);
|
174
|
+
scatter.color(color);
|
175
|
+
return chart;
|
176
|
+
};
|
177
|
+
|
178
|
+
chart.id = function(_) {
|
179
|
+
if (!arguments.length) return id;
|
180
|
+
id = _;
|
181
|
+
return chart;
|
182
|
+
};
|
183
|
+
|
184
|
+
chart.interpolate = function(_) {
|
185
|
+
if (!arguments.length) return interpolate;
|
186
|
+
interpolate = _;
|
187
|
+
return chart;
|
188
|
+
};
|
189
|
+
|
190
|
+
chart.defined = function(_) {
|
191
|
+
if (!arguments.length) return defined;
|
192
|
+
defined = _;
|
193
|
+
return chart;
|
194
|
+
};
|
195
|
+
|
196
|
+
return chart;
|
197
|
+
}
|
@@ -0,0 +1,319 @@
|
|
1
|
+
|
2
|
+
nv.models.lineWithFisheyeChart = function() {
|
3
|
+
var margin = {top: 30, right: 20, bottom: 50, left: 60},
|
4
|
+
color = nv.utils.defaultColor(),
|
5
|
+
width = null,
|
6
|
+
height = null,
|
7
|
+
showLegend = true,
|
8
|
+
showControls = true,
|
9
|
+
fisheye = 0,
|
10
|
+
pauseFisheye = false,
|
11
|
+
tooltips = true,
|
12
|
+
tooltip = function(key, x, y, e, graph) {
|
13
|
+
return '<h3>' + key + '</h3>' +
|
14
|
+
'<p>' + y + ' at ' + x + '</p>'
|
15
|
+
},
|
16
|
+
noData = "No Data Available."
|
17
|
+
;
|
18
|
+
|
19
|
+
|
20
|
+
var x = d3.fisheye.scale(d3.scale.linear).distortion(0);
|
21
|
+
|
22
|
+
var lines = nv.models.lineWithFisheye().xScale(x),
|
23
|
+
//x = lines.xScale(),
|
24
|
+
y = lines.yScale(),
|
25
|
+
xAxis = nv.models.axis().scale(x).orient('bottom').tickPadding(5),
|
26
|
+
yAxis = nv.models.axis().scale(y).orient('left'),
|
27
|
+
legend = nv.models.legend().height(30),
|
28
|
+
controls = nv.models.legend().height(30),
|
29
|
+
dispatch = d3.dispatch('tooltipShow', 'tooltipHide');
|
30
|
+
|
31
|
+
|
32
|
+
var showTooltip = function(e, offsetElement) {
|
33
|
+
var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
|
34
|
+
top = e.pos[1] + ( offsetElement.offsetTop || 0),
|
35
|
+
x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)),
|
36
|
+
y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)),
|
37
|
+
content = tooltip(e.series.key, x, y, e, chart);
|
38
|
+
|
39
|
+
nv.tooltip.show([left, top], content, null, null, offsetElement);
|
40
|
+
};
|
41
|
+
|
42
|
+
|
43
|
+
var controlsData = [
|
44
|
+
{ key: 'Magnify', disabled: true }
|
45
|
+
];
|
46
|
+
|
47
|
+
|
48
|
+
function chart(selection) {
|
49
|
+
selection.each(function(data) {
|
50
|
+
var container = d3.select(this),
|
51
|
+
that = this;
|
52
|
+
|
53
|
+
var availableWidth = (width || parseInt(container.style('width')) || 960)
|
54
|
+
- margin.left - margin.right,
|
55
|
+
availableHeight = (height || parseInt(container.style('height')) || 400)
|
56
|
+
- margin.top - margin.bottom;
|
57
|
+
|
58
|
+
chart.update = function() { container.transition().call(chart) };
|
59
|
+
chart.container = this; // I need a reference to the container in order to have outside code check if the chart is visible or not
|
60
|
+
//------------------------------------------------------------
|
61
|
+
// Display No Data message if there's nothing to show.
|
62
|
+
|
63
|
+
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
|
64
|
+
container.append('text')
|
65
|
+
.attr('class', 'nvd3 nv-noData')
|
66
|
+
.attr('x', availableWidth / 2)
|
67
|
+
.attr('y', availableHeight / 2)
|
68
|
+
.attr('dy', '-.7em')
|
69
|
+
.style('text-anchor', 'middle')
|
70
|
+
.text(noData);
|
71
|
+
return chart;
|
72
|
+
} else {
|
73
|
+
container.select('.nv-noData').remove();
|
74
|
+
}
|
75
|
+
|
76
|
+
//------------------------------------------------------------
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
var wrap = container.selectAll('g.nv-wrap.nv-lineChart').data([data]);
|
81
|
+
var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineChart').append('g');
|
82
|
+
|
83
|
+
|
84
|
+
gEnter.append('rect')
|
85
|
+
.attr('class', 'nvd3 nv-background')
|
86
|
+
.attr('width', availableWidth)
|
87
|
+
.attr('height', availableHeight);
|
88
|
+
|
89
|
+
|
90
|
+
gEnter.append('g').attr('class', 'nv-x nv-axis');
|
91
|
+
gEnter.append('g').attr('class', 'nv-y nv-axis');
|
92
|
+
gEnter.append('g').attr('class', 'nv-linesWrap');
|
93
|
+
gEnter.append('g').attr('class', 'nv-legendWrap');
|
94
|
+
gEnter.append('g').attr('class', 'nv-controlsWrap');
|
95
|
+
gEnter.append('g').attr('class', 'nv-controlsWrap');
|
96
|
+
|
97
|
+
|
98
|
+
var g = wrap.select('g');
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
if (showLegend) {
|
104
|
+
legend.width(availableWidth);
|
105
|
+
|
106
|
+
g.select('.nv-legendWrap')
|
107
|
+
.datum(data)
|
108
|
+
.call(legend);
|
109
|
+
|
110
|
+
if ( margin.top != legend.height()) {
|
111
|
+
margin.top = legend.height();
|
112
|
+
availableHeight = (height || parseInt(container.style('height')) || 400)
|
113
|
+
- margin.top - margin.bottom;
|
114
|
+
}
|
115
|
+
|
116
|
+
g.select('.nv-legendWrap')
|
117
|
+
.attr('transform', 'translate(0,' + (-margin.top) +')')
|
118
|
+
}
|
119
|
+
|
120
|
+
if (showControls) {
|
121
|
+
controls.width(180).color(['#444']);
|
122
|
+
g.select('.nv-controlsWrap')
|
123
|
+
.datum(controlsData)
|
124
|
+
.attr('transform', 'translate(0,' + (-margin.top) +')')
|
125
|
+
.call(controls);
|
126
|
+
}
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
lines
|
131
|
+
.width(availableWidth)
|
132
|
+
.height(availableHeight)
|
133
|
+
.color(data.map(function(d,i) {
|
134
|
+
return d.color || color(d, i);
|
135
|
+
}).filter(function(d,i) { return !data[i].disabled }));
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
|
140
|
+
|
141
|
+
|
142
|
+
var linesWrap = g.select('.nv-linesWrap')
|
143
|
+
.datum(data.filter(function(d) { return !d.disabled }))
|
144
|
+
|
145
|
+
d3.transition(linesWrap).call(lines);
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
xAxis
|
150
|
+
//.scale(x)
|
151
|
+
.ticks( availableWidth / 100 )
|
152
|
+
.tickSize(-availableHeight, 0);
|
153
|
+
|
154
|
+
g.select('.nv-x.nv-axis')
|
155
|
+
.attr('transform', 'translate(0,' + y.range()[0] + ')');
|
156
|
+
d3.transition(g.select('.nv-x.nv-axis'))
|
157
|
+
.call(xAxis);
|
158
|
+
|
159
|
+
|
160
|
+
yAxis
|
161
|
+
//.scale(y)
|
162
|
+
.ticks( availableHeight / 36 )
|
163
|
+
.tickSize( -availableWidth, 0);
|
164
|
+
|
165
|
+
d3.transition(g.select('.nv-y.nv-axis'))
|
166
|
+
.call(yAxis);
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
g.select('.nv-background').on('mousemove', updateFisheye);
|
171
|
+
g.select('.nv-background').on('click', function() { pauseFisheye = !pauseFisheye; });
|
172
|
+
//g.select('.point-paths').on('mousemove', updateFisheye);
|
173
|
+
|
174
|
+
|
175
|
+
function updateFisheye() {
|
176
|
+
if (pauseFisheye) {
|
177
|
+
//g.select('.background') .style('pointer-events', 'none');
|
178
|
+
g.select('.nv-point-paths').style('pointer-events', 'all');
|
179
|
+
return false;
|
180
|
+
}
|
181
|
+
|
182
|
+
g.select('.nv-background') .style('pointer-events', 'all');
|
183
|
+
g.select('.nv-point-paths').style('pointer-events', 'none' );
|
184
|
+
|
185
|
+
var mouse = d3.mouse(this);
|
186
|
+
linesWrap.call(lines);
|
187
|
+
g.select('.nv-x.nv-axis').call(xAxis);
|
188
|
+
x.distortion(fisheye).focus(mouse[0]);
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
controls.dispatch.on('legendClick', function(d,i) {
|
193
|
+
d.disabled = !d.disabled;
|
194
|
+
|
195
|
+
fisheye = d.disabled ? 0 : 5;
|
196
|
+
g.select('.nv-background') .style('pointer-events', d.disabled ? 'none' : 'all');
|
197
|
+
g.select('.nv-point-paths').style('pointer-events', d.disabled ? 'all' : 'none' );
|
198
|
+
|
199
|
+
//scatter.interactive(d.disabled);
|
200
|
+
//tooltips = d.disabled;
|
201
|
+
|
202
|
+
if (d.disabled) {
|
203
|
+
x.distortion(fisheye).focus(0);
|
204
|
+
|
205
|
+
linesWrap.call(lines);
|
206
|
+
g.select('.nv-x.nv-axis').call(xAxis);
|
207
|
+
} else {
|
208
|
+
pauseFisheye = false;
|
209
|
+
}
|
210
|
+
|
211
|
+
chart.update();
|
212
|
+
});
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
legend.dispatch.on('legendClick', function(d,i) {
|
217
|
+
d.disabled = !d.disabled;
|
218
|
+
|
219
|
+
if (!data.filter(function(d) { return !d.disabled }).length) {
|
220
|
+
data.map(function(d) {
|
221
|
+
d.disabled = false;
|
222
|
+
wrap.selectAll('.nv-series').classed('disabled', false);
|
223
|
+
return d;
|
224
|
+
});
|
225
|
+
}
|
226
|
+
|
227
|
+
chart.update();
|
228
|
+
});
|
229
|
+
|
230
|
+
/*
|
231
|
+
//
|
232
|
+
legend.dispatch.on('legendMouseover', function(d, i) {
|
233
|
+
d.hover = true;
|
234
|
+
selection.transition().call(chart)
|
235
|
+
});
|
236
|
+
|
237
|
+
legend.dispatch.on('legendMouseout', function(d, i) {
|
238
|
+
d.hover = false;
|
239
|
+
selection.transition().call(chart)
|
240
|
+
});
|
241
|
+
*/
|
242
|
+
|
243
|
+
lines.dispatch.on('elementMouseover.tooltip', function(e) {
|
244
|
+
e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
|
245
|
+
dispatch.tooltipShow(e);
|
246
|
+
});
|
247
|
+
if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, that.parentNode) } ); // TODO: maybe merge with above?
|
248
|
+
|
249
|
+
lines.dispatch.on('elementMouseout.tooltip', function(e) {
|
250
|
+
dispatch.tooltipHide(e);
|
251
|
+
});
|
252
|
+
if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup);
|
253
|
+
|
254
|
+
});
|
255
|
+
|
256
|
+
return chart;
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
chart.dispatch = dispatch;
|
261
|
+
chart.legend = legend;
|
262
|
+
chart.xAxis = xAxis;
|
263
|
+
chart.yAxis = yAxis;
|
264
|
+
|
265
|
+
d3.rebind(chart, lines, 'defined', 'x', 'y', 'size', 'xDomain', 'yDomain', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id', 'interpolate');
|
266
|
+
|
267
|
+
|
268
|
+
chart.margin = function(_) {
|
269
|
+
if (!arguments.length) return margin;
|
270
|
+
margin = _;
|
271
|
+
return chart;
|
272
|
+
};
|
273
|
+
|
274
|
+
chart.width = function(_) {
|
275
|
+
if (!arguments.length) return width;
|
276
|
+
width = _;
|
277
|
+
return chart;
|
278
|
+
};
|
279
|
+
|
280
|
+
chart.height = function(_) {
|
281
|
+
if (!arguments.length) return height;
|
282
|
+
height = _;
|
283
|
+
return chart;
|
284
|
+
};
|
285
|
+
|
286
|
+
chart.color = function(_) {
|
287
|
+
if (!arguments.length) return color;
|
288
|
+
color = nv.utils.getColor(_);
|
289
|
+
legend.color(color);
|
290
|
+
return chart;
|
291
|
+
};
|
292
|
+
|
293
|
+
chart.showLegend = function(_) {
|
294
|
+
if (!arguments.length) return showLegend;
|
295
|
+
showLegend = _;
|
296
|
+
return chart;
|
297
|
+
};
|
298
|
+
|
299
|
+
chart.tooltips = function(_) {
|
300
|
+
if (!arguments.length) return tooltips;
|
301
|
+
tooltips = _;
|
302
|
+
return chart;
|
303
|
+
};
|
304
|
+
|
305
|
+
chart.tooltipContent = function(_) {
|
306
|
+
if (!arguments.length) return tooltip;
|
307
|
+
tooltip = _;
|
308
|
+
return chart;
|
309
|
+
};
|
310
|
+
|
311
|
+
chart.noData = function(_) {
|
312
|
+
if (!arguments.length) return noData;
|
313
|
+
noData = _;
|
314
|
+
return chart;
|
315
|
+
};
|
316
|
+
|
317
|
+
|
318
|
+
return chart;
|
319
|
+
}
|