Hi,
I'm using jqChart v.4.0.0.0 for jQuery and plotting line charts only.
When there are ~10 lines plotted at once, it becomes hard to tell which series corresponds to which legend item, because the legend markers for Chart.Series.Line represent a thin horizontal dash. Telling the color of this dash is sometimes difficult, especially when there are many of those stacked in a row.
Is there a way to globally cofigure the legend markers of Chart.Series.Line be of a different shape, e.g. a circle?
I have tried to hide all the series from the legend using Chart.Series.Line.showInLegend = false and then create a custom legend like this:
Code:
let series = $('#plotdiv').jqChart('option', 'series');
let legend = $('#plotdiv').jqChart('option', 'legend');
legend.customItems = series.map(s => ({
marker: {
type: 'circle',
strokeStyle: s.strokeStyle,
fillStyle: s.strokeStyle
},
text: {
text: s.title
}
}));
$('#plotdiv').jqChart('update');
However, there are two issues with that approach:
1. If you don't specify series' strokeStyle and instead default to the predefined color scheme or specify your own using Chart.jqChart.paletteColors, you won't have any strokeStyle defined in your series. As a result, all of the markers will default to a blue color.
2. The legend items are no longer linked to the actual series and you can't show/hide the series by clicking the legend items.
Are there any solutions/workarounds to getting a different shape of a legend item?
Cheers,
Nikolay