2011-04-25 81 views
1

我納悶的是,可以適當設定在dojox.charting.DataChartDojoX中數據圖表X軸

這裏每個x軸是我的例子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}] } 
     ] 
} 

,並試圖得出x軸其中失敗(顯示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

它看起來像你的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頁。我認爲這對你很有幫助。