willdale / SwiftUICharts

A charts / plotting library for SwiftUI. Works on macOS, iOS, watchOS, and tvOS and has accessibility features built in.
MIT License
844 stars 105 forks source link

Adding single data - point of interest with an X and Y intercept #84

Closed 7elysium closed 3 years ago

7elysium commented 3 years ago

I have a 6 line multiline chart. I want to plot a single point of data based on user input on this graph to see where that data point lies with respect to the other lines. Preferably highlight it in some manner with X, Y-axis intercepts. I tried using yAxisPOI but that only lets me enter in one value (xAxis). And I tried creating another line with 3 points (2 preset ones and entering data into the third middle one) but I couldn't get it to work. I have two values [Double, Double] that I want to plot.

And if this is possible - will the point be appropriately placed along the Y-axis? I'm asking because my Y-axis labels are all string interpolations of integers.

Thank you so much!

willdale commented 3 years ago

Hi, does the request boil done to adding X axis POI?

7elysium commented 3 years ago

Hello! I think using both an X-axis POI together with a Y-axis POI should do the trick. But if we do that, then where will the POI label be shown? Won't there be two different POI labels?I don't think it'll be possible to specifically highlight the point where the 2 lines intercept...

This is what I'm trying to achieve:

Screen Shot 2021-06-05 at 7 13 42 PM

Also, thank you for looking into this! I really appreciate it!

7elysium commented 3 years ago

Hi Will,

I tried creating two straight lines to get something close to my screenshot using:

But this approach didn't work.. I tried something similar making one line using yAxisPOI which failed too.

Is there anything else that I can try using the tools already present in the package to get something close to the result I'm going for?

I'm sorry to bother you with this again, but I really need this for a project. I'm pretty new to coding so I'm not sure what else I can try and all the other charts packages available here don't even come close to yours...

I'd really appreciate any help!

Thank you so much!

willdale commented 3 years ago

In v2.8 you can now add a X axis marker.

.xAxisPOI(chartData: data,
          markerName: "Worst",
           markerValue: 2,
           dataPointCount: data.dataSets.dataPoints.count,
           lineColour: .red)