I'm trying to add axis unit labels to a chart built with Swift Charts.
For example:
import SwiftUI
import Charts
struct ContentView: View {
struct ChartData: Identifiable {
var id: Double { xVal }
let xVal: Double
…
Looking over Apple Documentation I found a straightforward way of doing this provided your dataset is structured correctly (mine is not). I've been working with a CSV file containing rows structured as below:
PM2.5 data, PM10 data, DateTime
PM2.5…
I have a Swift Chart that can toggle between line and bar marks.
I've added annotations to the top of each mark to display the value for each data point. On the bar chart, the annotations display correctly. However, on the line chart, only the first…
I am using the new swift charts framework to display some data. In seeking to manually control the frequency of the x-axis AxisValueLabels, as well as adjust the color, I implemented the following:
AxisMarks(values: .automatic(desiredCount: 11,…
In Swift Charts the signature for chartForegroundStyleScale to set the ShapeStyle for each data series is:
func chartForegroundStyleScale(_ mapping: KeyValuePairs) -> some View where DataValue : Plottable, S :…
I have a Chart with WeatherKit.HourWeather objects spanning over multiple days on the x axis. However, I want to exclude the nighttime hours. It looks like I can do this with the chartXScale modifier like this:
let myDataSeperatedByHours =…
is it possible to create a Pie / Donut chart using Apple's new Swift Charts framework?
there are images of a pie chart shown in the WWDC videos. Any help or code sample on how to create the pie chart will be much appreciated.
Thanks
I've got this very simple chart, nothing fancy - just takes up stock indicator prices and shows them.
VStack {
Chart {
ForEach(viewmodel.chartData1) { chartData in
LineMark(x: .value("date", chartData.date),
…
Given this is a heart rate chart, I'm trying to make the chart's Y max scale 210 (bpm), e.g. .chartYScale(domain: 0 ... 210) however it only seems to scale correctly if I pass in 200 or 300, anything in between doesn't work. Is this intended or a…
I am using the Charts framework from Daniel Cohen Gindi. I am scrolling chart horizontally by increasing scaleX value and enabled drag as described in answer of this question
Set an horizontal scroll to my Barchart in swift
I want to add marker at…
Is it possible to make the Chart with one line that will have two styles like on this picture?
I tried this, but it always selects only one style.
func strokeStyleByID(thenID: Int) -> StrokeStyle {
if thenID > 0 {
return…
I'm building a Bar chart using Swift Charts. The chart displays daily totals for a given week. I'm seeing a glitch when transitioning between consecutive weeks, where the first X axis label does not animate correctly and remains visible a bit more…
in swiftCharts library made by ivanschuetz i cannot have multiple value for one LineChartDataPoint object
LineChartDataPoint has something like this:
LineChartDataPoint(value: 23.0 , xAxisLabel: "A")
but i want it to get an array of value like…
Pretty basic code for a horizontal bar chart using Apple's Swift Charts:
private var testData: [(String, Int)] = []
init() {
for i in (0 ..< 10).reversed() {
testData.append(
("Item\(i)", i + 3)
)
}
}
var body:…
I'm doing FetchRequest
@Environment(\.managedObjectContext) var managedObjContext
@FetchRequest(sortDescriptors: [SortDescriptor(\.date, order: .reverse)])
var day: FetchedResults
And then I put it in Charts, but Swift Charts need…