Welcome Guest Search | Active Topics |

Legend markers for line series
ndolzhenkov
#1 Posted : Monday, September 3, 2018 1:53:26 PM(UTC)
Rank: Newbie

Groups: jQueryChart, Registered
Joined: 4/18/2017(UTC)
Posts: 1

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
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
Dragan
#2 Posted : Wednesday, September 12, 2018 1:55:58 PM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Hi,

Currently, jqChart doesn't support workaround for this case, but we'll try implementing "configurable legend item" functionality and we'll send you a custom version via email. I hope this will be at the beginning of next week.
Best Regards,
Dragan Matek
jqChart Inc.
1 user thanked Dragan for this useful post.
ndolzhenkov on 9/14/2018(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

FlatEarth Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.059 seconds.