Home forums Using CanvasJS Dynamically determine number of pie charts and display each one

This topic contains 1 reply, has 2 voices, and was last updated by  Shashi Ranjan 2 weeks, 4 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #27208

    I am hoping to construct an undetermined amount of pie charts and be able to display them alongside each other on a page. The number of pie charts generated will depend upon the number of elements in a JSON object. I have included an example of how my data will look below:

    
    [
      {
        "id" : "123",
        "data" : [20, 40, 10, 20, 10]
      },
      {
        "id" : "456",
        "data" : [10, 20, 20, 30, 20]    
      },
      {
        "id" : "789",
        "data" : [25, 35, 5, 10, 25]
      }
    ]
    

    I would like to have one pie chart for each element where there is an ‘id’ and ‘data’ attribute where ‘data’ will be used as the dataPoints in the pie charts for the ‘id’ which is included in the element. How can I achieve this?

    #27238

    @1alexritchie1,

    Parsing the data from JSON and passing it to chart-options should work fine in this case. Please take a look at this JSFiddle for the same.


    Shashi Ranjan
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.