0

i have this service that give back this Json result :

{
"MANNOUBA": 1,
"Medinine": 4,
"Gabes": 5,
"Tunis": 22,
"Beja": 3,
"Kebili": 0,
"Sfax": 11,
"Laundry Making": 6,
"italia": 0,
"Sousse": 6,
"Desk": 1,
"Jendouba": 3,
"Mahdia": 6,
"Ben Arous": 19,
"Zaghouan": 4,
"Gafsa": 0,
"Kairouan": 6,
"Monastir": 18,
"metos": 1,
"Eleonetech": 2,
"Nabeul": 22,
"Mannouba": 9,
"BENAROUS": 8,
"Ariana": 21,
"Bizerte": 3

}

i want to put this data in a Barchart For my angular Project with the names in the X axis and the Numbers in the Y axis

1 Answers1

0

With using Highcharts, you can preprocess your data to the: [name, y] format and use category axis type. Example:

for (let key in data) {
    chartData.push([key, data[key]]);
}

Highcharts.chart('container', {
    xAxis: {
        type: 'category'
    },
    series: [{
        type: 'column',
        data: chartData
    }]
});

Live demo: http://jsfiddle.net/BlackLabel/cjk3uboh/

Highcharts angular wrapper: https://www.npmjs.com/package/highcharts-angular

ppotaczek
  • 36,341
  • 2
  • 14
  • 24