Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Using multiple Line Styles on a single Line Mark

Hello, I am wondering if it is possible to have a Line Mark with different line styles. I am trying to create a Line Mark where part of the line is solid and another part of the line is dashed. Even with a conditional it only displays one or the other. Is it currently possible in SwiftCharts to do something like the attached image? Thank you.

There are a couple of options, not all of which necessarily work for your use case.

  • Stitch: Since you can have multiple, independent curve sections, you can compose your curve from multiple lines, such that it still looks like one overall curve. Note: test your results with accessibility in mind. For example, if some data points are duplicated (where different sub-series meet) perhaps one of the points should have accessibility disabled.
  • Overplot: create a full, dotted curve, and superimpose it with a solid curve that has gap(s) in it
  • (Not for dots, but for changing colors) You can call .foregroundStyle with a horizontal gradient (eg. LinearGradient, or Gradient) such that, knowing the ratios of where the style change occurs, you introduce an abrupt color change (specify two different colors with the same location value)
Using multiple Line Styles on a single Line Mark
 
 
Q