1
votes

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

        });
1

1 Answers

1
votes

It looks like your json object structure is invalid for charting. It would be better use the following structure:

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

and creating chart:

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

        });

View source of this page - here working example.
Read good article about chart building - introducing-dojox-datachart

EDIT: Also look this page. I think it will be very helpful for you.