【问题标题】:dojo charting with multiple axis多轴道场制图
【发布时间】:2013-07-29 11:00:15
【问题描述】:

我正在尝试创建一个折线图,其中一些系列显示在 LHS 轴(“y”)上,一些系列显示在 RHS 轴上(“其他 y”):

//Init chart and set theme
var myChart = new Chart("graphDiv")
myChart.setTheme(theme)

//Add plot for LHS axis
myChart.addPlot("default", {
    type: Lines,
    markers: true,
    hAxis: "x",
    vAxis: "y"
})

//Add additional plot for RHS axis
myChart.addPlot("other", {
    type: Lines,
    markers: true,
    hAxis: "x",
    vAxis: "other y"
})

//Add axis
myChart.addAxis("x", {
    fixUpper: "major",
    fixLower:"minor"
})
myChart.addAxis("y", {
    title: "Y Axis Left",
    vertical: true,
    fixUpper: "major",
    fixLower:"minor"
})
myChart.addAxis("other y", {
    title: "Y Axis Right",
    vertical: true,
    leftBottom: false,
    fixUpper: "major",
    fixLower:"minor",
})

//Add the data
myChart.addSeries('test1',[{x:1,y:2},{x:2,y:2},{x:3,y:2},{x:4,y:2}],{plot:'default'})
myChart.addSeries('test2',[{x:1,y:3},{x:2,y:3},{x:3,y:3},{x:4,y:3}],{plot:'default'})
myChart.addSeries('test3',[{x:1,'other y':5},{x:2,'other y':5},{x:3,'other y':5}, x:4,'other y':5}],{plot:'other'})
myChart.render()

第二个轴未渲染,第二个绘图(“其他”)的数据未渲染。但是,如果我 console.log(myChart) 我可以在 myChart.series 中看到所有数据都在那里!控制台窗口没有错误,我使用的是 Dojo 1.9 和 chrome。

任何想法我做错了什么?

【问题讨论】:

    标签: dojo dojox.charting


    【解决方案1】:

    将您的数据字段“other y”设置为“y”,就像在其他图中一样。该属性对应于 x 或 y 轴,而不是轴名称。即你的第三个系列应该是:

    myChart.addSeries('test3',[{x:1,y:5},{x:2,y:5},{x:3,y:5}, {x:4,y:5}],{plot:'other'})
    

    我在这个例子中为这个系列制作了动画,所以它很突出:http://jsfiddle.net/psoares/nYtAg/

    【讨论】:

    • 请注意,通过在定义第二个轴时删除 max 和 min 参数,这会导致轴不被渲染。这是一个错误吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多