3

我正在使用道场柱形图。我想添加一条在绘图上绘制的自定义线(某种阈值线)。所以,假设 y 轴的范围从 0 到 5。我想要一条水平线,比如说,4.2 穿过图。它是一个柱形图。我希望找到一些绘图 API 可以帮助我在绘图上进行自定义绘图,但我无法弄清楚如何。我知道图表使用 gfx 和表面,所以如果我可以处理图表/绘图表面,也许我可以画一条自定义线?还需要数据来渲染坐标映射以实现这一点

我当前的图表使用如下代码:

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]);
4

3 回答 3

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();
于 2012-03-29T13:16:24.617 回答
1

在同一图表中将 max_temperature 表示为 Lines 并将 Min_temperature 表示为 Columns 的另一个简单示例:

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();
于 2013-02-19T16:16:13.763 回答
0

最后但并非最不重要的一点是,您可以使用 gfx 绘图函数手动绘制一条线,如下所述:

向道场图表添加一条线(不是系列)

于 2013-07-23T10:29:48.710 回答