* ---------------------------------------
* This demo was created using amCharts 5.
* For more information visit:
* https://www.amcharts.com/
* Documentation is available at:
* https://www.amcharts.com/docs/v5/
* ---------------------------------------
function createChart(div) {
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
var root = am5.Root.new(div);
// https://www.amcharts.com/docs/v5/concepts/themes/
root.setThemes([am5themes_Animated.new(root)]);
{ date: new Date(2012, 1, 1).getTime(), value: Math.round(Math.random() * 30) },
{ date: new Date(2012, 1, 2).getTime(), value: Math.round(Math.random() * 30) },
{ date: new Date(2012, 1, 3).getTime(), value: Math.round(Math.random() * 30) },
{ date: new Date(2012, 1, 4).getTime(), value: Math.round(Math.random() * 30) },
{ date: new Date(2012, 1, 5).getTime(), value: Math.round(Math.random() * 30) },
{ date: new Date(2012, 1, 6).getTime(), value: Math.round(Math.random() * 30) },
{ date: new Date(2012, 1, 7).getTime(), value: Math.round(Math.random() * 30) },
{ date: new Date(2012, 1, 8).getTime(), value: Math.round(Math.random() * 30) },
{ date: new Date(2012, 1, 9).getTime(), value: Math.round(Math.random() * 30) },
{ date: new Date(2012, 1, 10).getTime(), value: Math.round(Math.random() * 30) },
{ date: new Date(2012, 1, 11).getTime(), value: Math.round(Math.random() * 30) }
// https://www.amcharts.com/docs/v5/charts/xy-chart/
var chart = root.container.children.push(
am5xy.XYChart.new(root, {
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
var xAxis = chart.xAxes.push(
am5xy.DateAxis.new(root, {
renderer: am5xy.AxisRendererX.new(root, {
tooltip: am5.Tooltip.new(root, {})
var yAxis = chart.yAxes.push(
am5xy.ValueAxis.new(root, {
renderer: am5xy.AxisRendererY.new(root, {})
// https://www.amcharts.com/docs/v5/charts/xy-chart/series/
var series = chart.series.push(
am5xy.LineSeries.new(root, {
tooltip: am5.Tooltip.new(root, {
pointerOrientation: "horizontal",
series.data.setAll(data);
series.bullets.push(function () {
return am5.Bullet.new(root, {
sprite: am5.Circle.new(root, {
fill: series.get("fill"),
stroke: root.interfaceColors.get("background"),
// https://www.amcharts.com/docs/v5/charts/xy-chart/cursor/
am5xy.XYCursor.new(root, {
cursor.lineY.set("visible", false);
am5.Scrollbar.new(root, {
orientation: "horizontal"
// Make stuff animate on load
// https://www.amcharts.com/docs/v5/concepts/animations/
series.appear(1000, 100);
xAxis.on("start", function () {
xAxis.on("end", function () {
chartsToSync.push(createChart("chartdiv1"));
chartsToSync.push(createChart("chartdiv2"));
chartsToSync.push(createChart("chartdiv3"));
am5.array.each(chartsToSync, function (sourceChart) {
am5.array.each(chartsToSync, function (targetChart) {
if (targetChart !== sourceChart) {
syncCursors.push(targetChart.get("cursor"));
sourceChart.get("cursor").set("syncWith", syncCursors);
function syncAxes(targetChart) {
var targetAxis = targetChart.xAxes.getIndex(0);
if (targetAxis._skipSync != true) {
var start = targetAxis.get("start");
var end = targetAxis.get("end");
am5.array.each(chartsToSync, function (chart) {
if (chart != targetChart) {
var axis = chart.xAxes.getIndex(0);