2015-02-23 39 views
0

我有一個web服務,從中解析數據並繪製條形圖。我正在使用morris.js庫。使用morris進行json響應的動態條形圖

問題: 我有這樣一個Web服務:

http://localhost:9999/hellowebservice/search?select= *

在選擇查詢參數,我通過我想要搜索類似的值:

http://localhost:9999/hellowebservice/search?select=x,y

JSON響應是類似下面的東西:

"hits" : { 
    "total" : 2, 
    "max_score" : 1.0, 
    "hits" : [ { 
     "_id" : "abcd", 
     "_score" : 1.0, 
     "fields" : { 
     "x" : [ "10" ], 
     "y : [ "20" ] 
     } 
    }] 
    } 
} 

當我在選擇字段下一次進入x, y, z,我想自動更新基於輸入字段條形圖

注:我m使用_id值在x軸上,無論選擇值是在y軸上輸入。

回答

1

找到的解決方案:

帶有虛擬值的已初始化的morris圖表。 然後使用morrisChart.setData()方法來動態更新圖表。