我正在使用dojo柱形图。我想添加一个在绘图上绘制的自定义线(某种阈值线)。 所以,让我们说y轴的范围从0到5.我想要一条水平线,比如4.2,在整个地块上运行。 这是一个柱形图。 我希望找到一些绘图API,可以帮助我在绘图上自定义绘图,但我无法弄清楚如何。我知道图表使用gfx和surface,所以如果我可以得到图表/图表面的句柄,也许我可以绘制一个自定义行?还需要数据来呈现坐标映射以实现这一目标
我当前的图表使用的代码如下:
var mychart = new dojox.charting.Chart2D("columns").
addAxis("x", {fixLower: "minor", fixUpper: "minor", natural: true,
font: "normal normal 10pt Arial",
labels: [{value: 1, text: "Q2 FY11"},
{value: 2, text: "Q3 FY11"},
{value: 3, text: "Q4 FY11"},
{value: 4, text: "Q1 FY12"}]
}).
addAxis("y", {vertical: true, includeZero: false, fixLower: "major", fixUpper: "major", min: 0, max: 5, font: "normal normal 10pt Arial", majorTick: {color: "black", length: 6}, minorTicks: false}).
addPlot("default", {type: "ClusteredColumns", tension: "S", shadows: {dx: 2, dy: 2}, gap: 5, minBarSize : 14, maxBarSize:24, animate: { duration: 1000, easing: dojo.fx.easing.linear} }).
addSeries("Series A", [{ y: 2.3, tooltip: "FFFF"}, { y: 3.5, tooltip: "GGGG"}]).
addSeries("Series B", [1.2, 2.5]);
答案 0 :(得分:3)
您可以使用其他图表渲染该线条。
new dojox.charting.Chart2D("columns").
addAxis("x", {fixLower: "minor", fixUpper: "minor", natural: true,
font: "normal normal 10pt Arial",
labels: [{value: 1, text: "Q2 FY11"},
{value: 2, text: "Q3 FY11"},
{value: 3, text: "Q4 FY11"},
{value: 4, text: "Q1 FY12"}]
}).
addAxis("y", {vertical: true, includeZero: false, fixLower: "major", fixUpper: "major", min: 0, max: 5, font: "normal normal 10pt Arial", majorTick: {color: "black", length: 6}, minorTicks: false}).
addPlot("default", {type: "ClusteredColumns", tension: "S", shadows: {dx: 2, dy: 2}, gap: 5, minBarSize : 14, maxBarSize:24, animate: { duration: 1000, easing: dojo.fx.easing.linear} }).
addSeries("Series A", [{ y: 2.3, tooltip: "FFFF"}, { y: 3.5, tooltip: "GGGG"}]).
addSeries("Series B", [1.2, 2.5]).
addPlot("threshold", { type: "Lines" }).
addSeries("threshold", [{x: 0, y: 4.2}, {x: 4, y: 4.2}], { plot: "threshold" }).
render();
答案 1 :(得分:0)
另一个简单示例将max_temperature表示为Lines,将Min_temperature表示为同一图表中的列:
var chart = new Chart("chartNode");
chart.addPlot("tempMaxPlot", {
type: "Lines",
markers: false
});
chart.addPlot("tempMinPlot", {
type: "Columns",
markers: true,
gap: 5
});
chart.addAxis("x");
chart.addAxis("y", { min: -3, max: 13, vertical: true, fixLower: "minor", fixUpper: "major" });
var chartData_tmax = [11,13,12,11,10,9,9,10];
chart.addSeries("tmax",chartData_tmax, { plot: "tempMaxPlot" });
var chartData_tmin = [1,1,2,1,0,-1,-1,0];
chart.addSeries("tmin",chartData_tmin, { plot: "tempMinPlot" });
chart.render();
答案 2 :(得分:0)
最后但并非最不重要的是,您可以通过gfx绘图功能手动绘制线条,如下所述: