Dojox数据图表xaxis

时间:2011-04-25 08:01:43

标签: dojo dojox.charting

我很想知道在dojox.charting.DataChart中正确设置每个xax是否可能

这是我的data.JSON例如:

{ 
  "label": "btmlabel",
  "items": [
        { "mydata":"ANDT", "btmlabel":[{value: 1, text: "22 April 10.34AM"},{value: 2, text: "22 April 10.40AM"}], "data":[{"x":1,"y":1},{"x":2,"y":3}] }
       ]
}

并尝试使用以下代码绘制失败的xaxis(在xaxis中显示为空):

var chartPrefs = {
            chartPlot: {type:dojox.charting.plot2d.Markers, tension:"S"},
            scroll:true,
            xaxis:{labelFunc:"seriesLabels"},
        }

        chart = new dojox.charting.DataChart("chartNode", chartPrefs);
        chart.setStore(store, {mydata:"*"}, "data");

        });

1 个答案:

答案 0 :(得分:1)

看起来您的json对象结构对于图表无效。最好使用以下结构:

var storeData = {
    "label": "btmlabel",
    "items":
        [
           {
              "btmlabel": "22 April 10.34AM",
              "data": 1
           },
           {
              "btmlabel": "22 April 10.40AM",
              "data": 3
           }
        ]
    }

并创建图表:

dojo.addOnLoad(function () {
            var storeForChart = new dojo.data.ItemFileWriteStore({ data: storeData });

            var chartPrefs = {
                chartPlot: { type: dojox.charting.plot2d.Markers, tension: "S" },
                comparative: true,
                xaxis: { labelFunc: "seriesLabels" }
            }
            chart = new dojox.charting.DataChart("chartNode", chartPrefs);
            chart.setStore(storeForChart, { data: "*" }, "data");

        });

查看此页面的来源 - 此处working example
阅读有关图表构建的好文章 - introducing-dojox-datachart

修改  另请查看this页面。我认为这对你很有帮助。