SwiftCharts: How to clip data to specific range?

I found that can customise the range of the x and y axes. But my problem is that for line marks some data might just be outside the axes range. If I add .clipped to the chart that would limit it, but then it also clips off some of the axis marks.

No Clipping:

With Clipping: you see the green line go over the AxisValueLabel area and the topmost label is clipped off.

One way I can imagine addressing this without enabling clipping is to create an interpolated value for values that are just outside the chart range so that the line ends exactly at the min/max.

Another problem is that my AreaMarks also go out of the visible area. So my more general question is to Apple: how does one deal with marks that are outside of the desired chart ranges for the x and y axes?

did you find solution for clipping data?

have the same problem :/

+1

I could trim the data to fit the charts, but I need the interpolation to carry on so that the line curves correctly right up to the edge of the chart using the values that are outside the bounds of the x-axis. .clipped() trims the left side of the chart, but not the right :/

After spending a considerable amount of time searching for a solution, I discovered that using .drawingGroup() for the Chart or container with Chart solved the problem.

SwiftCharts: How to clip data to specific range?
 
 
Q