JSFiddle - React, Tailwind, and code Playground
by ashishsingh
HTML
<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.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: 450px;
}
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
var chart = am4core.create("chartdiv", am4charts.XYChart);
chart.data = [{
"name": "2014",
"startTime": 4,
"endTime": 8,
"step": 6.5,
"color": "#A0C23A"
}, {
"name": "2015",
"startTime": 5.5,
"endTime": 7,
"step": 6.2,
"color": "#A0C23A"
}];
var categoryAxis = chart.yAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = "name";
categoryAxis.renderer.inversed = true;
/* categoryAxis.renderer.grid.template.location = 0; */
categoryAxis.renderer.grid.template.disabled = true;
categoryAxis.renderer.maxGridDistance = 20;
var valueAxis = chart.xAxes.push(new am4charts.ValueAxis());
valueAxis.renderer.minGridDistance = 50;
valueAxis.renderer.grid.template.disabled = true;
var columnSeries = chart.series.push(new am4charts.ColumnSeries());
columnSeries.dataFields.categoryY = "name";
columnSeries.dataFields.valueX = "endTime";
columnSeries.dataFields.openValueX = "startTime";
columnSeries.columns.template.tooltipText = "[bold]{categoryY}[/]\nstarts at {openValueX}\nends at {valueX}";
columnSeries.hiddenInLegend = true;
var columnTemplate = columnSeries.columns.template;
columnTemplate.strokeOpacity = 0;
columnTemplate.fillOpacity = 0.5;
columnTemplate.propertyFields.fill = "color";
columnTemplate.height = am4core.percent(30);
var stepSeries = chart.series.push(new am4charts.StepLineSeries());
stepSeries.noRisers = true;
stepSeries.stacked = false;
stepSeries.strokeWidth = 4;
stepSeries.stroke = '#88AC3E';
stepSeries.name = "MAPE";
stepSeries.dataFields.categoryY = "name";
stepSeries.dataFields.valueX = "step";
stepSeries.autoGapCount = 0;
stepSeries.height =...