开发者

Display months in xAxis with Dojo

开发者 https://www.devze.com 2023-01-15 21:52 出处:网络
I have this data : { \"identifie开发者_运维百科r\": \"id\", \"idAttribute\":\"id\", \"label\": \"date\",

I have this data :

{ "identifie开发者_运维百科r": "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"}
                     ]}
            ]}

I want to display it in this chart. Also, I don’t know how can I put the month’s date in the labels.

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


I don't know how to do it with DataChart, but regular Dojo charts can do any kind of labels without problems: http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_labels2d.html

If you need to use a dojo.data store as your data source, consider using DataSeries with regular charts:

  • http://docs.dojocampus.org/dojox/charting#using-dojo-data-data-sources-with-charts
  • http://dojotoolkit.org/api/dojox/charting/DataSeries.html
  • http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_DataSeries.html
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号