我使用记录的barChartPlotter()绘制条形图,但有时我想绘制默认折线图。
如何定义" defaultChartPlotter"这样我可以画出来吗?
g.updateOptions({
'file': dataToday, title: graphTitle, dateWindow: newDateWindow,
ylabel: yAxisType,
plotter: generalChartPlotter
}
});
function generalChartPlotter(e) {
if(myChartTypeFlag=="BAR")
return barChartPlotter(e);
else
return defaultChartPlotter(e);
}
function defaultChartPlotter(e) {
//What do I put here to get line default chart?
}
function barChartPlotter(e) {
var ctx = e.drawingContext;
var points = e.points;
var y_bottom = e.dygraph.toDomYCoord(0);
ctx.fillStyle = darkenColor(e.color);
// Find the minimum separation between x-values.
// This determines the bar width.
var min_sep = Infinity;
for (var i = 1; i < points.length; i++) {
var sep = points[i].canvasx - points[i - 1].canvasx;
if (sep < min_sep) min_sep = sep;
}
var bar_width = Math.floor(2.0 / 3 * min_sep);
// Do the actual plotting.
for (var i = 0; i < points.length; i++) {
var p = points[i];
var center_x = p.canvasx;
ctx.fillRect(center_x - bar_width / 2, p.canvasy,
bar_width, y_bottom - p.canvasy);
ctx.strokeRect(center_x - bar_width / 2, p.canvasy,
bar_width, y_bottom - p.canvasy);
}
}
答案 0 :(得分:2)
这似乎是默认值:
Dygraph.Plotters.linePlotter(e);