Questions tagged [swiftui-charts]

Questions related to the Charts framework added to SwiftUI 4 (iOS 16+, macOS 13+)

For more information see the documentation for Charts

51 questions
5
votes
3 answers

SwiftUI Scrollable Charts in IOS16

Using the new SwiftUI Charts framework, we can make a chart bigger than the visible screen and place it into a ScrollView to make it scrollable. Something like this: var body : some View { GeometryReader { proxy in …
fcollf
  • 131
  • 1
  • 5
4
votes
1 answer

How to change the color of BarView in SwiftUI charts when we tap on it

I have created a chart view like below. I wanted to know how to change the bar mark when user tap on the bar. Chart { ForEach(Data.lastOneHour, id: \.day) { BarMark( x: .value("Month", $0.day, unit: .hour), y:…
Leela
  • 65
  • 7
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
2
votes
1 answer

Removing overflow from SwiftUI Chart Axis

I am trying to plot some line charts using SwiftUI. In general, there is less data shown than available (in my example, I want to show values from 0…100, even though I am placing LineMarks for 0…200). My code works; however, there is an overflow on…
Philipp
  • 23
  • 4
2
votes
1 answer

Swift Charts - Is there a way query the y value of a LineMark at a specific x value?

So I have a chart displaying line data at equal x intervals, with varying y values - something like this: let ints = Array([0...10]) Chart { ForEach(ints) { int in let someRandomYValue = Int.random() LineMark(x: int, y:…
swiftyboi
  • 2,965
  • 4
  • 25
  • 52
2
votes
1 answer

SwiftUI Charts how to add a indication line to the selected (or last) BarMark

I'm trying to create a Range chart that looks like a native iOS heart rate chart but with some additional lines on it. . I found the example here https://github.com/jordibruin/Swift-Charts-Examples I tried to modify my chart by adding a…
2
votes
0 answers

Format the axis values of a SwiftUI Chart when data is being generated in realtime

I am trying to format the x axis values of a chart, where data is being generated in realtime. My X axis represent the seconds, while the Y axis represents the pressure. The chart works fine, but I have a dark background so the ValueLabels are hard…
GeorgeHTS
  • 41
  • 3
1
vote
0 answers

How to use ScrollViewReader to scroll to proper BarMark

Im trying to resolve the animated transition to the correct one BarMark using Charts library. The first idea was to add to each element id and next using .scrollTo(id) from ScrollViewReader. Unfortunately, it doesn't work. import SwiftUI import…
1
vote
1 answer

SwiftUI Charts LineMark symbol touch event

I have a chart: Create by code: Chart { ForEach(viewModel.historyChar) { chartItem in AreaMark( x: .value("Date", chartItem.date), y: .value("Amount", chartItem.amount) ) …
Serhii Didanov
  • 2,200
  • 1
  • 16
  • 31
1
vote
0 answers

SwiftUI Charts Issue

I'm having an issue with SwiftUI charts and was wondering if anyone knows of a solution or has also run into this. I've been trying to plot data for my app and the X axis does not show the dates and the Y axis only has axis marks 0-9. So, I tried to…
Rachel
  • 51
  • 1
  • 7
1
vote
1 answer

adding custom marks to SwiftUI chart using path

I want to use a custom shape that I have drawn using a path to the marks of my chart. So instead of points or bars or whatever marking the data, I want the shape to be a specific symbol I have drawn. I am quite new to swift so I apologise if I add…
1
vote
0 answers

Swift Charts remove weekend gaps in data when plotting time-series, stock data

I am using Swift Charts to practice plotting some stock price data. Stocks only trade on weekdays, so every 5 days there is a gap of 2 days worth of data missing in any type of time-series stock data. I have a fully functional LineMark plot of…
apod
  • 145
  • 1
  • 6
1
vote
1 answer

SwiftUI Charts tapping Bar Chart

I have used the new SwiftUI Charts to make a simple bar chart, with month names on the x axis and cost on the y axis. I have added a .chartOverlay view modifier which tracks where I tap on the chart, and shows a BarMark with a text of the cost of…
Ivan C Myrvold
  • 680
  • 7
  • 23
1
vote
1 answer

SwiftUI charts clickable annotations

I'am trying to handle click on annotation in SwiftUI BarMark var body: some View { List { Chart { ForEach(data) { BarMark( x: .value("Mount", $0.mount), …
ankmara
  • 265
  • 3
  • 13
0
votes
1 answer

SwiftUI Chart Text Animation Glitch with AxisMarks and AxisLabels

I've encountered an animation glitch affecting the text for AxisMarks and AxisLabels in the SwiftUI Chart framework. Below are the sample project code and video for reference: struct ContentView: View { @State var isDisplayingAge = true …
Dan Flict
  • 117
  • 8
1
2 3 4