Struggling to dynamically set colors in a chartist graph using JavaScript. How can custom colors be applied through JS? The attempted method below is not successfully changing the color for the showArea in the chartist graph.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Chartist</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="chartist.min.css">
<style>
.ct-series-a .ct-area, .ct-series-a .ct-slice-donut-solid, .ct-series-a .ct-slice-pie{
fill: #4287f5;
fill-opacity:0.5;
stroke: #4287f5;
}
</style>
</head>
<body>
<div class="ct-chart" id="chart"></div>
<div class="ct-barchart"></div>
<script type="text/javascript" src="chartist.min.js"></script>
<script>
var data = "[49,71,87,135,63]";
var parsedData = JSON.parse(data);
var chart = new Chartist.Line('.ct-chart', {
labels: [1, 2, 3, 4],
series: [
parsedData
]
}, {
showPoint: false,
showLine: false,
showArea: true,
fullWidth: true,
showLabel: false,
axisX: {
showGrid: false,
showLabel: false,
offset: 0
},
axisY: {
showGrid: false,
showLabel: false,
offset: 0
},
chartPadding: 0,
low: 0
});
function functioncall(){
var ta = document.getElementsByClassName('.ct-series .ct-series-a');
ta[0].style.stroke = "#95f27e";
}
functioncall();
</script>
</body>
</html>
Managed to change the color only via the style tag, but looking to achieve this through JavaScript.