2012-06-09 06:51:41 +00:00
|
|
|
|
2012-06-09 19:44:12 +00:00
|
|
|
nv.models.lineChart = function() {
|
2012-07-09 20:01:33 +00:00
|
|
|
|
|
|
|
//============================================================
|
|
|
|
// Public Variables with Default Settings
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
var lines = nv.models.line()
|
|
|
|
, xAxis = nv.models.axis()
|
|
|
|
, yAxis = nv.models.axis()
|
|
|
|
, legend = nv.models.legend()
|
2013-07-04 03:17:08 +00:00
|
|
|
, interactiveLayer = nv.interactiveGuideline()
|
2012-08-18 00:15:28 +00:00
|
|
|
;
|
|
|
|
|
2012-11-06 23:49:45 +00:00
|
|
|
//set margin.right to 23 to fit dates on the x-axis within the chart
|
2012-11-07 16:27:55 +00:00
|
|
|
var margin = {top: 30, right: 20, bottom: 50, left: 60}
|
2012-08-18 00:15:28 +00:00
|
|
|
, color = nv.utils.defaultColor()
|
|
|
|
, width = null
|
|
|
|
, height = null
|
|
|
|
, showLegend = true
|
2013-06-07 21:07:00 +00:00
|
|
|
, showXAxis = true
|
|
|
|
, showYAxis = true
|
2013-06-11 16:59:33 +00:00
|
|
|
, rightAlignYAxis = false
|
2013-07-04 03:17:08 +00:00
|
|
|
, useInteractiveGuideline = false
|
2012-08-18 00:15:28 +00:00
|
|
|
, tooltips = true
|
2013-07-04 03:17:08 +00:00
|
|
|
, tooltip = function(key, x, y, e, graph) {
|
|
|
|
return '<h3>' + key + '</h3>' +
|
|
|
|
'<p>' + y + ' at ' + x + '</p>'
|
2012-08-18 00:15:28 +00:00
|
|
|
}
|
|
|
|
, x
|
|
|
|
, y
|
2012-12-28 05:05:37 +00:00
|
|
|
, state = {}
|
2013-04-04 19:45:26 +00:00
|
|
|
, defaultState = null
|
2012-08-21 16:08:05 +00:00
|
|
|
, noData = 'No Data Available.'
|
2012-12-28 05:05:37 +00:00
|
|
|
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
|
2012-08-18 00:15:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
xAxis
|
|
|
|
.orient('bottom')
|
2012-10-26 15:09:39 +00:00
|
|
|
.tickPadding(7)
|
2012-08-18 00:15:28 +00:00
|
|
|
;
|
|
|
|
yAxis
|
2013-06-11 16:59:33 +00:00
|
|
|
.orient((rightAlignYAxis) ? 'right' : 'left')
|
2012-08-18 00:15:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
//============================================================
|
2012-07-09 20:01:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
//============================================================
|
|
|
|
// Private Variables
|
|
|
|
//------------------------------------------------------------
|
2012-06-09 06:51:41 +00:00
|
|
|
|
|
|
|
var showTooltip = function(e, offsetElement) {
|
2013-07-04 03:17:08 +00:00
|
|
|
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 = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)),
|
|
|
|
content = tooltip(e.series.key, x, y, e, chart);
|
|
|
|
|
|
|
|
nv.tooltip.show([left, top], content, null, null, offsetElement);
|
2012-06-09 06:51:41 +00:00
|
|
|
};
|
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
//============================================================
|
|
|
|
|
2012-06-09 06:51:41 +00:00
|
|
|
|
|
|
|
function chart(selection) {
|
|
|
|
selection.each(function(data) {
|
2012-06-20 06:38:19 +00:00
|
|
|
var container = d3.select(this),
|
|
|
|
that = this;
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2012-06-12 06:26:57 +00:00
|
|
|
var availableWidth = (width || parseInt(container.style('width')) || 960)
|
2012-06-09 06:51:41 +00:00
|
|
|
- margin.left - margin.right,
|
2012-06-12 06:26:57 +00:00
|
|
|
availableHeight = (height || parseInt(container.style('height')) || 400)
|
2012-06-09 06:51:41 +00:00
|
|
|
- margin.top - margin.bottom;
|
|
|
|
|
2012-07-27 21:37:20 +00:00
|
|
|
|
2013-04-16 22:54:46 +00:00
|
|
|
chart.update = function() { container.transition().call(chart) };
|
2012-08-22 18:29:42 +00:00
|
|
|
chart.container = this;
|
|
|
|
|
2013-03-20 21:46:10 +00:00
|
|
|
//set state.disabled
|
|
|
|
state.disabled = data.map(function(d) { return !!d.disabled });
|
|
|
|
|
2013-04-04 19:45:26 +00:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
}
|
2012-08-22 18:29:42 +00:00
|
|
|
|
2012-07-27 21:37:20 +00:00
|
|
|
//------------------------------------------------------------
|
2012-08-18 00:15:28 +00:00
|
|
|
// Display noData message if there's nothing to show.
|
2012-07-27 21:37:20 +00:00
|
|
|
|
|
|
|
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
|
2012-08-22 18:29:42 +00:00
|
|
|
var noDataText = container.selectAll('.nv-noData').data([noData]);
|
|
|
|
|
|
|
|
noDataText.enter().append('text')
|
2012-07-27 21:37:20 +00:00
|
|
|
.attr('class', 'nvd3 nv-noData')
|
|
|
|
.attr('dy', '-.7em')
|
2012-08-22 18:29:42 +00:00
|
|
|
.style('text-anchor', 'middle');
|
|
|
|
|
|
|
|
noDataText
|
|
|
|
.attr('x', margin.left + availableWidth / 2)
|
|
|
|
.attr('y', margin.top + availableHeight / 2)
|
|
|
|
.text(function(d) { return d });
|
|
|
|
|
|
|
|
return chart;
|
2012-07-27 21:37:20 +00:00
|
|
|
} else {
|
2012-08-22 18:29:42 +00:00
|
|
|
container.selectAll('.nv-noData').remove();
|
2012-07-27 21:37:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
//------------------------------------------------------------
|
|
|
|
// Setup Scales
|
|
|
|
|
2012-07-09 20:01:33 +00:00
|
|
|
x = lines.xScale();
|
|
|
|
y = lines.yScale();
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// Setup containers and skeleton of chart
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2012-07-26 23:42:42 +00:00
|
|
|
var wrap = container.selectAll('g.nv-wrap.nv-lineChart').data([data]);
|
|
|
|
var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineChart').append('g');
|
2012-08-18 00:15:28 +00:00
|
|
|
var g = wrap.select('g');
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2012-07-26 23:42:42 +00:00
|
|
|
gEnter.append('g').attr('class', 'nv-x nv-axis');
|
|
|
|
gEnter.append('g').attr('class', 'nv-y nv-axis');
|
|
|
|
gEnter.append('g').attr('class', 'nv-linesWrap');
|
|
|
|
gEnter.append('g').attr('class', 'nv-legendWrap');
|
2013-07-03 14:33:48 +00:00
|
|
|
gEnter.append('g').attr('class', 'nv-interactive');
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
//------------------------------------------------------------
|
|
|
|
// Legend
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2012-06-14 05:18:12 +00:00
|
|
|
if (showLegend) {
|
|
|
|
legend.width(availableWidth);
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2012-07-26 23:42:42 +00:00
|
|
|
g.select('.nv-legendWrap')
|
2012-06-14 05:18:12 +00:00
|
|
|
.datum(data)
|
|
|
|
.call(legend);
|
2012-06-15 16:47:47 +00:00
|
|
|
|
|
|
|
if ( margin.top != legend.height()) {
|
|
|
|
margin.top = legend.height();
|
|
|
|
availableHeight = (height || parseInt(container.style('height')) || 400)
|
|
|
|
- margin.top - margin.bottom;
|
|
|
|
}
|
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
wrap.select('.nv-legendWrap')
|
2012-06-15 16:47:47 +00:00
|
|
|
.attr('transform', 'translate(0,' + (-margin.top) +')')
|
2012-06-14 05:18:12 +00:00
|
|
|
}
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
//------------------------------------------------------------
|
|
|
|
|
2012-08-18 02:51:06 +00:00
|
|
|
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
|
|
|
|
|
2013-06-11 16:59:33 +00:00
|
|
|
if (rightAlignYAxis) {
|
|
|
|
g.select(".nv-y.nv-axis")
|
|
|
|
.attr("transform", "translate(" + availableWidth + ",0)");
|
|
|
|
}
|
2012-08-18 00:15:28 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// Main Chart Component(s)
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2013-07-09 21:20:20 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//Set up interactive layer
|
|
|
|
if (useInteractiveGuideline) {
|
2013-07-25 20:03:05 +00:00
|
|
|
interactiveLayer
|
|
|
|
.width(availableWidth)
|
|
|
|
.height(availableHeight)
|
|
|
|
.margin({left:margin.left, top:margin.top})
|
|
|
|
.svgContainer(container)
|
|
|
|
.xScale(x);
|
2013-07-09 21:20:20 +00:00
|
|
|
wrap.select(".nv-interactive").call(interactiveLayer);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-15 16:47:47 +00:00
|
|
|
lines
|
|
|
|
.width(availableWidth)
|
|
|
|
.height(availableHeight)
|
|
|
|
.color(data.map(function(d,i) {
|
2012-07-26 12:26:01 +00:00
|
|
|
return d.color || color(d, i);
|
2012-06-15 16:47:47 +00:00
|
|
|
}).filter(function(d,i) { return !data[i].disabled }));
|
|
|
|
|
|
|
|
|
2012-07-26 23:42:42 +00:00
|
|
|
var linesWrap = g.select('.nv-linesWrap')
|
2012-06-09 06:51:41 +00:00
|
|
|
.datum(data.filter(function(d) { return !d.disabled }))
|
|
|
|
|
|
|
|
d3.transition(linesWrap).call(lines);
|
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
//------------------------------------------------------------
|
2012-06-09 06:51:41 +00:00
|
|
|
|
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
//------------------------------------------------------------
|
|
|
|
// Setup Axes
|
|
|
|
|
2013-06-07 21:07:00 +00:00
|
|
|
if (showXAxis) {
|
|
|
|
xAxis
|
|
|
|
.scale(x)
|
|
|
|
.ticks( availableWidth / 100 )
|
|
|
|
.tickSize(-availableHeight, 0);
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2013-06-07 21:07:00 +00:00
|
|
|
g.select('.nv-x.nv-axis')
|
|
|
|
.attr('transform', 'translate(0,' + y.range()[0] + ')');
|
|
|
|
d3.transition(g.select('.nv-x.nv-axis'))
|
|
|
|
.call(xAxis);
|
|
|
|
}
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2013-06-07 21:07:00 +00:00
|
|
|
if (showYAxis) {
|
|
|
|
yAxis
|
|
|
|
.scale(y)
|
|
|
|
.ticks( availableHeight / 36 )
|
|
|
|
.tickSize( -availableWidth, 0);
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2013-06-07 21:07:00 +00:00
|
|
|
d3.transition(g.select('.nv-y.nv-axis'))
|
|
|
|
.call(yAxis);
|
|
|
|
}
|
2012-08-18 00:15:28 +00:00
|
|
|
//------------------------------------------------------------
|
2012-06-09 06:51:41 +00:00
|
|
|
|
|
|
|
|
2012-07-09 20:01:33 +00:00
|
|
|
//============================================================
|
|
|
|
// Event Handling/Dispatching (in chart's scope)
|
|
|
|
//------------------------------------------------------------
|
2012-06-09 06:51:41 +00:00
|
|
|
|
|
|
|
legend.dispatch.on('legendClick', function(d,i) {
|
|
|
|
d.disabled = !d.disabled;
|
|
|
|
|
|
|
|
if (!data.filter(function(d) { return !d.disabled }).length) {
|
|
|
|
data.map(function(d) {
|
|
|
|
d.disabled = false;
|
2012-07-26 23:42:42 +00:00
|
|
|
wrap.selectAll('.nv-series').classed('disabled', false);
|
2012-06-09 06:51:41 +00:00
|
|
|
return d;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-12-28 05:05:37 +00:00
|
|
|
state.disabled = data.map(function(d) { return !!d.disabled });
|
|
|
|
dispatch.stateChange(state);
|
|
|
|
|
2013-04-16 22:54:46 +00:00
|
|
|
// container.transition().call(chart);
|
|
|
|
chart.update();
|
2012-06-09 06:51:41 +00:00
|
|
|
});
|
|
|
|
|
2013-06-11 20:38:39 +00:00
|
|
|
legend.dispatch.on('legendDblclick', function(d) {
|
|
|
|
//Double clicking should always enable current series, and disabled all others.
|
|
|
|
data.forEach(function(d) {
|
|
|
|
d.disabled = true;
|
|
|
|
});
|
|
|
|
d.disabled = false;
|
|
|
|
|
|
|
|
state.disabled = data.map(function(d) { return !!d.disabled });
|
|
|
|
dispatch.stateChange(state);
|
|
|
|
chart.update();
|
|
|
|
});
|
|
|
|
|
2013-07-04 16:21:12 +00:00
|
|
|
|
|
|
|
|
2013-07-03 14:33:48 +00:00
|
|
|
interactiveLayer.dispatch.on('elementMousemove', function(e) {
|
2013-07-06 15:05:23 +00:00
|
|
|
lines.clearHighlights();
|
2013-07-04 16:21:12 +00:00
|
|
|
var singlePoint, pointIndex, pointXLocation, allData = [];
|
2013-07-03 17:43:32 +00:00
|
|
|
data
|
|
|
|
.filter(function(series, i) {
|
|
|
|
series.seriesIndex = i;
|
|
|
|
return !series.disabled;
|
|
|
|
})
|
|
|
|
.forEach(function(series,i) {
|
2013-07-05 02:18:02 +00:00
|
|
|
pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x());
|
2013-07-06 15:05:23 +00:00
|
|
|
lines.highlightPoint(i, pointIndex, true);
|
2013-07-04 16:21:12 +00:00
|
|
|
var point = series.values[pointIndex];
|
2013-07-03 17:43:32 +00:00
|
|
|
if (typeof point === 'undefined') return;
|
2013-07-04 03:17:08 +00:00
|
|
|
if (typeof singlePoint === 'undefined') singlePoint = point;
|
2013-07-06 17:25:52 +00:00
|
|
|
if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex));
|
2013-07-03 14:33:48 +00:00
|
|
|
allData.push({
|
|
|
|
key: series.key,
|
2013-07-06 17:25:52 +00:00
|
|
|
value: chart.y()(point, pointIndex),
|
2013-07-03 17:43:32 +00:00
|
|
|
color: color(series,series.seriesIndex)
|
2013-07-03 14:33:48 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-07-05 02:18:02 +00:00
|
|
|
var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex));
|
2013-07-04 03:17:08 +00:00
|
|
|
interactiveLayer.tooltip
|
2013-07-04 16:21:12 +00:00
|
|
|
.position({left: pointXLocation + margin.left, top: e.mouseY + margin.top})
|
2013-07-08 19:06:22 +00:00
|
|
|
.chartContainer(that.parentNode)
|
2013-07-04 03:17:08 +00:00
|
|
|
.enabled(tooltips)
|
|
|
|
.valueFormatter(function(d,i) {
|
|
|
|
return yAxis.tickFormat()(d);
|
|
|
|
})
|
|
|
|
.data(
|
|
|
|
{
|
|
|
|
value: xValue,
|
|
|
|
series: allData
|
|
|
|
}
|
|
|
|
)();
|
2013-06-11 20:38:39 +00:00
|
|
|
|
2013-07-04 16:21:12 +00:00
|
|
|
interactiveLayer.renderGuideLine(pointXLocation);
|
|
|
|
|
2012-06-09 06:51:41 +00:00
|
|
|
});
|
|
|
|
|
2013-07-03 14:33:48 +00:00
|
|
|
interactiveLayer.dispatch.on("elementMouseout",function(e) {
|
|
|
|
dispatch.tooltipHide();
|
2013-07-06 15:05:23 +00:00
|
|
|
lines.clearHighlights();
|
2012-06-09 06:51:41 +00:00
|
|
|
});
|
|
|
|
|
2012-07-09 20:01:33 +00:00
|
|
|
dispatch.on('tooltipShow', function(e) {
|
2013-07-06 14:46:17 +00:00
|
|
|
if (tooltips) showTooltip(e, that.parentNode);
|
2012-06-09 06:51:41 +00:00
|
|
|
});
|
|
|
|
|
2012-12-28 05:05:37 +00:00
|
|
|
|
|
|
|
dispatch.on('changeState', function(e) {
|
|
|
|
|
|
|
|
if (typeof e.disabled !== 'undefined') {
|
|
|
|
data.forEach(function(series,i) {
|
|
|
|
series.disabled = e.disabled[i];
|
|
|
|
});
|
|
|
|
|
|
|
|
state.disabled = e.disabled;
|
|
|
|
}
|
|
|
|
|
2013-05-17 23:31:30 +00:00
|
|
|
chart.update();
|
2012-12-28 05:05:37 +00:00
|
|
|
});
|
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
//============================================================
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
});
|
2012-06-09 06:51:41 +00:00
|
|
|
|
|
|
|
return chart;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-09 20:01:33 +00:00
|
|
|
//============================================================
|
|
|
|
// Event Handling/Dispatching (out of chart's scope)
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
lines.dispatch.on('elementMouseover.tooltip', function(e) {
|
|
|
|
e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
|
2013-07-04 03:17:08 +00:00
|
|
|
dispatch.tooltipShow(e);
|
2012-07-09 20:01:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
lines.dispatch.on('elementMouseout.tooltip', function(e) {
|
2013-07-04 03:17:08 +00:00
|
|
|
dispatch.tooltipHide(e);
|
2012-07-09 20:01:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
dispatch.on('tooltipHide', function() {
|
|
|
|
if (tooltips) nv.tooltip.cleanup();
|
|
|
|
});
|
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
//============================================================
|
|
|
|
|
2012-07-09 20:01:33 +00:00
|
|
|
|
|
|
|
//============================================================
|
2012-08-18 00:15:28 +00:00
|
|
|
// Expose Public Variables
|
2012-07-09 20:01:33 +00:00
|
|
|
//------------------------------------------------------------
|
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
// expose chart's sub-components
|
2012-06-09 06:51:41 +00:00
|
|
|
chart.dispatch = dispatch;
|
2012-08-18 00:15:28 +00:00
|
|
|
chart.lines = lines;
|
2012-06-09 06:51:41 +00:00
|
|
|
chart.legend = legend;
|
|
|
|
chart.xAxis = xAxis;
|
|
|
|
chart.yAxis = yAxis;
|
2013-07-05 02:18:02 +00:00
|
|
|
chart.interactiveLayer = interactiveLayer;
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2013-07-03 14:33:48 +00:00
|
|
|
d3.rebind(chart, lines, 'defined', 'isArea', 'x', 'y', 'size', 'xScale', 'yScale', 'xDomain', 'yDomain', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'useVoronoi','id', 'interpolate');
|
2012-06-09 06:51:41 +00:00
|
|
|
|
|
|
|
chart.margin = function(_) {
|
|
|
|
if (!arguments.length) return margin;
|
2012-08-27 17:39:23 +00:00
|
|
|
margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
|
|
|
|
margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
|
|
|
|
margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
|
|
|
|
margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
|
2012-06-09 06:51:41 +00:00
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
|
|
|
chart.width = function(_) {
|
|
|
|
if (!arguments.length) return width;
|
|
|
|
width = _;
|
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
|
|
|
chart.height = function(_) {
|
|
|
|
if (!arguments.length) return height;
|
|
|
|
height = _;
|
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
2012-06-15 16:47:47 +00:00
|
|
|
chart.color = function(_) {
|
|
|
|
if (!arguments.length) return color;
|
2012-07-26 12:26:01 +00:00
|
|
|
color = nv.utils.getColor(_);
|
|
|
|
legend.color(color);
|
2012-06-15 16:47:47 +00:00
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
2012-06-14 05:18:12 +00:00
|
|
|
chart.showLegend = function(_) {
|
|
|
|
if (!arguments.length) return showLegend;
|
|
|
|
showLegend = _;
|
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
2013-06-07 21:07:00 +00:00
|
|
|
chart.showXAxis = function(_) {
|
|
|
|
if (!arguments.length) return showXAxis;
|
|
|
|
showXAxis = _;
|
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
|
|
|
chart.showYAxis = function(_) {
|
|
|
|
if (!arguments.length) return showYAxis;
|
|
|
|
showYAxis = _;
|
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
2013-06-11 16:59:33 +00:00
|
|
|
chart.rightAlignYAxis = function(_) {
|
|
|
|
if(!arguments.length) return rightAlignYAxis;
|
|
|
|
rightAlignYAxis = _;
|
|
|
|
yAxis.orient( (_) ? 'right' : 'left');
|
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
2013-07-04 03:17:08 +00:00
|
|
|
chart.useInteractiveGuideline = function(_) {
|
|
|
|
if(!arguments.length) return useInteractiveGuideline;
|
|
|
|
useInteractiveGuideline = _;
|
2013-07-05 02:18:02 +00:00
|
|
|
if (_ === true) {
|
2013-07-05 22:35:16 +00:00
|
|
|
chart.interactive(false);
|
|
|
|
chart.useVoronoi(false);
|
2013-07-05 02:18:02 +00:00
|
|
|
}
|
2013-07-04 03:17:08 +00:00
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
2012-06-15 16:47:47 +00:00
|
|
|
chart.tooltips = function(_) {
|
|
|
|
if (!arguments.length) return tooltips;
|
|
|
|
tooltips = _;
|
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
2013-07-04 03:17:08 +00:00
|
|
|
chart.tooltipContent = function(_) {
|
|
|
|
if (!arguments.length) return tooltip;
|
|
|
|
tooltip = _;
|
|
|
|
return chart;
|
|
|
|
};
|
2012-06-09 06:51:41 +00:00
|
|
|
|
2012-12-28 19:32:53 +00:00
|
|
|
chart.state = function(_) {
|
|
|
|
if (!arguments.length) return state;
|
|
|
|
state = _;
|
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
2013-04-04 19:45:26 +00:00
|
|
|
chart.defaultState = function(_) {
|
|
|
|
if (!arguments.length) return defaultState;
|
|
|
|
defaultState = _;
|
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
2012-07-27 21:37:20 +00:00
|
|
|
chart.noData = function(_) {
|
|
|
|
if (!arguments.length) return noData;
|
|
|
|
noData = _;
|
|
|
|
return chart;
|
|
|
|
};
|
|
|
|
|
2012-08-18 00:15:28 +00:00
|
|
|
//============================================================
|
|
|
|
|
2012-07-27 21:37:20 +00:00
|
|
|
|
2012-06-09 06:51:41 +00:00
|
|
|
return chart;
|
|
|
|
}
|