使用Dojo在xAxis中显示月份

时间:2010-09-08 15:25:39

标签: charts dojo dojox.charting

我有这些数据:

{ "identifier": "id", "idAttribute":"id", "label": "date",
   "items": [
          { "id":1,
             "name":"index",
             "point":[{"id":1,"num":17, "date":"2009-02-01"},
                      {"id":2,"num":10, "date":"2009-06-01"}
                      ]},
           { "id":2,
             "name":"high",
             "point":[{"id":1,"num":11, "date":"2009-01-01"},
                     {"id":2,"num":19, "date":"2009-09-01"}
                     ]},
           { "id":3,
             "name":"low",
             "point":[{"id":1,"num":14, "date":"2009-07-01"},
                      {"id":2,"num":20, "date":"2009-03-01"}
                     ]}
            ]}

我想在此图表中显示它。 另外,我不知道如何将月份日期放在标签中。

dojo.require(”dojox.charting.DataChart”);
dojo.require(”dojo.data.ItemFileWriteStore”);
dojo.addOnLoad(function() {

dojo.require("dojox.charting.DataChart");
 dojo.require("dojo.data.ItemFileWriteStore");
 dojo.addOnLoad(function() {

    var store = new dojo.data.ItemFileWriteStore({
       url: "exemple_stock.json"
    });
    chart = new dojox.charting.DataChart("chartDiv" ,{ displayRange:12,
    xaxis:{labels:["0", "Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"]},
    yaxis:{max:100,min:0, majorTickStep:10, maxLabelSize:30},
    type: dojox.charting.plot2d.Lines
 });

    chart.setStore(store, {symbol:"*"}, "point");  //  <-- single value property
 });

1 个答案:

答案 0 :(得分:0)

我不知道如何使用DataChart,但是常规的Dojo图表可以毫无问题地执行任何类型的标记:http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_labels2d.html

如果您需要使用dojo.data商店作为数据源,请考虑将DataSeries与常规图表一起使用: