Merging in upstream changes

master-patched
Lee Gillentine 12 years ago
commit 2ac200ead0

@ -21,7 +21,7 @@ Minifying your fork:
The Makefile requires [UglifyJS](https://github.com/mishoo/UglifyJS).
The easist way to install is to install via npm. Run `npm install
The easiest way to install is to install via npm. Run `npm install
uglify-js` from your home directory, then add the output from `npm bin`
into your path so that you have access to `uglifyjs` from the command
line (remember to restart your terminal window when adding to the path.)

@ -1,6 +0,0 @@
#!/bin/bash
COMPRESSOR=`which yui-compressor`
cat src/intro.js src/core.js src/tooltip.js src/utils.js src/models/*.js src/outro.js > nv.d3.js
if [ -e $COMPRESSOR ]; then
$COMPRESSOR --type js -o nv.d3.min.js nv.d3.js
fi

@ -49,11 +49,14 @@ 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())
.clipVoronoi(false);
chart.xAxis
.tickFormat(function(d) {
@ -64,6 +67,7 @@ nv.addGraph(function() {
.tickFormat(d3.format(',.1%'));
d3.select('#chart1 svg')
// .datum(cumulativeTestData())
.datum(cumulativeTestData())
//.transition().duration(500)
.call(chart);
@ -72,10 +76,25 @@ nv.addGraph(function() {
nv.utils.windowResize(chart.update);
//nv.utils.windowResize(function() { d3.select('#chart1 svg').call(chart) });
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});
function flatTestData() {
return [
{
key: "Snakes",
values: [0,1,2,3,4,5,6,7,8,9].map(function(d) {
var currentDate = new Date();
currentDate.setDate(currentDate.getDate() + d);
return [currentDate, 0]
})
}
];
}
function cumulativeTestData() {

@ -51,8 +51,10 @@ svg {
// Wrapping in nv.addGraph allows for '0 timeout render', stores 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.lineChart();
chart = nv.models.lineChart();
chart
.x(function(d,i) { return i })
@ -75,6 +77,8 @@ nv.addGraph(function() {
nv.utils.windowResize(chart.update);
//nv.utils.windowResize(function() { d3.select('#chart1 svg').call(chart) });
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});

@ -53,14 +53,14 @@ var testdata = [
},
{
"key" : "Price" ,
"values" : [ [ 1136005200000 , 71.89] , [ 1138683600000 , 75.51] , [ 1141102800000 , 68.49] , [ 1143781200000 , 62.72] , [ 1146369600000 , 70.39] , [ 1149048000000 , 59.77] , [ 1151640000000 , 57.27] , [ 1154318400000 , 67.96] , [ 1156996800000 , 67.85] , [ 1159588800000 , 76.98] , [ 1162270800000 , 81.08] , [ 1164862800000 , 91.66] , [ 1167541200000 , 84.84] , [ 1170219600000 , 85.73] , [ 1172638800000 , 84.61] , [ 1175313600000 , 92.91] , [ 1177905600000 , 99.8] , [ 1180584000000 , 121.191] , [ 1183176000000 , 122.04] , [ 1185854400000 , 131.76] , [ 1188532800000 , 138.48] , [ 1191124800000 , 153.47] , [ 1193803200000 , 189.95] , [ 1196398800000 , 182.22] , [ 1199077200000 , 198.08] , [ 1201755600000 , 135.36] , [ 1204261200000 , 125.02] , [ 1206936000000 , 143.5] , [ 1209528000000 , 173.95] , [ 1212206400000 , 188.75] , [ 1214798400000 , 167.44] , [ 1217476800000 , 158.95] , [ 1220155200000 , 169.53] , [ 1222747200000 , 113.66] , [ 1225425600000 , 107.59] , [ 1228021200000 , 92.67] , [ 1230699600000 , 85.35] , [ 1233378000000 , 90.13] , [ 1235797200000 , 89.31] , [ 1238472000000 , 105.12] , [ 1241064000000 , 125.83] , [ 1243742400000 , 135.81] , [ 1246334400000 , 142.43] , [ 1249012800000 , 163.39] , [ 1251691200000 , 168.21] , [ 1254283200000 , 185.35] , [ 1256961600000 , 188.5] , [ 1259557200000 , 199.91] , [ 1262235600000 , 210.732] , [ 1264914000000 , 192.063] , [ 1267333200000 , 204.62] , [ 1270008000000 , 235.0] , [ 1272600000000 , 261.09] , [ 1275278400000 , 256.88] , [ 1277870400000 , 251.53] , [ 1280548800000 , 257.25] , [ 1283227200000 , 243.1] , [ 1285819200000 , 283.75] , [ 1288497600000 , 300.98] , [ 1291093200000 , 311.15] , [ 1293771600000 , 322.56] , [ 1296450000000 , 339.32] , [ 1298869200000 , 353.21] , [ 1301544000000 , 348.5075] , [ 1304136000000 , 350.13] , [ 1306814400000 , 347.83] , [ 1309406400000 , 335.67] , [ 1312084800000 , 390.48] , [ 1314763200000 , 384.83] , [ 1317355200000 , 381.32] , [ 1320033600000 , 404.78] , [ 1322629200000 , 382.2] , [ 1325307600000 , 405.0] , [ 1327986000000 , 456.48] , [ 1330491600000 , 542.44] , [ 1333166400000 , 599.55] , [ 1335758400000 , 583.98]]
"values" : [ [ 1136005200000 , 71.89] , [ 1138683600000 , 75.51] , [ 1141102800000 , 68.49] , [ 1143781200000 , 62.72] , [ 1146369600000 , 70.39] , [ 1149048000000 , 59.77] , [ 1151640000000 , 57.27] , [ 1154318400000 , 67.96] , [ 1156996800000 , 67.85] , [ 1159588800000 , 76.98] , [ 1162270800000 , 81.08] , [ 1164862800000 , 91.66] , [ 1167541200000 , 84.84] , [ 1170219600000 , 85.73] , [ 1172638800000 , 84.61] , [ 1175313600000 , 92.91] , [ 1177905600000 , 99.8] , [ 1180584000000 , 121.191] , [ 1183176000000 , 122.04] , [ 1185854400000 , 131.76] , [ 1188532800000 , 138.48] , [ 1191124800000 , 153.47] , [ 1193803200000 , 189.95] , [ 1196398800000 , 182.22] , [ 1199077200000 , 198.08] , [ 1201755600000 , 135.36] , [ 1204261200000 , 125.02] , [ 1206936000000 , 143.5] , [ 1209528000000 , 173.95] , [ 1212206400000 , 188.75] , [ 1214798400000 , 167.44] , [ 1217476800000 , 158.95] , [ 1220155200000 , 169.53] , [ 1222747200000 , 113.66] , [ 1225425600000 , 107.59] , [ 1228021200000 , 92.67] , [ 1230699600000 , 85.35] , [ 1233378000000 , 90.13] , [ 1235797200000 , 89.31] , [ 1238472000000 , 105.12] , [ 1241064000000 , 125.83] , [ 1243742400000 , 135.81] , [ 1246334400000 , 142.43] , [ 1249012800000 , 163.39] , [ 1251691200000 , 168.21] , [ 1254283200000 , 185.35] , [ 1256961600000 , 188.5] , [ 1259557200000 , 199.91] , [ 1262235600000 , 210.732] , [ 1264914000000 , 192.063] , [ 1267333200000 , 204.62] , [ 1270008000000 , 235.0] , [ 1272600000000 , 261.09] , [ 1275278400000 , 256.88] , [ 1277870400000 , 251.53] , [ 1280548800000 , 257.25] , [ 1283227200000 , 243.1] , [ 1285819200000 , 283.75] , [ 1288497600000 , 300.98] , [ 1291093200000 , 311.15] , [ 1293771600000 , 322.56] , [ 1296450000000 , 339.32] , [ 1298869200000 , 353.21] , [ 1301544000000 , 348.5075] , [ 1304136000000 , 350.13] , [ 1306814400000 , 347.83] , [ 1309406400000 , 335.67] , [ 1312084800000 , 390.48] , [ 1314763200000 , 384.83] , [ 1317355200000 , 381.32] , [ 1320033600000 , 404.78] , [ 1322629200000 , 382.2] , [ 1325307600000 , 405.0] , [ 1327986000000 , 456.48] , [ 1330491600000 , 542.44] , [ 1333166400000 , 599.55] , [ 1335758400000 , 583.98] ]
}
].map(function(series) {
series.values = series.values.map(function(d) { return {x: d[0], y: d[1] } });
return series;
});
/*
//For testing single data point
var testdata = [
{
@ -76,11 +76,12 @@ var testdata = [
series.values = series.values.map(function(d) { return {x: d[0], y: d[1] } });
return series;
});
*/
var chart;
nv.addGraph(function() {
var chart = nv.models.linePlusBarChart()
chart = nv.models.linePlusBarChart()
.margin({top: 30, right: 60, bottom: 50, left: 70})
.x(function(d,i) { return i })
.color(d3.scale.category10().range());
@ -105,6 +106,8 @@ nv.addGraph(function() {
nv.utils.windowResize(chart.update);
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});

@ -52,9 +52,9 @@ var test_data = stream_layers(3,10+Math.random()*100,.1).map(function(data, i) {
});
var chart;
nv.addGraph(function() {
var chart = nv.models.multiBarChart();
chart = nv.models.multiBarChart();
chart.xAxis
.showMaxMin(true)
@ -69,6 +69,8 @@ nv.addGraph(function() {
nv.utils.windowResize(chart.update);
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});

@ -136,9 +136,9 @@ long_short_data = [
];
var chart;
nv.addGraph(function() {
var chart = nv.models.multiBarHorizontalChart()
chart = nv.models.multiBarHorizontalChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value })
.margin({top: 30, right: 20, bottom: 50, left: 175})
@ -156,6 +156,8 @@ nv.addGraph(function() {
nv.utils.windowResize(chart.update);
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});

@ -59,12 +59,12 @@ text {
var chart;
nv.addGraph(function() {
var width = 500,
height = 500;
var chart = nv.models.pieChart()
chart = nv.models.pieChart()
.x(function(d) { return d.key })
.y(function(d) { return d.y })
//.showLabels(false)
@ -80,6 +80,8 @@ nv.addGraph(function() {
.attr('height', height)
.call(chart);
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});

@ -61,8 +61,9 @@ div {
//Format A
var chart;
nv.addGraph(function() {
var chart = nv.models.scatterChart()
chart = nv.models.scatterChart()
.showDistX(true)
.showDistY(true)
//.height(500)
@ -79,6 +80,8 @@ nv.addGraph(function() {
nv.utils.windowResize(chart.update);
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});

@ -61,8 +61,9 @@ div {
//Format A
var chart;
nv.addGraph(function() {
var chart = nv.models.scatterPlusLineChart()
chart = nv.models.scatterPlusLineChart()
.showDistX(true)
.showDistY(true)
//.height(500)
@ -78,6 +79,8 @@ nv.addGraph(function() {
nv.utils.windowResize(chart.update);
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});

@ -190,8 +190,9 @@ var histcatexpshort = [
var colors = d3.scale.category20();
keyColor = function(d, i) {return colors(d.key)};
var chart;
nv.addGraph(function() {
var chart = nv.models.stackedAreaChart()
chart = nv.models.stackedAreaChart()
.x(function(d) { return d[0] })
.y(function(d) { return d[1] })
.color(keyColor)
@ -211,6 +212,8 @@ nv.addGraph(function() {
nv.utils.windowResize(chart.update);
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});

@ -119,7 +119,7 @@ d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) {
/*****
* A no frills tooltip implementation.
* A no-frills tooltip implementation.
*****/
@ -288,7 +288,7 @@ nv.utils.windowResize = function(fun){
// Backwards compatible way to implement more d3-like coloring of graphs.
// If passed an array, wrap it in a function which implements the old default
// behaviour
// behavior
nv.utils.getColor = function(color) {
if (!arguments.length) return nv.utils.defaultColor(); //if you pass in nothing, get default colors back
@ -296,7 +296,7 @@ nv.utils.getColor = function(color) {
return function(d, i) { return d.color || color[i % color.length]; };
else
return color;
//can't really help it if someone passes rubish as color
//can't really help it if someone passes rubbish as color
}
// Default color chooser uses the index of an object as before.
@ -1785,8 +1785,9 @@ nv.models.cumulativeLineChart = function() {
, x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale()
, id = lines.id()
, state = { index: 0, rescaleY: rescaleY }
, noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
xAxis
@ -1884,6 +1885,10 @@ nv.models.cumulativeLineChart = function() {
function dragEnd(d,i) {
d3.select(chart.container)
.style('cursor', 'auto');
// update state and send stateChange with new index
state.index = index.i;
dispatch.stateChange(state);
}
@ -2117,12 +2122,22 @@ nv.models.cumulativeLineChart = function() {
.on('click', function() {
index.x = d3.mouse(this)[0];
index.i = Math.round(dx.invert(index.x));
// update state and send stateChange with new index
state.index = index.i;
dispatch.stateChange(state);
updateZero();
});
lines.dispatch.on('elementClick', function(e) {
index.i = e.pointIndex;
index.x = dx(index.i);
// update state and send stateChange with new index
state.index = index.i;
dispatch.stateChange(state);
updateZero();
});
@ -2130,6 +2145,9 @@ nv.models.cumulativeLineChart = function() {
d.disabled = !d.disabled;
rescaleY = !d.disabled;
state.rescaleY = rescaleY;
dispatch.stateChange(state);
//selection.transition().call(chart);
selection.call(chart);
});
@ -2146,6 +2164,9 @@ nv.models.cumulativeLineChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
//selection.transition().call(chart);
selection.call(chart);
});
@ -2167,6 +2188,37 @@ 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);
state.index = e.index;
indexLine
.data([index]);
}
if (typeof e.rescaleY !== 'undefined') {
rescaleY = e.rescaleY;
}
selection.call(chart);
});
//============================================================
});
@ -2236,6 +2288,12 @@ nv.models.cumulativeLineChart = function() {
return chart;
};
chart.rescaleY = function(_) {
if (!arguments.length) return rescaleY;
rescaleY = _
return rescaleY;
};
chart.showControls = function(_) {
if (!arguments.length) return showControls;
showControls = _;
@ -2260,6 +2318,12 @@ nv.models.cumulativeLineChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
@ -2653,7 +2717,7 @@ nv.models.discreteBarChart = function() {
, x
, y
, noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'beforeUpdate')
;
xAxis
@ -2698,7 +2762,7 @@ nv.models.discreteBarChart = function() {
- margin.top - margin.bottom;
chart.update = function() { selection.transition().call(chart); };
chart.update = function() { dispatch.beforeUpdate(); selection.transition().call(chart); };
chart.container = this;
@ -3883,8 +3947,9 @@ nv.models.lineChart = function() {
}
, x
, y
, state = {}
, noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
xAxis
@ -4075,6 +4140,9 @@ nv.models.lineChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -4094,6 +4162,20 @@ nv.models.lineChart = function() {
if (tooltips) showTooltip(e, that.parentNode);
});
dispatch.on('changeState', function(e) {
if (typeof e.disabled !== 'undefined') {
data.forEach(function(series,i) {
series.disabled = e.disabled[i];
});
state.disabled = e.disabled;
}
selection.call(chart);
});
//============================================================
});
@ -4181,6 +4263,12 @@ nv.models.lineChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
@ -4223,7 +4311,7 @@ nv.models.linePlusBarChart = function() {
, y1
, y2
, noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
bars
@ -4252,15 +4340,17 @@ nv.models.linePlusBarChart = function() {
// Private Variables
//------------------------------------------------------------
var showTooltip = function(e, offsetElement) {
var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
top = e.pos[1] + ( offsetElement.offsetTop || 0),
x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)),
y = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)),
content = tooltip(e.series.key, x, y, e, chart);
var state = {},
showTooltip = function(e, offsetElement) {
var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
top = e.pos[1] + ( offsetElement.offsetTop || 0),
x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)),
y = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)),
content = tooltip(e.series.key, x, y, e, chart);
nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement);
};
nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement);
}
;
//------------------------------------------------------------
@ -4311,14 +4401,13 @@ nv.models.linePlusBarChart = function() {
var dataLines = data.filter(function(d) { return !d.bar }); // removed the !d.disabled clause here to fix Issue #240
//x = xAxis.scale();
x = dataLines.filter(function(d) { return !d.disabled; }).length ? lines.xScale() : bars.xScale();
x = dataLines.filter(function(d) { return !d.disabled; }).length && dataLines.filter(function(d) { return !d.disabled; })[0].values.length ? lines.xScale() : bars.xScale();
//x = dataLines.filter(function(d) { return !d.disabled; }).length ? lines.xScale() : bars.xScale(); //old code before change above
y1 = bars.yScale();
y2 = lines.yScale();
//------------------------------------------------------------
//------------------------------------------------------------
// Setup containers and skeleton of chart
@ -4454,6 +4543,9 @@ nv.models.linePlusBarChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -4461,6 +4553,21 @@ nv.models.linePlusBarChart = 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;
}
selection.call(chart);
});
//============================================================
@ -4578,6 +4685,12 @@ nv.models.linePlusBarChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
@ -5547,8 +5660,9 @@ nv.models.multiBarChart = function() {
}
, x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale()
, state = { stacked: false }
, noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
multibar
@ -5776,6 +5890,9 @@ nv.models.multiBarChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -5796,6 +5913,9 @@ nv.models.multiBarChart = function() {
break;
}
state.stacked = multibar.stacked();
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -5803,6 +5923,25 @@ nv.models.multiBarChart = 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.stacked !== 'undefined') {
multibar.stacked(e.stacked);
state.stacked = e.stacked;
}
selection.call(chart);
});
//============================================================
@ -5914,6 +6053,12 @@ nv.models.multiBarChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
@ -6323,8 +6468,9 @@ nv.models.multiBarHorizontalChart = function() {
}
, x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale()
, state = { stacked: stacked }
, noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
multibar
@ -6536,6 +6682,9 @@ nv.models.multiBarHorizontalChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -6556,6 +6705,9 @@ nv.models.multiBarHorizontalChart = function() {
break;
}
state.stacked = multibar.stacked();
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -6563,6 +6715,24 @@ nv.models.multiBarHorizontalChart = 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.stacked !== 'undefined') {
multibar.stacked(e.stacked);
state.stacked = e.stacked;
}
selection.call(chart);
});
//============================================================
@ -6662,6 +6832,12 @@ nv.models.multiBarHorizontalChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
@ -7819,8 +7995,9 @@ nv.models.pieChart = function() {
return '<h3>' + key + '</h3>' +
'<p>' + y + '</p>'
}
, state = {}
, noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
//============================================================
@ -7952,6 +8129,9 @@ nv.models.pieChart = function() {
});
}
state.disabled = data[0].map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
selection.transition().call(chart)
});
@ -7959,6 +8139,20 @@ nv.models.pieChart = function() {
dispatch.tooltipHide(e);
});
// Update chart from a state object passed to event handler
dispatch.on('changeState', function(e) {
if (typeof e.disabled !== 'undefined') {
data[0].forEach(function(series,i) {
series.disabled = e.disabled[i];
});
state.disabled = e.disabled;
}
selection.call(chart);
});
//============================================================
@ -8045,6 +8239,12 @@ nv.models.pieChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
@ -8245,13 +8445,13 @@ nv.models.scatter = function() {
}
if(vertices.length < 3) {
// if(vertices.length < 3) {
// Issue #283 - Adding 2 dummy points to the voronoi b/c voronoi requires min 3 points to work
vertices.push([x.range()[0] - 2000, y.range()[0] - 2000, null, null]);
vertices.push([x.range()[1] + 2000, y.range()[1] + 2000, null, null]);
vertices.push([x.range()[0] - 2000, y.range()[0] + 2000, null, null]);
vertices.push([x.range()[1] + 2000, y.range()[1] - 2000, null, null]);
}
vertices.push([x.range()[0] - 20, y.range()[0] - 20, null, null]);
vertices.push([x.range()[1] + 20, y.range()[1] + 20, null, null]);
vertices.push([x.range()[0] - 20, y.range()[0] + 20, null, null]);
vertices.push([x.range()[1] + 20, y.range()[1] - 20, null, null]);
// }
var bounds = d3.geom.polygon([
[-10,-10],
@ -8708,7 +8908,7 @@ nv.models.scatterChart = function() {
, tooltipY = function(key, x, y) { return '<strong>' + y + '</strong>' }
//, tooltip = function(key, x, y) { return '<h3>' + key + '</h3>' }
, tooltip = null
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, noData = "No Data Available."
;
@ -8738,7 +8938,8 @@ nv.models.scatterChart = function() {
// Private Variables
//------------------------------------------------------------
var x0, y0;
var state = {},
x0, y0;
var showTooltip = function(e, offsetElement) {
//TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?)
@ -9039,6 +9240,9 @@ nv.models.scatterChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
chart(selection);
});
@ -9068,6 +9272,20 @@ nv.models.scatterChart = 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;
}
selection.call(chart);
});
//============================================================
@ -9213,6 +9431,12 @@ nv.models.scatterChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
@ -9258,7 +9482,7 @@ nv.models.scatterPlusLineChart = function() {
, tooltip = function(key, x, y, date) { return '<h3>' + key + '</h3>'
+ '<p>' + date + '</p>' }
//, tooltip = null
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, noData = "No Data Available."
;
@ -9288,7 +9512,8 @@ nv.models.scatterPlusLineChart = function() {
// Private Variables
//------------------------------------------------------------
var x0, y0;
var state = {},
x0, y0;
var showTooltip = function(e, offsetElement) {
//TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?)
@ -9604,6 +9829,9 @@ nv.models.scatterPlusLineChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
chart(selection);
});
@ -9633,6 +9861,20 @@ nv.models.scatterPlusLineChart = 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;
}
selection.call(chart);
});
//============================================================
@ -9766,6 +10008,12 @@ nv.models.scatterPlusLineChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
@ -9976,6 +10224,7 @@ nv.models.sparklinePlus = function() {
, yTickFormat = d3.format(',.2f')
, showValue = true
, alignValue = true
, rightAlignValue = false
, noData = "No Data Available."
;
@ -10069,11 +10318,12 @@ nv.models.sparklinePlus = function() {
.data([currentValue]);
value.enter().append('text').attr('class', 'nv-currentValue')
.attr('dx', 8)
.attr('dy', '.9em');
.attr('dx', rightAlignValue ? -8 : 8)
.attr('dy', '.9em')
.style('text-anchor', rightAlignValue ? 'end' : 'start');
value
.attr('x', availableWidth)
.attr('x', availableWidth + (rightAlignValue ? margin.right : 0))
.attr('y', alignValue ? function(d) { return y(d) } : 0)
.style('fill', sparkline.color()(data[data.length-1], data.length-1))
.text(yTickFormat(currentValue));
@ -10228,6 +10478,12 @@ nv.models.sparklinePlus = function() {
return chart;
};
chart.rightAlignValue = function(_) {
if (!arguments.length) return rightAlignValue;
rightAlignValue = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
@ -10603,8 +10859,9 @@ nv.models.stackedAreaChart = function() {
, x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale()
, yAxisTickFormat = d3.format(',.2f')
, state = { style: stacked.style() }
, noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
xAxis
@ -10837,6 +11094,9 @@ nv.models.stackedAreaChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
//selection.transition().call(chart);
chart(selection);
});
@ -10862,6 +11122,9 @@ nv.models.stackedAreaChart = function() {
break;
}
state.style = stacked.style();
dispatch.stateChange(state);
//selection.transition().call(chart);
chart(selection);
});
@ -10870,6 +11133,24 @@ nv.models.stackedAreaChart = 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.style !== 'undefined') {
stacked.style(e.style);
}
selection.call(chart);
});
});
@ -10979,6 +11260,12 @@ nv.models.stackedAreaChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

10
nv.d3.min.js vendored

File diff suppressed because one or more lines are too long

@ -27,8 +27,9 @@ nv.models.cumulativeLineChart = function() {
, x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale()
, id = lines.id()
, state = { index: 0, rescaleY: rescaleY }
, noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
xAxis
@ -126,6 +127,10 @@ nv.models.cumulativeLineChart = function() {
function dragEnd(d,i) {
d3.select(chart.container)
.style('cursor', 'auto');
// update state and send stateChange with new index
state.index = index.i;
dispatch.stateChange(state);
}
@ -359,12 +364,22 @@ nv.models.cumulativeLineChart = function() {
.on('click', function() {
index.x = d3.mouse(this)[0];
index.i = Math.round(dx.invert(index.x));
// update state and send stateChange with new index
state.index = index.i;
dispatch.stateChange(state);
updateZero();
});
lines.dispatch.on('elementClick', function(e) {
index.i = e.pointIndex;
index.x = dx(index.i);
// update state and send stateChange with new index
state.index = index.i;
dispatch.stateChange(state);
updateZero();
});
@ -372,6 +387,9 @@ nv.models.cumulativeLineChart = function() {
d.disabled = !d.disabled;
rescaleY = !d.disabled;
state.rescaleY = rescaleY;
dispatch.stateChange(state);
//selection.transition().call(chart);
selection.call(chart);
});
@ -388,6 +406,9 @@ nv.models.cumulativeLineChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
//selection.transition().call(chart);
selection.call(chart);
});
@ -409,6 +430,37 @@ 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);
state.index = e.index;
indexLine
.data([index]);
}
if (typeof e.rescaleY !== 'undefined') {
rescaleY = e.rescaleY;
}
selection.call(chart);
});
//============================================================
});
@ -478,6 +530,12 @@ nv.models.cumulativeLineChart = function() {
return chart;
};
chart.rescaleY = function(_) {
if (!arguments.length) return rescaleY;
rescaleY = _
return rescaleY;
};
chart.showControls = function(_) {
if (!arguments.length) return showControls;
showControls = _;
@ -502,6 +560,12 @@ nv.models.cumulativeLineChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

@ -23,7 +23,7 @@ nv.models.discreteBarChart = function() {
, x
, y
, noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'beforeUpdate')
;
xAxis
@ -68,7 +68,7 @@ nv.models.discreteBarChart = function() {
- margin.top - margin.bottom;
chart.update = function() { selection.transition().call(chart); };
chart.update = function() { dispatch.beforeUpdate(); selection.transition().call(chart); };
chart.container = this;

@ -24,8 +24,9 @@ nv.models.lineChart = function() {
}
, x
, y
, state = {}
, noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
xAxis
@ -216,6 +217,9 @@ nv.models.lineChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -235,6 +239,20 @@ nv.models.lineChart = function() {
if (tooltips) showTooltip(e, that.parentNode);
});
dispatch.on('changeState', function(e) {
if (typeof e.disabled !== 'undefined') {
data.forEach(function(series,i) {
series.disabled = e.disabled[i];
});
state.disabled = e.disabled;
}
selection.call(chart);
});
//============================================================
});
@ -322,6 +340,12 @@ nv.models.lineChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

@ -29,7 +29,7 @@ nv.models.linePlusBarChart = function() {
, y1
, y2
, noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
bars
@ -58,15 +58,17 @@ nv.models.linePlusBarChart = function() {
// Private Variables
//------------------------------------------------------------
var showTooltip = function(e, offsetElement) {
var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
top = e.pos[1] + ( offsetElement.offsetTop || 0),
x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)),
y = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)),
content = tooltip(e.series.key, x, y, e, chart);
var state = {},
showTooltip = function(e, offsetElement) {
var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
top = e.pos[1] + ( offsetElement.offsetTop || 0),
x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)),
y = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)),
content = tooltip(e.series.key, x, y, e, chart);
nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement);
};
nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement);
}
;
//------------------------------------------------------------
@ -117,14 +119,13 @@ nv.models.linePlusBarChart = function() {
var dataLines = data.filter(function(d) { return !d.bar }); // removed the !d.disabled clause here to fix Issue #240
//x = xAxis.scale();
x = dataLines.filter(function(d) { return !d.disabled; }).length ? lines.xScale() : bars.xScale();
x = dataLines.filter(function(d) { return !d.disabled; }).length && dataLines.filter(function(d) { return !d.disabled; })[0].values.length ? lines.xScale() : bars.xScale();
//x = dataLines.filter(function(d) { return !d.disabled; }).length ? lines.xScale() : bars.xScale(); //old code before change above
y1 = bars.yScale();
y2 = lines.yScale();
//------------------------------------------------------------
//------------------------------------------------------------
// Setup containers and skeleton of chart
@ -260,6 +261,9 @@ nv.models.linePlusBarChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -267,6 +271,21 @@ nv.models.linePlusBarChart = 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;
}
selection.call(chart);
});
//============================================================
@ -384,6 +403,12 @@ nv.models.linePlusBarChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

@ -27,8 +27,9 @@ nv.models.multiBarChart = function() {
}
, x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale()
, state = { stacked: false }
, noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
multibar
@ -256,6 +257,9 @@ nv.models.multiBarChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -276,6 +280,9 @@ nv.models.multiBarChart = function() {
break;
}
state.stacked = multibar.stacked();
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -283,6 +290,25 @@ nv.models.multiBarChart = 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.stacked !== 'undefined') {
multibar.stacked(e.stacked);
state.stacked = e.stacked;
}
selection.call(chart);
});
//============================================================
@ -394,6 +420,12 @@ nv.models.multiBarChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

@ -26,8 +26,9 @@ nv.models.multiBarHorizontalChart = function() {
}
, x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale()
, state = { stacked: stacked }
, noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
multibar
@ -239,6 +240,9 @@ nv.models.multiBarHorizontalChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -259,6 +263,9 @@ nv.models.multiBarHorizontalChart = function() {
break;
}
state.stacked = multibar.stacked();
dispatch.stateChange(state);
selection.transition().call(chart);
});
@ -266,6 +273,24 @@ nv.models.multiBarHorizontalChart = 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.stacked !== 'undefined') {
multibar.stacked(e.stacked);
state.stacked = e.stacked;
}
selection.call(chart);
});
//============================================================
@ -365,6 +390,12 @@ nv.models.multiBarHorizontalChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

@ -19,8 +19,9 @@ nv.models.pieChart = function() {
return '<h3>' + key + '</h3>' +
'<p>' + y + '</p>'
}
, state = {}
, noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
//============================================================
@ -152,6 +153,9 @@ nv.models.pieChart = function() {
});
}
state.disabled = data[0].map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
selection.transition().call(chart)
});
@ -159,6 +163,20 @@ nv.models.pieChart = function() {
dispatch.tooltipHide(e);
});
// Update chart from a state object passed to event handler
dispatch.on('changeState', function(e) {
if (typeof e.disabled !== 'undefined') {
data[0].forEach(function(series,i) {
series.disabled = e.disabled[i];
});
state.disabled = e.disabled;
}
selection.call(chart);
});
//============================================================
@ -245,6 +263,12 @@ nv.models.pieChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

@ -187,13 +187,13 @@ nv.models.scatter = function() {
}
if(vertices.length < 3) {
// if(vertices.length < 3) {
// Issue #283 - Adding 2 dummy points to the voronoi b/c voronoi requires min 3 points to work
vertices.push([x.range()[0] - 2000, y.range()[0] - 2000, null, null]);
vertices.push([x.range()[1] + 2000, y.range()[1] + 2000, null, null]);
vertices.push([x.range()[0] - 2000, y.range()[0] + 2000, null, null]);
vertices.push([x.range()[1] + 2000, y.range()[1] - 2000, null, null]);
}
vertices.push([x.range()[0] - 20, y.range()[0] - 20, null, null]);
vertices.push([x.range()[1] + 20, y.range()[1] + 20, null, null]);
vertices.push([x.range()[0] - 20, y.range()[0] + 20, null, null]);
vertices.push([x.range()[1] + 20, y.range()[1] - 20, null, null]);
// }
var bounds = d3.geom.polygon([
[-10,-10],

@ -33,7 +33,7 @@ nv.models.scatterChart = function() {
, tooltipY = function(key, x, y) { return '<strong>' + y + '</strong>' }
//, tooltip = function(key, x, y) { return '<h3>' + key + '</h3>' }
, tooltip = null
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, noData = "No Data Available."
;
@ -63,7 +63,8 @@ nv.models.scatterChart = function() {
// Private Variables
//------------------------------------------------------------
var x0, y0;
var state = {},
x0, y0;
var showTooltip = function(e, offsetElement) {
//TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?)
@ -364,6 +365,9 @@ nv.models.scatterChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
chart(selection);
});
@ -393,6 +397,20 @@ nv.models.scatterChart = 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;
}
selection.call(chart);
});
//============================================================
@ -538,6 +556,12 @@ nv.models.scatterChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

@ -32,7 +32,7 @@ nv.models.scatterPlusLineChart = function() {
, tooltip = function(key, x, y, date) { return '<h3>' + key + '</h3>'
+ '<p>' + date + '</p>' }
//, tooltip = null
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
, noData = "No Data Available."
;
@ -62,7 +62,8 @@ nv.models.scatterPlusLineChart = function() {
// Private Variables
//------------------------------------------------------------
var x0, y0;
var state = {},
x0, y0;
var showTooltip = function(e, offsetElement) {
//TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?)
@ -378,6 +379,9 @@ nv.models.scatterPlusLineChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
chart(selection);
});
@ -407,6 +411,20 @@ nv.models.scatterPlusLineChart = 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;
}
selection.call(chart);
});
//============================================================
@ -540,6 +558,12 @@ nv.models.scatterPlusLineChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

@ -18,6 +18,7 @@ nv.models.sparklinePlus = function() {
, yTickFormat = d3.format(',.2f')
, showValue = true
, alignValue = true
, rightAlignValue = false
, noData = "No Data Available."
;
@ -111,11 +112,12 @@ nv.models.sparklinePlus = function() {
.data([currentValue]);
value.enter().append('text').attr('class', 'nv-currentValue')
.attr('dx', 8)
.attr('dy', '.9em');
.attr('dx', rightAlignValue ? -8 : 8)
.attr('dy', '.9em')
.style('text-anchor', rightAlignValue ? 'end' : 'start');
value
.attr('x', availableWidth)
.attr('x', availableWidth + (rightAlignValue ? margin.right : 0))
.attr('y', alignValue ? function(d) { return y(d) } : 0)
.style('fill', sparkline.color()(data[data.length-1], data.length-1))
.text(yTickFormat(currentValue));
@ -270,6 +272,12 @@ nv.models.sparklinePlus = function() {
return chart;
};
chart.rightAlignValue = function(_) {
if (!arguments.length) return rightAlignValue;
rightAlignValue = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

@ -26,8 +26,9 @@ nv.models.stackedAreaChart = function() {
, x //can be accessed via chart.xScale()
, y //can be accessed via chart.yScale()
, yAxisTickFormat = d3.format(',.2f')
, state = { style: stacked.style() }
, noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
;
xAxis
@ -260,6 +261,9 @@ nv.models.stackedAreaChart = function() {
});
}
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
//selection.transition().call(chart);
chart(selection);
});
@ -285,6 +289,9 @@ nv.models.stackedAreaChart = function() {
break;
}
state.style = stacked.style();
dispatch.stateChange(state);
//selection.transition().call(chart);
chart(selection);
});
@ -293,6 +300,24 @@ nv.models.stackedAreaChart = 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.style !== 'undefined') {
stacked.style(e.style);
}
selection.call(chart);
});
});
@ -402,6 +427,12 @@ nv.models.stackedAreaChart = function() {
return chart;
};
chart.state = function(_) {
if (!arguments.length) return state;
state = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;

@ -1,6 +1,6 @@
/*****
* A no frills tooltip implementation.
* A no-frills tooltip implementation.
*****/

@ -40,7 +40,7 @@ nv.utils.windowResize = function(fun){
// Backwards compatible way to implement more d3-like coloring of graphs.
// If passed an array, wrap it in a function which implements the old default
// behaviour
// behavior
nv.utils.getColor = function(color) {
if (!arguments.length) return nv.utils.defaultColor(); //if you pass in nothing, get default colors back
@ -48,7 +48,7 @@ nv.utils.getColor = function(color) {
return function(d, i) { return d.color || color[i % color.length]; };
else
return color;
//can't really help it if someone passes rubish as color
//can't really help it if someone passes rubbish as color
}
// Default color chooser uses the index of an object as before.

Loading…
Cancel
Save