2017-03-02 55 views
-2

我在django項目中使用了chartit。 我有一個模型(ReadingSensor)具有以下屬性:用Django中的chartit創建多個(兩個)源代碼

  • id_sensor
  • DATE_TIME

我想創建幾行線圖的不同id_sensors

例如:

ReadingSensor.objects.filter(id_sensor=2) ReadingSensor.objects.filter(id_sensor=1)

對於單一模式有:

ds = DataPool(
     series= 
     [{'options': { 
      'source': MonthlyWeatherByCity.objects.all()}, 
      'terms': [ 
      'month', 
      'houston_temp', 
      'boston_temp']} 
     ]) 


cht = Chart(
     datasource = ds, 
     series_options = 
      [{'options':{ 
       'type': 'line', 
       'stacking': False}, 
      'terms':{ 
       'month': [ 
       'boston_temp', 
       'houston_temp'] 
       }}], 
     chart_options = 
      {'title': { 
       'text': 'Weather Data of Boston and Houston'}, 
      'xAxis': { 
       'title': { 
        'text': 'Month number'}}}) 

文檔:http://chartit.shutupandship.com/docs/

我諮詢的文件,但沒有發現任何提示例子來幫助我。 有人可以幫我嗎?

+0

請把你的代碼! –

+0

我現在加了。抱歉 – roliveira

回答

0

事實上的例子是,你在網站上提供,請檢查此鏈接:http://chartit.shutupandship.com/demo/chart/multi-table-same-x/

的想法只是與optionsterms添加更多的項目到series列表構建DataPool對象時,調整termsseries_options當相應地構造對象時。

那麼你會發現它是有用的,爲的情況下調整字段名時,兩個數據源具有相同名稱的字段,關於這個問題的詳細的文檔是在這裏:http://chartit.shutupandship.com/docs/apireference.html#datapool