Questions tagged [swiftcharts]

A charting library for iOS, written in swift.

A charting library for iOS, written in swift.

References

Github repository

98 questions
17
votes
2 answers

How to label axes in Swift Charts?

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 …
Hundley
  • 3,167
  • 3
  • 23
  • 45
10
votes
1 answer

Creating line chart with multiple lines

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…
John Harrington
  • 1,314
  • 12
  • 36
8
votes
1 answer

Why do annotations only show correctly on bar marks?

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…
6
votes
2 answers

Swift Charts will not display the last x-axis AxisValueLabel with AxisMarks

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,…
apod
  • 145
  • 1
  • 6
6
votes
2 answers

How can I create a dynamic input to .chartForegroundStyleScale

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 :…
Fleet Phil
  • 333
  • 2
  • 12
5
votes
1 answer

Swift Charts: How to show only values and labels for values in array?

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 =…
Daniel
  • 1,473
  • 3
  • 33
  • 63
4
votes
3 answers

Swift Charts (iOS 16) Pie / Donut Chart

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
shinto Joseph
  • 1,039
  • 3
  • 16
  • 27
4
votes
1 answer

Swift Charts AreaMark fill entire vertical height

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), …
Yosi199
  • 1,745
  • 4
  • 22
  • 47
4
votes
3 answers

Swift Charts: .chartYScale only seems to work with increments of 100?

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…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
3
votes
1 answer

How to add marker to center position in ios charts while scrolling horizontally with increasing scaleX and enabling drag

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…
Hannan Riaz
  • 33
  • 1
  • 3
2
votes
0 answers

One line with two styles in SwiftUI Chart

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…
CosmicTea
  • 90
  • 6
2
votes
0 answers

Why is there an X Axis label glitch when animating a Date based Bar chart using Swift Charts?

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…
2
votes
0 answers

I have a problem with xAxisLabel of SwiftCharts by ivanschuetz

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…
Mehdi
  • 1,340
  • 1
  • 10
  • 5
2
votes
0 answers

Swift Charts: Prevent horizontal bar marks from overlapping Y axis label

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:…
William T.
  • 12,831
  • 4
  • 56
  • 53
2
votes
1 answer

How to use Core Data with Swift Charts?

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…
1
2 3 4 5 6 7