-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels for Max Value #24
Comments
Hi @xremix, private struct LineChartDemo: View {
@State var data1: [CGFloat] = (2010...2020).map { _ in .random(in: 0.0...1.0) }
@State var trim: CGFloat = 0
var body: some View {
HStack {
VStack {
AxisLabels(.vertical, data: (-10...10).reversed(), id: \.self) {
Text("\($0 * 10)")
.fontWeight(.bold)
.font(Font.system(size: 8))
.foregroundColor(.secondary)
}
.frame(width: 20)
Rectangle().foregroundColor(.clear).frame(width: 20, height: 20)
}
VStack {
Chart(data: data1)
.chartStyle(
LineChartStyle(.quadCurve, lineColor: .blue, lineWidth: 5, trimTo: $trim)
)
.padding()
.background(
GridPattern(horizontalLines: 20 + 1, verticalLines: data1.count + 1)
.inset(by: 1)
.stroke(Color.gray.opacity(0.1), style: .init(lineWidth: 2, lineCap: .round))
)
.onAppear {
trim = 0
withAnimation(.easeInOut(duration: 3)) {
trim = 1
}
}
AxisLabels(.horizontal, data: 2010...2020, id: \.self) {
Text("\($0)".replacingOccurrences(of: ",", with: ""))
.fontWeight(.bold)
.font(Font.system(size: 8))
.foregroundColor(.secondary)
}
.frame(height: 20)
.padding(.horizontal, 1)
}
.layoutPriority(1)
}
.padding()
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @spacenation,
first of all, thanks for providing this amazing library!
Is there a way to add label for the largest (and maybe smallest) value to the left of a chart? That'd be really helpful for most of my use cases.
Thanks and best regards
Toni
The text was updated successfully, but these errors were encountered: