Vamsi
Vamsi

Reputation: 878

Dynamic bar charts from json response using morris

I have a webservice from which I parse data and plot bar charts. I'm using morris.js library.

Problem: I have a webservice like this:

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

At select query parameter, I pass the values which I want to search like:

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

the json response is something like below:

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

When I enter x, y, z in the select field next time, I want the bar charts to be automatically updated based on the entered fields

NOTE: I'm using _id value to be on x-axis and whatever select values entered to be on y axis.

Upvotes: 0

Views: 417

Answers (1)

Vamsi
Vamsi

Reputation: 878

Found solution:

Initialized morris chart with dummy values. And then used morrisChart.setData() method to dynamically update the chart.

Upvotes: 1

Related Questions