JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css">
<div>
<div id="chartContainer" style="height: 360px; width: 100%;"></div>
<div id = "slider"></div>
</div>
CSS
#slider {
margin-left: 45px;
margin-right: 10px;
}
#slider .ui-slider-handle {
width: 15px !important;
}
JavaScript
var lastValue = 0;
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "Basic Column Chart"
},
data: [{
color: "gray",
dataPoints: [
{ x: 10, y: 71 },
{ x: 20, y: 55},
{ x: 30, y: 50 },
{ x: 40, y: 65 },
{ x: 50, y: 95 },
{ x: 60, y: 68 },
{ x: 70, y: 28 },
{ x: 80, y: 34 },
{ x: 90, y: 14},
{ x: 100, y: 71 },
{ x: 110, y: 55},
{ x: 120, y: 50 },
{ x: 130, y: 65 },
{ x: 140, y: 95 },
{ x: 150, y: 68 },
{ x: 160, y: 28 },
{ x: 170, y: 34 },
{ x: 180, y: 14},
{ x: 190, y: 71 },
{ x: 200, y: 55},
{ x: 210, y: 50 },
{ x: 220, y: 50 },
{ x: 230, y: 65 },
{ x: 240, y: 95 },
{ x: 250, y: 68 },
{ x: 260, y: 28 },
{ x: 270, y: 34 },
{ x: 280, y: 14}
]
}]
});
chart.render();
$(function() {
$( "#slider" ).slider({
animate:"fast",
max: chart.options.data[0].dataPoints.length - 1,
orientation: "horizontal",
slide: function( event, ui ) {
for(var i = 0; i < chart.options.data[0].dataPoints.length; i++) {
chart.options.data[0].dataPoints[i].color = chart.options.data[0].color;
}
chart.options.data[0].dataPoints[ui.value].color = "red";
chart.render();
}
});
chart.options.data[0].dataPoints[$("#slider").slider("value")].color = "red";
chart.render();
});