amcharts5
amcharts5 copied to clipboard
SmoothedXLineSeries strokeDasharray in templateField doesn't work; can't get dataItem in series.fills.template.adapters
Bug description Hello.
- The second part of my SmoothedXLineSeries becomes not smoothed, if data items contain
templateField
for strokes withstrokeDasharray
setting. - 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
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
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.
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.