* Add PieChart interaction PR changes to v2 * Add custom string format for ChartLabel when interactionInProgress = true (#151) * Dark/Light mode fixes (#148) Fix for making text work with both Dark/Light mode. Also solves line chart background to appear white in dark mode * Add custom string format for ChartLabel when interactionInProgress = true Co-authored-by: Sagar Patel <s.72427patel@gmail.com> * Prepare charts to display x and y values souch as a value for a given point Co-authored-by: Roddy Munro <roddymunro@icloud.com> Co-authored-by: Sagar Patel <s.72427patel@gmail.com>
22 lines
599 B
Swift
22 lines
599 B
Swift
import SwiftUI
|
|
|
|
extension View where Self: ChartBase {
|
|
|
|
/// Set data for a chart
|
|
/// - Parameter data: array of `Double`
|
|
/// - Returns: modified `View` with data attached
|
|
public func data(_ data: [Double]) -> some View {
|
|
chartData.data = data.map { ("", $0) }
|
|
return self
|
|
.environmentObject(chartData)
|
|
.environmentObject(ChartValue())
|
|
}
|
|
|
|
public func data(_ data: [(String, Double)]) -> some View {
|
|
chartData.data = data
|
|
return self
|
|
.environmentObject(chartData)
|
|
.environmentObject(ChartValue())
|
|
}
|
|
}
|