Highcharts Tutorial
Chart Types
To create a rotated column chart with rotated labels using Highcharts, you can follow these steps:
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="chart-container"></div>
Highcharts.chart('chart-container', { chart: { type: 'column', events: { load: function() { var chart = this; chart.renderer.text('X Axis Label', chart.plotLeft + chart.plotWidth / 2, chart.plotTop + chart.plotHeight + 35) .attr({ align: 'center' }) .add(); } } }, title: { text: 'Rotated Column Chart with Rotated Labels' }, xAxis: { categories: ['Category 1', 'Category 2', 'Category 3', 'Category 4', 'Category 5'], labels: { rotation: -45, align: 'right', style: { fontSize: '13px', fontFamily: 'Verdana, sans-serif' } } }, yAxis: { min: 0, title: { text: 'Values' } }, legend: { enabled: false }, series: [{ name: 'Series 1', data: [5, 7, 3, 6, 4] }] });
In this example, we're creating a rotated column chart with the Highcharts chart
function and passing in a set of options:
chart.type
is set to 'column'
to create a column chartchart.events.load
is used to add a custom x-axis label to the chart. We're using the chart.renderer.text
method to create the label as an SVG text element, and positioning it at the bottom of the chart.title.text
is set to 'Rotated Column Chart with Rotated Labels'
to set the main titlexAxis.categories
is set to an array of category labels for the x-axisxAxis.labels.rotation
is set to -45
to rotate the x-axis labels by 45 degrees counterclockwisexAxis.labels.align
is set to 'right'
to align the labels with the right edge of the columnxAxis.labels.style
is used to set the font size and family for the labelsyAxis.min
is set to 0
to set the minimum value of the y-axisyAxis.title
is set to set the label for the y-axislegend.enabled
is set to false
to disable the legendseries
is set to an array of objects with a name
and data
property to define the series dataWith these options, you can create a rotated column chart with rotated labels and customizable data and appearance.
Customizing appearance in Highcharts Rotated Label Column Chart: To customize the appearance of a Rotated Label Column Chart in Highcharts, you can use options like colors, borders, and more. Here's an example code snippet:
Highcharts.chart('container', { chart: { type: 'column' }, plotOptions: { column: { color: 'skyblue', borderColor: 'white', borderWidth: 2 } }, series: [{ name: 'Data', data: [10, 15, 20, 25, 30] }] });
Adding data to Highcharts Label Rotated Column Chart:
To add data to the Label Rotated Column Chart, you can use the data
property within the series
object. Here's an example:
series: [{ name: 'Data', data: [10, 15, 20, 25, 30] }]
Highcharts Label Rotation configuration options:
For rotating labels, use the xAxis.labels.rotation
property in the chart configuration. Here's an example:
xAxis: { categories: ['Category 1', 'Category 2', 'Category 3', 'Category 4', 'Category 5'], labels: { rotation: -45 } }
Rotated Label Stacked Column Chart in Highcharts:
To create a Rotated Label Stacked Column Chart, use the stacking
property in the plot options. Here's an example:
plotOptions: { column: { stacking: 'normal' } }, series: [{ name: 'Category 1', data: [10, 15, 20, 25, 30] }, { name: 'Category 2', data: [5, 10, 15, 20, 25] }]
Grouped Rotated Label Column Chart using Highcharts:
To create a grouped Rotated Label Column Chart, omit the stacking
property. Here's an example:
plotOptions: { column: { // No stacking property for grouped chart } }, series: [{ name: 'Category 1', data: [10, 15, 20, 25, 30] }, { name: 'Category 2', data: [5, 10, 15, 20, 25] }]
Interactive features in Highcharts Label Rotated Column Chart: Highcharts supports interactive features like tooltips, click events, and legends. You can enable these features to enhance user interaction. Here's a snippet for tooltip configuration:
tooltip: { pointFormat: 'Value: {point.y}' }