Home
Tutorials
Microsoft Technologies Tutorials
Java Programming Tutorials
Web Designing Tutorials
Script Programming Tutorials
Database Programming Tutorials
Mobile Technologies Tutorials
Other Programming Tutorials
Examples
Articles
Tools
News
Highcharts Bar with Negative Stack Chart Example
Keywords : How to show bar chart with negative stack using highcharts with example, Highcharts stacked bar with negative and positive values example, Use bar chart to show negative stack values example
Example
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Highcharts Bar with negative stack chart</title> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <script type="text/javascript"> $(function () { // Age categories var categories = ['0-4', '5-9', '10-14', '15-19', '20-24', '25-29', '30-34', '35-39', '40-44', '45-49', '50-54', '55-59', '60-64', '65-69', '70-74', '75-79', '80-84', '85-89', '90-94', '95-99', '100 + ']; var chartype = { type: 'bar' } var chartitle = { text: 'Population pyramid for Germany, 2015' } var chartsubtitle = { text: 'Source: <a href="http://populationpyramid.net/germany/2015/">Population Pyramids of the World from 1950 to 2100</a>' } var chartxaxis = [{ categories: categories, reversed: false, labels: { step: 1 } }, { // mirror axis on right side opposite: true, reversed: false, categories: categories, linkedTo: 0, labels: { step: 1 } }] var chartyaxis = { title: { text: null }, labels: { formatter: function () { return Math.abs(this.value) + '%'; } } } var chartplotoptions = { series: { stacking: 'normal' } } var chartooltip = { formatter: function () { return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' + 'Population: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0); } } var chartseries = [{ name: 'Male', data: [-2.2, -2.2, -2.3, -2.5, -2.7, -3.1, -3.2, -3.0, -3.2, -4.3, -4.4, -3.6, -3.1, -2.4, -2.5, -2.3, -1.2, -0.6, -0.2, -0.0, -0.0] }, { name: 'Female', data: [2.1, 2.0, 2.2, 2.4, 2.6, 3.0, 3.1, 2.9, 3.1, 4.1, 4.3, 3.6, 3.4, 2.6, 2.9, 2.9, 1.8, 1.2, 0.6, 0.1, 0.0] }] $('#container').highcharts({ chart:chartype, title: chartitle, subtitle:chartsubtitle, xAxis:chartxaxis, yAxis: chartyaxis, plotOptions: chartplotoptions, tooltip:chartooltip, series: chartseries }); }); </script> </head> <body> <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div> </body> </html>
Click Here to See Result
Result
Previous
Next