Highcharts Tutorial
Chart Types
To create a basic column chart using Highcharts, you can follow these steps:
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="chart-container"></div>
var data = [5, 3, 4, 7, 2];
Or, here's an array of objects with 'name' and 'y' properties:
var data = [ { name: 'Apples', y: 5 }, { name: 'Oranges', y: 3 }, { name: 'Bananas', y: 4 }, { name: 'Pears', y: 7 }, { name: 'Grapes', y: 2 } ];
Highcharts.chart('chart-container', { chart: { type: 'column' }, title: { text: 'Basic Column Chart' }, xAxis: { type: 'category' }, yAxis: { title: { text: 'Value' } }, series: [{ name: 'Data', data: data }] });
Note that we're using the 'data' option to specify the data for the chart, and the 'xAxis' option to set the type of the x-axis to 'category'.
#chart-container { width: 100%; height: 500px; max-width: 800px; margin: 0 auto; }
This will create a basic column chart using the specified data and options, and render it in the 'chart-container' element on your web page. You can customize the chart further by adjusting the options and adding additional features, like tooltips, legends, and labels.
Customizing appearance in Highcharts Basic Column Chart:
Highcharts.chart('container', { chart: { type: 'column', backgroundColor: '#f2f2f2' }, plotOptions: { column: { color: '#64b4dc', // Column color borderWidth: 1, // Border width borderColor: '#3582c4', // Border color pointWidth: 20 // Column width } }, series: [{ data: [10, 15, 7, 22, 11] }], // Other configuration options... });
Adding data to Highcharts Basic Column Chart:
series
array to create a Basic Column Chart.Highcharts.chart('container', { chart: { type: 'column' }, series: [{ data: [10, 15, 7, 22, 11] }], // Other configuration options... });
Stacked Basic Column Chart in Highcharts:
stacking
option.Highcharts.chart('container', { chart: { type: 'column' }, plotOptions: { column: { stacking: 'normal' // Stack columns on top of each other } }, series: [{ name: 'Series 1', data: [10, 15, 7, 22, 11] }, { name: 'Series 2', data: [5, 10, 5, 15, 7] }], // Other configuration options... });
Grouped Basic Column Chart using Highcharts:
grouping
option.Highcharts.chart('container', { chart: { type: 'column' }, plotOptions: { column: { grouping: false // Display columns side by side } }, series: [{ name: 'Series 1', data: [10, 15, 7, 22, 11] }, { name: 'Series 2', data: [5, 10, 5, 15, 7] }], // Other configuration options... });
Interactive features in Highcharts Basic Column Chart:
Highcharts.chart('container', { chart: { type: 'column' }, plotOptions: { column: { dataLabels: { enabled: true, // Show data labels format: '{y}' // Data label format } } }, series: [{ data: [10, 15, 7, 22, 11] }], // Other configuration options... });