1

I'm wonder is it possible to proper setting each xaxis in dojox.charting.DataChart

here is my data.JSON for example:

{ 
  "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}] }
       ]
}

and trying to draw xaxis which failed(show empty in xaxis) with below code:

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");

        });
4

1 回答 1

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");

        });

查看此页面的源代码 - 这里是工作示例
阅读有关图表构建的好文章 - Introduction-dojox-datachart

编辑: 也看看这个页面。我认为这对你会很有帮助。

于 2011-04-25T11:02:45.397 回答