Instead of manually creating the series array, you could iterate over the data in the sales variable and build the array. So, how many elements in the sales.SalesData array sales.SalesData all elements be present in the series array
var series = [], salesData= sales.SalesData; for (var i=0 i< salesData.length; i++) { series.push({"name" : key, "data" : sales[key]}) }
This constructed series array is part of the object that you must pass as an argument to the highcharts method.
var chartdata = { chart: {type: 'column'}, title: {text: 'Sales Data'}, xAxis: { categories: ['Category 1','Category 2'] }, yAxis: { min: 0, title: {text: 'Sales'} }, series : [] } chartdata.series = series; $('#chart').highcharts(chartdata);
where #chart is the container in which you want to display the chart.
You can also refer to the scripts that are available on your demo pages for each type of chart to learn more about how to display a specific type of chart.
source share