How do you manually set a range on a chart

How can you set a manual range on a chart? There is .chartXScale(range:) but the only options seem to be to add padding to the values in the chart. I need to have a specific start and end date.

Replies

I found a workaround by adding a hidden vertical RuleMark for the beginning and end of the day. Not sure if this is a good idea but it does seem to work well.

RuleMark(x: .value("Start of day", period.start))
		.foregroundStyle(Color.clear)
RuleMark(x: .value("End of day", period.end))
		.foregroundStyle(Color.clear)
  • There has to be a better way but I haven't found it yet, thanks for the workaround!

Add a Comment