JSFiddle - React, Tailwind, and code Playground
amCharts Comparison Micro Chart
by ashishsingh
HTML
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv"></div>
CSS
#chartdiv {
width: 500px;
height: 155px;
}
JavaScript
var chart = AmCharts.makeChart( "chartdiv", {
"type": "serial",
"theme": "light",
"categoryField": "categoryDimension",
"rotate": true,
"startDuration": 1,
"categoryAxis": {
"gridPosition": "start",
"position": "left",
"gridPosition": "start",
"axisAlpha": 0,
"gridAlpha": 0,
"position": "left"
},
"columnSpacing": 0,
"columnWidth": 1,
"autoMargins": false,
"marginLeft": 0,
"marginRight": 5,
"marginTop": 0,
"marginBottom": 0,
"graphs": [ {
/**
* These two graphs are just here for labels
* They're basically invisible, save for the label itself,
* but underneath they're just stacked column graphs
*/
"valueAxis": "background",
"labelText": "[[categoryDimension]]",
"labelPosition": "left",
"labelOffset": -3,
"labelAnchor": "start",
"fontSize": 12,
"fillAlphas": 0,
"lineAlpha": 0,
"type": "column",
"columnWidth": 1,
"valueField": "labelLeft",
"fixedColumnWidth": '14px',
"showBalloon": false,
"visibleInLegend": false
}, {
"valueAxis": "background",
"labelText": "[[measureValue]]",
"labelPosition": "right",
"labelOffset": 0,
"labelAnchor": "end",
"fontSize": 12,
"fillAlphas": 0,
"lineAlpha": 0,
//"title": "Expenses",
"type": "column",
"columnWidth": 1,
"valueField": "labelRight",
"showBalloon": false,
"visibleInLegend": false
}, {
"newStack": true,
"valueAxis": "background",
"showBalloon": false,
"fillAlphas": 0.8,
"lineAlpha": 0,
"fillColors": "#D5DADC",
"type": "column",
"columnWidth": 0.4,
"valueField": "backgroundLeft"
}, {
/**
* We start a new stack with this graph
*/
"valueAxis": "background",
"balloonText": "Value:[[value]]",
"fillAlphas": 0.8,
"lineAlpha": 0,
"fillColors": "#84B761",
"negativeFillColors": "#CC4748",
"type": "column",
"columnWidth": 0.4,
"valueField": "measureValue"
},...