Divergent stacked bars
by alcosbarco
HTML
<script src="https://cdn.amcharts.com/lib/4/core.js"></script>
<script src="https://cdn.amcharts.com/lib/4/charts.js"></script>
<script src="https://cdn.amcharts.com/lib/4/themes/animated.js"></script>
<div id="chartdiv"></div>
CSS
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
#chartdiv {
width: 100%;
height: 500px;
}
JavaScript
/**
* ---------------------------------------
* This demo was created using amCharts 4.
*
* For more information visit:
* https://www.amcharts.com/
*
* Documentation is available at:
* https://www.amcharts.com/docs/v4/
* ---------------------------------------
*/
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
// Create chart instance
var chart = am4core.create("chartdiv", am4charts.XYChart);
// Title
var title = chart.titles.push(new am4core.Label());
title.text = "Research tools used by students";
title.fontSize = 25;
title.marginBottom = 15;
// Add data
chart.data = [{
"category": "Search engines",
"negative1": -0.1,
"negative2": -0.9,
"positive1": 5,
"positive2": 94
}, {
"category": "Online encyclopedias",
"negative1": -2,
"negative2": -4,
"positive1": 19,
"positive2": 75
}, {
"category": "Peers",
"negative1": -2,
"negative2": -10,
"positive1": 46,
"positive2": 42
}, {
"category": "Social media",
"negative1": -2,
"negative2": -13,
"positive1": 33,
"positive2": 52
}, {
"category": "Study guides",
"negative1": -6,
"negative2": -19,
"positive1": 34,
"positive2": 41
}, {
"category": "News websites",
"negative1": -3,
"negative2": -23,
"positive1": 49,
"positive2": 25
}, {
"category": "Textbooks",
"negative1": -5,
"negative2": -28,
"positive1": 49,
"positive2": 18
}, {
"category": "Librarian",
"negative1": -14,
"negative2": -34,
"positive1": 37,
"positive2": 16
}, {
"category": "Printed books",
"negative1": -9,
"negative2": -41,
"positive1": 38,
"positive2": 12
}, {
"category": "Databases",
"negative1": -18,
"negative2": -36,
"positive1": 29,
"positive2": 17
}, {
"category": "Student search engines",
"negative1": -17,
"negative2": -39,
"positive1": 34,
"positive2": 10
}];
// Create axes
var categoryAxis = chart.yAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category =...