Timeline

Timelines are used to depict a sequence of events. This demo shows how you can use a simple <code>LineSeries</code> together with some states and data binding to implement a good looking Timeline. For down-to-the-bold details on how it is implement, please read our "<a href="https://www.amcharts.com/docs/v4/tutorials/creating-timeline-charts/">Creating Timeline Charts</a>" tutorial.

by navinleon

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>
<div style="text-align:center">
Totally it took <span style="background-color:green">13 hours</span> to onboard this customer
</div>

CSS

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

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: 350px;
}
g text + text tspan{
  font-size:12px;
}

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);

// Add data
chart.data = [{
  "x": "1",
  "y": 1,
  "text": "[bold]Trial requested[/]\n|\nRequested at: 10/20/19 10:20PM",
  "center": "bottom"
}, {
  "x": "2",
  "y": 1,
  "text": "[bold]Sales approved[/]\n|\n[bold]Response Time[/]: 2hours\nRequested at: 10/20 /19 10:20PM",
  "center": "top"
}, {
  "x": "3",
  "y": 1,
  "text": "[bold]Activation email sent[/]\n|\n[bold]Response Time[/]: 2hours\nRequested at: 10/20 /19 10:20PM",
  "center": "bottom"
}, {
  "x": "4",
  "y": 1,
  "text": "[bold]Customer onboarded[/]\n|\n[bold]Time took[/]: 2hours\nRequested at: 10/20 /19 10:20PM",
  "center": "top"
}];

// Create axes
var xAxis = chart.xAxes.push(new am4charts.CategoryAxis());
xAxis.dataFields.category = "x";
xAxis.renderer.grid.template.disabled = true;
xAxis.renderer.labels.template.disabled = true;
xAxis.tooltip.disabled = true;

var yAxis = chart.yAxes.push(new am4charts.ValueAxis());
yAxis.min = 0;
yAxis.max = 1.99;
yAxis.renderer.grid.template.disabled = true;
yAxis.renderer.labels.template.disabled = true;
yAxis.renderer.baseGrid.disabled = true;
yAxis.tooltip.disabled = true;


// Create series
var series = chart.series.push(new am4charts.LineSeries());
series.dataFields.categoryX = "x";
series.dataFields.valueY = "y";
series.strokeWidth = 4;
series.sequencedInterpolation = true;

var bullet = series.bullets.push(new am4charts.CircleBullet());
bullet.setStateOnChildren = true;
bullet.states.create("hover");
bullet.circle.radius = 10;
bullet.circle.states.create("hover").properties.radius = 15;

var labelBullet =...