I am working on a Angular 5 application where I am asked to use highcharts and display some information on pie charts and bar charts. The data that I get from the web api call is in json format and looks like:
[
{
"fruit": "Orange",
count: 10
},
{
"fruit": "Strawberry",
count: 20
}
]
The following is the sample code of my pie chart:
this.chart = new Chart({
chart: {
type: 'pie'
},
title: {
text: 'Available Fruits'
},
credits: {
enabled: false
},
series : [{
name: 'Line 1',
data: [10, 20, 30, 40]
}]
});
So this data is dynamic and I want to pass this data as input to the pie chart.I also want a similar one to be displayed as a bar chart. The charts should be rendered once the web api calls return me this data. Could you please let me know how I could implement this functionality.
Note: the data value in the chart object is just temporary value and I need this value to be the json data returned from the web api.