updated many models for state management

This commit is contained in:
Tyler Wolf 2013-04-04 15:45:26 -04:00
parent 7335631472
commit db144a9290
11 changed files with 345 additions and 35 deletions

169
nv.d3.js
View File

@ -1786,6 +1786,7 @@ nv.models.cumulativeLineChart = function() {
, y //can be accessed via chart.yScale() , y //can be accessed via chart.yScale()
, id = lines.id() , id = lines.id()
, state = { index: 0, rescaleY: rescaleY } , state = { index: 0, rescaleY: rescaleY }
, defaultState = null
, noData = 'No Data Available.' , noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
; ;
@ -1866,6 +1867,17 @@ nv.models.cumulativeLineChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
var indexDrag = d3.behavior.drag() var indexDrag = d3.behavior.drag()
.on('dragstart', dragStart) .on('dragstart', dragStart)
.on('drag', dragMove) .on('drag', dragMove)
@ -2325,6 +2337,12 @@ nv.models.cumulativeLineChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;
@ -3956,6 +3974,7 @@ nv.models.lineChart = function() {
, x , x
, y , y
, state = {} , state = {}
, defaultState = null
, noData = 'No Data Available.' , noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
; ;
@ -4018,6 +4037,16 @@ nv.models.lineChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display noData message if there's nothing to show. // Display noData message if there's nothing to show.
@ -4280,6 +4309,12 @@ nv.models.lineChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;
@ -4321,6 +4356,8 @@ nv.models.linePlusBarChart = function() {
, x , x
, y1 , y1
, y2 , y2
, state = {}
, defaultState = null
, noData = "No Data Available." , noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
; ;
@ -4351,8 +4388,7 @@ nv.models.linePlusBarChart = function() {
// Private Variables // Private Variables
//------------------------------------------------------------ //------------------------------------------------------------
var state = {}, var showTooltip = function(e, offsetElement) {
showTooltip = function(e, offsetElement) {
var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
top = e.pos[1] + ( offsetElement.offsetTop || 0), top = e.pos[1] + ( offsetElement.offsetTop || 0),
x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)),
@ -4383,6 +4419,16 @@ nv.models.linePlusBarChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display No Data message if there's nothing to show. // Display No Data message if there's nothing to show.
@ -4705,6 +4751,12 @@ nv.models.linePlusBarChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;
@ -5722,6 +5774,7 @@ nv.models.multiBarChart = function() {
, x //can be accessed via chart.xScale() , x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale() , y //can be accessed via chart.yScale()
, state = { stacked: false } , state = { stacked: false }
, defaultState = null
, noData = "No Data Available." , noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, controlWidth = function() { return showControls ? 180 : 0 } , controlWidth = function() { return showControls ? 180 : 0 }
@ -5778,7 +5831,16 @@ nv.models.multiBarChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display noData message if there's nothing to show. // Display noData message if there's nothing to show.
@ -6130,6 +6192,12 @@ nv.models.multiBarChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;
@ -6590,6 +6658,7 @@ nv.models.multiBarHorizontalChart = function() {
, x //can be accessed via chart.xScale() , x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale() , y //can be accessed via chart.yScale()
, state = { stacked: stacked } , state = { stacked: stacked }
, defaultState = null
, noData = 'No Data Available.' , noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, controlWidth = function() { return showControls ? 180 : 0 } , controlWidth = function() { return showControls ? 180 : 0 }
@ -6646,6 +6715,16 @@ nv.models.multiBarHorizontalChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display No Data message if there's nothing to show. // Display No Data message if there's nothing to show.
@ -6969,6 +7048,12 @@ nv.models.multiBarHorizontalChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;
@ -8194,6 +8279,7 @@ nv.models.pieChart = function() {
'<p>' + y + '</p>' '<p>' + y + '</p>'
} }
, state = {} , state = {}
, defaultState = null
, noData = "No Data Available." , noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
; ;
@ -8234,6 +8320,17 @@ nv.models.pieChart = function() {
//set state.disabled //set state.disabled
state.disabled = data[0].map(function(d) { return !!d.disabled }); state.disabled = data[0].map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display No Data message if there's nothing to show. // Display No Data message if there's nothing to show.
@ -8446,6 +8543,12 @@ nv.models.pieChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;
@ -9117,6 +9220,8 @@ nv.models.scatterChart = function() {
, tooltipY = function(key, x, y) { return '<strong>' + y + '</strong>' } , tooltipY = function(key, x, y) { return '<strong>' + y + '</strong>' }
//, tooltip = function(key, x, y) { return '<h3>' + key + '</h3>' } //, tooltip = function(key, x, y) { return '<h3>' + key + '</h3>' }
, tooltip = null , tooltip = null
, state = {}
, defaultState = null
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, noData = "No Data Available." , noData = "No Data Available."
; ;
@ -9147,8 +9252,7 @@ nv.models.scatterChart = function() {
// Private Variables // Private Variables
//------------------------------------------------------------ //------------------------------------------------------------
var state = {}, var x0, y0;
x0, y0;
var showTooltip = function(e, offsetElement) { var showTooltip = function(e, offsetElement) {
//TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?)
@ -9193,6 +9297,16 @@ nv.models.scatterChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display noData message if there's nothing to show. // Display noData message if there's nothing to show.
@ -9649,6 +9763,12 @@ nv.models.scatterChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;
@ -9694,6 +9814,8 @@ nv.models.scatterPlusLineChart = function() {
, tooltip = function(key, x, y, date) { return '<h3>' + key + '</h3>' , tooltip = function(key, x, y, date) { return '<h3>' + key + '</h3>'
+ '<p>' + date + '</p>' } + '<p>' + date + '</p>' }
//, tooltip = null //, tooltip = null
, state = {}
, defaultState = null
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, noData = "No Data Available." , noData = "No Data Available."
; ;
@ -9724,8 +9846,7 @@ nv.models.scatterPlusLineChart = function() {
// Private Variables // Private Variables
//------------------------------------------------------------ //------------------------------------------------------------
var state = {}, var x0, y0;
x0, y0;
var showTooltip = function(e, offsetElement) { var showTooltip = function(e, offsetElement) {
//TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?)
@ -9770,6 +9891,16 @@ nv.models.scatterPlusLineChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display noData message if there's nothing to show. // Display noData message if there's nothing to show.
@ -10229,6 +10360,12 @@ nv.models.scatterPlusLineChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;
@ -11075,6 +11212,7 @@ nv.models.stackedAreaChart = function() {
, y //can be accessed via chart.yScale() , y //can be accessed via chart.yScale()
, yAxisTickFormat = d3.format(',.2f') , yAxisTickFormat = d3.format(',.2f')
, state = { style: stacked.style() } , state = { style: stacked.style() }
, defaultState = null
, noData = 'No Data Available.' , noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, controlWidth = 250 , controlWidth = 250
@ -11130,6 +11268,16 @@ nv.models.stackedAreaChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display No Data message if there's nothing to show. // Display No Data message if there's nothing to show.
@ -11489,6 +11637,12 @@ nv.models.stackedAreaChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;
@ -11496,6 +11650,7 @@ nv.models.stackedAreaChart = function() {
}; };
yAxis.setTickFormat = yAxis.tickFormat; yAxis.setTickFormat = yAxis.tickFormat;
yAxis.tickFormat = function(_) { yAxis.tickFormat = function(_) {
if (!arguments.length) return yAxisTickFormat; if (!arguments.length) return yAxisTickFormat;
yAxisTickFormat = _; yAxisTickFormat = _;

10
nv.d3.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -28,6 +28,7 @@ nv.models.cumulativeLineChart = function() {
, y //can be accessed via chart.yScale() , y //can be accessed via chart.yScale()
, id = lines.id() , id = lines.id()
, state = { index: 0, rescaleY: rescaleY } , state = { index: 0, rescaleY: rescaleY }
, defaultState = null
, noData = 'No Data Available.' , noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
; ;
@ -108,6 +109,17 @@ nv.models.cumulativeLineChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
var indexDrag = d3.behavior.drag() var indexDrag = d3.behavior.drag()
.on('dragstart', dragStart) .on('dragstart', dragStart)
.on('drag', dragMove) .on('drag', dragMove)
@ -567,6 +579,12 @@ nv.models.cumulativeLineChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;

View File

@ -25,6 +25,7 @@ nv.models.lineChart = function() {
, x , x
, y , y
, state = {} , state = {}
, defaultState = null
, noData = 'No Data Available.' , noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
; ;
@ -87,6 +88,16 @@ nv.models.lineChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display noData message if there's nothing to show. // Display noData message if there's nothing to show.
@ -349,6 +360,12 @@ nv.models.lineChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;

View File

@ -28,6 +28,8 @@ nv.models.linePlusBarChart = function() {
, x , x
, y1 , y1
, y2 , y2
, state = {}
, defaultState = null
, noData = "No Data Available." , noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
; ;
@ -58,8 +60,7 @@ nv.models.linePlusBarChart = function() {
// Private Variables // Private Variables
//------------------------------------------------------------ //------------------------------------------------------------
var state = {}, var showTooltip = function(e, offsetElement) {
showTooltip = function(e, offsetElement) {
var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
top = e.pos[1] + ( offsetElement.offsetTop || 0), top = e.pos[1] + ( offsetElement.offsetTop || 0),
x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)),
@ -90,6 +91,16 @@ nv.models.linePlusBarChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display No Data message if there's nothing to show. // Display No Data message if there's nothing to show.
@ -412,6 +423,12 @@ nv.models.linePlusBarChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;

View File

@ -28,6 +28,7 @@ nv.models.multiBarChart = function() {
, x //can be accessed via chart.xScale() , x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale() , y //can be accessed via chart.yScale()
, state = { stacked: false } , state = { stacked: false }
, defaultState = null
, noData = "No Data Available." , noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, controlWidth = function() { return showControls ? 180 : 0 } , controlWidth = function() { return showControls ? 180 : 0 }
@ -84,7 +85,16 @@ nv.models.multiBarChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display noData message if there's nothing to show. // Display noData message if there's nothing to show.
@ -436,6 +446,12 @@ nv.models.multiBarChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;

View File

@ -27,6 +27,7 @@ nv.models.multiBarHorizontalChart = function() {
, x //can be accessed via chart.xScale() , x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale() , y //can be accessed via chart.yScale()
, state = { stacked: stacked } , state = { stacked: stacked }
, defaultState = null
, noData = 'No Data Available.' , noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, controlWidth = function() { return showControls ? 180 : 0 } , controlWidth = function() { return showControls ? 180 : 0 }
@ -83,6 +84,16 @@ nv.models.multiBarHorizontalChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display No Data message if there's nothing to show. // Display No Data message if there's nothing to show.
@ -406,6 +417,12 @@ nv.models.multiBarHorizontalChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;

View File

@ -19,6 +19,7 @@ nv.models.pieChart = function() {
'<p>' + y + '</p>' '<p>' + y + '</p>'
} }
, state = {} , state = {}
, defaultState = null
, noData = "No Data Available." , noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
; ;
@ -59,6 +60,17 @@ nv.models.pieChart = function() {
//set state.disabled //set state.disabled
state.disabled = data[0].map(function(d) { return !!d.disabled }); state.disabled = data[0].map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display No Data message if there's nothing to show. // Display No Data message if there's nothing to show.
@ -271,6 +283,12 @@ nv.models.pieChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;

View File

@ -33,6 +33,8 @@ nv.models.scatterChart = function() {
, tooltipY = function(key, x, y) { return '<strong>' + y + '</strong>' } , tooltipY = function(key, x, y) { return '<strong>' + y + '</strong>' }
//, tooltip = function(key, x, y) { return '<h3>' + key + '</h3>' } //, tooltip = function(key, x, y) { return '<h3>' + key + '</h3>' }
, tooltip = null , tooltip = null
, state = {}
, defaultState = null
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, noData = "No Data Available." , noData = "No Data Available."
; ;
@ -63,8 +65,7 @@ nv.models.scatterChart = function() {
// Private Variables // Private Variables
//------------------------------------------------------------ //------------------------------------------------------------
var state = {}, var x0, y0;
x0, y0;
var showTooltip = function(e, offsetElement) { var showTooltip = function(e, offsetElement) {
//TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?)
@ -109,6 +110,16 @@ nv.models.scatterChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display noData message if there's nothing to show. // Display noData message if there's nothing to show.
@ -565,6 +576,12 @@ nv.models.scatterChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;

View File

@ -32,6 +32,8 @@ nv.models.scatterPlusLineChart = function() {
, tooltip = function(key, x, y, date) { return '<h3>' + key + '</h3>' , tooltip = function(key, x, y, date) { return '<h3>' + key + '</h3>'
+ '<p>' + date + '</p>' } + '<p>' + date + '</p>' }
//, tooltip = null //, tooltip = null
, state = {}
, defaultState = null
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, noData = "No Data Available." , noData = "No Data Available."
; ;
@ -62,8 +64,7 @@ nv.models.scatterPlusLineChart = function() {
// Private Variables // Private Variables
//------------------------------------------------------------ //------------------------------------------------------------
var state = {}, var x0, y0;
x0, y0;
var showTooltip = function(e, offsetElement) { var showTooltip = function(e, offsetElement) {
//TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?)
@ -108,6 +109,16 @@ nv.models.scatterPlusLineChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display noData message if there's nothing to show. // Display noData message if there's nothing to show.
@ -567,6 +578,12 @@ nv.models.scatterPlusLineChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;

View File

@ -27,6 +27,7 @@ nv.models.stackedAreaChart = function() {
, y //can be accessed via chart.yScale() , y //can be accessed via chart.yScale()
, yAxisTickFormat = d3.format(',.2f') , yAxisTickFormat = d3.format(',.2f')
, state = { style: stacked.style() } , state = { style: stacked.style() }
, defaultState = null
, noData = 'No Data Available.' , noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, controlWidth = 250 , controlWidth = 250
@ -82,6 +83,16 @@ nv.models.stackedAreaChart = function() {
//set state.disabled //set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled }); state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
//------------------------------------------------------------ //------------------------------------------------------------
// Display No Data message if there's nothing to show. // Display No Data message if there's nothing to show.
@ -441,6 +452,12 @@ nv.models.stackedAreaChart = function() {
return chart; return chart;
}; };
chart.defaultState = function(_) {
if (!arguments.length) return defaultState;
defaultState = _;
return chart;
};
chart.noData = function(_) { chart.noData = function(_) {
if (!arguments.length) return noData; if (!arguments.length) return noData;
noData = _; noData = _;
@ -448,6 +465,7 @@ nv.models.stackedAreaChart = function() {
}; };
yAxis.setTickFormat = yAxis.tickFormat; yAxis.setTickFormat = yAxis.tickFormat;
yAxis.tickFormat = function(_) { yAxis.tickFormat = function(_) {
if (!arguments.length) return yAxisTickFormat; if (!arguments.length) return yAxisTickFormat;
yAxisTickFormat = _; yAxisTickFormat = _;