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

Swiftui Charts resorting ontapGesture with annotation

I have a Chart where I'm trying to add annotation for a bar when tapped. The annotation appears properly~ish. The bars start movig around to different positions once I tap on them. Here's the code for this? …
Robert
  • 809
  • 3
  • 10
  • 19
0
votes
1 answer

Animatable transition of a chart foregroundStyle color property

Is possible to animate the color transition between two colors defined to a LineMark on a SwiftUI Chart? I would like to see gradual change and not an abrupt switch between the colors, as you can see in this sample code: struct SwiftUIViewTest: View…
João Colaço
  • 1,202
  • 1
  • 14
  • 38
0
votes
0 answers

Charts hide LineMark?

I just started working with Charts in SwiftUI and there is one thing I can't figure out, if it's even possible to achieve. Let's say my Y axis ranges from 0 to 1. If I have a value that is -1, is it possible to only hide that one LineMark without…
0
votes
0 answers

Conversion of seconds unit on y axis in SwiftUI charts

I am trying to play around with the SwiftUI Charts framework to make a bar graph, where the x axis is a date, and the y axis is the number of seconds. As the number of seconds grows, at some point, the data starts to loose value, as the seconds…
Mickey223
  • 1
  • 1
0
votes
1 answer

(SwiftUI Charts/ VisionOS) Static method 'buildExpression' requires that 'Chart' conform to 'View'

Trying to create a Chart in ContentView. I keep seeing this error no matter how I try to construct it. import Foundation import SwiftUI import Charts struct StockView: View { var body: some View { Chart { BarMark( …
rkatakam
  • 51
  • 6
0
votes
0 answers

SwiftUI Chart Y-axis zoom

Hi I am making a Crypto price tracking app and I am trying to show the price for Bitcoin for the day as a SwiftUI chart. The problem is the chart is zoomed out on the Y axis to show 0-40,000 (so the chart basically looks like a horizontal line…
0
votes
0 answers

How to determine the symbols and styles chosen by Swift Charts

I'm curious, is there a way to predict or query the style and symbols that Swift Charts will use when using .foregroundStyle(by:), .symbol(by:), etc? The reason I need to know is that I have UI elements outside the Chart that need to match those…
Curious Jorge
  • 354
  • 1
  • 9
0
votes
0 answers

SwiftUI line chart colored by series

How do I specify a custom color for each series on a SwiftUI line chart? The number and desired colors of the series are determined at runtime. The closest fit I've found is chartForegroundStyleScale(_ mapping: KeyValuePairs
Edward Brey
  • 40,302
  • 20
  • 199
  • 253
0
votes
1 answer

Order of layers in Swift combined chart

I am making a chart which consists of an Area Mark, 2 Line Marks & 2 Point Marks. No matter which order I place the different chart elements, the Area Mark is on top and I can't find any documentation or online articles explaining how to change the…
0
votes
0 answers

Displaying bar chart bars as average and not sum

How can I get SwiftUI Chart to display a daily average vs the sum if I were using .weekOfYear as the unit for BarMark? For example, instead of displaying the total number of steps in a week, I'd like to show the daily average for that week. Chart { …
Tuan Anh Vu
  • 760
  • 1
  • 7
  • 26
0
votes
0 answers

SwiftUI Charts zoom and mouse over popup

I have a macOS App written in Swift and I need to visualise some temperatures sensors like a Charts. The project doesn't use SwiftUI, but only for this view. I've created this View and works fine. Now I need to enable users zoom over the chart…
Fry
  • 6,235
  • 8
  • 54
  • 93
0
votes
0 answers

Chart RectangleMark Breaks with Large DataSets

Anyone run into problems with SwiftUI Charts using a RectangleMark where the foregroundStyle color doesn't render any opacity for large datasets? This doesn't happen when my dataSet is small. Here I have my chart code as well as the method I call…
Kenny Ho
  • 409
  • 3
  • 16
0
votes
1 answer

SwiftUI chart line mark being one continuous line

i'm very new to ios development, i'm fetching data from firebase and processing it into two arrays full of tuples currently(Will eventually be 3). the x axis is the first value in the tuple and so on, each tuple should be a point of the line and…
0
votes
0 answers

Why does SwiftUI ForEach<>._layoutChartContent get called here?

I am trying to add a SwiftUI chart inside a SwiftUI sheet. The chart has around 288 data points and around 10 different AreaMarks. When I try to add any of .chartForegroundStyleScale, .chartXAxis, or .chartYAxis view modifiers I start to notice an…
0
votes
0 answers

how to make a bar chart with apples new swift chart?

I am developing a finance management app, and I want to display a bar chart for each spending category. The goal is to show the user a visual representation of their transactions within a specific time period, such as today, this week, this month,…