Been looking for a solution to this with either chartist or chart.js, but keep coming up empty. I'm looking for a way to create a line graph and change the color of the line based on the data.
Example data set:
[
{time: '3:00:00', speed: 20, direction: 345},
{time: '3:01:00', speed: 0, direction: 0},
{time: '3:02:00', speed: 25, direction: 90},
{time: '3:03:00', speed: 10, direction: 180},
{time: '3:04:00', speed: 5, direction: 0}
]
I'm looking for the time to be the x axis, the speed to be the y axis, and then to change the color of the line segment based on the direction. Seems like most of the charting libraries (unless I start digging into d3) when they create line graphs create one big line for the whole series and doesn't let you style the individual segments of the line. There's a great chartjs example here, but the color isn't based on the data (it's just an arbitrary set of colors):
https://blog.vanila.io/chart-js-tutorial-how-to-make-gradient-line-chart-af145e5c92f9