amcharts5 icon indicating copy to clipboard operation
amcharts5 copied to clipboard

SmoothedXLineSeries strokeDasharray in templateField doesn't work; can't get dataItem in series.fills.template.adapters

Open jdim opened this issue 2 years ago • 2 comments

Bug description Hello.

  1. The second part of my SmoothedXLineSeries becomes not smoothed, if data items contain templateField for strokes with strokeDasharray setting.
  2. I would like to use a custom fill for some of segments, based on dataItem, so I trying to use an adapter. But the target.dataItem is undefined, and I can't get X value (Date)
series.fills.template.adapters.add('fill', function(fill, target) {
 // etc.

Environment (if applicable)

  • amCharts 5
  • Browser Chrome

Additional context

Example: https://codepen.io/dm-khabarov/pen/PoRRavY

jdim avatar Aug 04 '22 12:08 jdim

Switching line styling (in your case its from solid to dashed line) terminates current segment and starts new.

Smoothing algorithm requires at least three points of reference, whereas in your example you have only two in the last segment, hence the straight line.

If you need to apply different styling to parts of the smoothed line series, I suggest using axis ranges instead: https://www.amcharts.com/docs/v5/charts/xy-chart/axes/axis-ranges/#series-axis-ranges

martynasma avatar Aug 04 '22 13:08 martynasma

It seems in my example, I had last three data points with strokeDasharray. I've added an additional point with strokesSettings to the example, but the line is straight, it doesn't help.

Thanks for help, I will consider using axis ranges. At first glance the templateField for strokes looked as a simplest way.

jdim avatar Aug 04 '22 13:08 jdim

This issue is stale because it has been open 30 days with no activity. It will be closed in 5 days unless a new comment is added.

github-actions[bot] avatar Sep 04 '22 00:09 github-actions[bot]