Added changeSatte functionality to update chart from a state object
This commit is contained in:
parent
94629ff02e
commit
64a066ccdf
@ -49,11 +49,12 @@ svg {
|
||||
|
||||
|
||||
// Wrapping in nv.addGraph allows for '0 timeout render', stors rendered charts in nv.graphs, and may do more in the future... it's NOT required
|
||||
var chart;
|
||||
nv.addGraph(function() {
|
||||
var chart = nv.models.cumulativeLineChart()
|
||||
.x(function(d) { return d[0] })
|
||||
.y(function(d) { return d[1]/100 })
|
||||
.color(d3.scale.category10().range());
|
||||
chart = nv.models.cumulativeLineChart()
|
||||
.x(function(d) { return d[0] })
|
||||
.y(function(d) { return d[1]/100 })
|
||||
.color(d3.scale.category10().range());
|
||||
|
||||
chart.xAxis
|
||||
.tickFormat(function(d) {
|
||||
|
35
nv.d3.js
35
nv.d3.js
@ -1787,7 +1787,7 @@ nv.models.cumulativeLineChart = function() {
|
||||
, id = lines.id()
|
||||
, state = { index: 0, rescaleY: rescaleY }
|
||||
, noData = 'No Data Available.'
|
||||
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange')
|
||||
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
|
||||
;
|
||||
|
||||
xAxis
|
||||
@ -2188,6 +2188,39 @@ nv.models.cumulativeLineChart = function() {
|
||||
if (tooltips) showTooltip(e, that.parentNode);
|
||||
});
|
||||
|
||||
|
||||
// Update chart from a state object passed to event handler
|
||||
dispatch.on('changeState', function(e) {
|
||||
|
||||
if (typeof e.disabled !== 'undefined') {
|
||||
data.forEach(function(series,i) {
|
||||
series.disabled = e.disabled[i];
|
||||
});
|
||||
|
||||
state.disabled = e.disabled;
|
||||
}
|
||||
|
||||
|
||||
if (typeof e.index !== 'undefined') {
|
||||
index.i = e.index;
|
||||
index.x = dx(index.i);
|
||||
|
||||
// update state and send stateChange with new index
|
||||
state.index = e.index;
|
||||
dispatch.stateChange(state);
|
||||
|
||||
indexLine
|
||||
.data([index]);
|
||||
}
|
||||
|
||||
|
||||
if (typeof e.rescaleY !== 'undefined') {
|
||||
rescaleY = e.rescaleY;
|
||||
}
|
||||
|
||||
selection.call(chart);
|
||||
});
|
||||
|
||||
//============================================================
|
||||
|
||||
});
|
||||
|
10
nv.d3.min.js
vendored
10
nv.d3.min.js
vendored
File diff suppressed because one or more lines are too long
@ -29,7 +29,7 @@ nv.models.cumulativeLineChart = function() {
|
||||
, id = lines.id()
|
||||
, state = { index: 0, rescaleY: rescaleY }
|
||||
, noData = 'No Data Available.'
|
||||
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange')
|
||||
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
|
||||
;
|
||||
|
||||
xAxis
|
||||
@ -430,6 +430,39 @@ nv.models.cumulativeLineChart = function() {
|
||||
if (tooltips) showTooltip(e, that.parentNode);
|
||||
});
|
||||
|
||||
|
||||
// Update chart from a state object passed to event handler
|
||||
dispatch.on('changeState', function(e) {
|
||||
|
||||
if (typeof e.disabled !== 'undefined') {
|
||||
data.forEach(function(series,i) {
|
||||
series.disabled = e.disabled[i];
|
||||
});
|
||||
|
||||
state.disabled = e.disabled;
|
||||
}
|
||||
|
||||
|
||||
if (typeof e.index !== 'undefined') {
|
||||
index.i = e.index;
|
||||
index.x = dx(index.i);
|
||||
|
||||
// update state and send stateChange with new index
|
||||
state.index = e.index;
|
||||
dispatch.stateChange(state);
|
||||
|
||||
indexLine
|
||||
.data([index]);
|
||||
}
|
||||
|
||||
|
||||
if (typeof e.rescaleY !== 'undefined') {
|
||||
rescaleY = e.rescaleY;
|
||||
}
|
||||
|
||||
selection.call(chart);
|
||||
});
|
||||
|
||||
//============================================================
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user