My chart has lines which are quite close together, but still need to be differentiated in the legend. There are a few hundred datapoints for this line charts, so when I use pointstyle to differentiate them I get the following result:
chart with overdense point styles
The points are only readable in the very vertical parts of the graph. How can I make the markers evenly spaced?
I’ve used scriptable options with radius to only turn on ever nth point, but then I am left with underdense areas when the points have large vertical gaps:
chart with some underdense areas
I’ve tried to use dash-style to differentiate them, but that has been quite unreadable:[
chart with different dash styles](https://i.sstatic.net/BQDeHTzu.png)
My attempt at enabling points based on the distance to the previously enabled point failed because I wasn’t able to figure out how to access the radii of other points in the graph:
New Chart(
{options: {
elements: {
point: {
radius: spacePoints
}
}
}}
)
function spacePoints (context){
var POINT_SPACING = 10
var data = context.dataset.data
var x = context.parsed.x
var y = context.parsed.y
// iterate backwards through previous points
for (let i = context.dataIndex-1; i>=0; i--){
var point = data[i]
// when you find the previous point in the graph that has been "enabled"
if (point.radius != 0){ // <--- PROBLEM: `point` only has x and y values, not point options
//^^^^^^^^^^^^^^^^^^^
var absoluteXDist = (x-point.x) /15*900 //factor at the end to compensate for scale bounds and width on screen
var absoluteYDist = (y-point.y) /100*380
var distance = Math.sqrt(absoluteXDist ** 2 + absoluteYDist ** 2)
if (distance > POINT_SPACING){
return 8
}
else{
return 0
}
}
}
}