LineChart

main

A simple animated LineChart example.
karlis/LineChart

LineChart

A simple animated LineChart example.

import SwiftUI

struct ExampleView: View {
  @ObservedObject
  var model = LineModel()

  var body: some View {
    Color.white
      .overlay(
        LineShape(model: model)
          .fill(gradient)
      )
      .onTapGesture {
        withAnimation {
          model.add(CGFloat.random(in: 0...100))
        }
      }
  }

  var gradient: LinearGradient {
    LinearGradient(
      gradient: Gradient(colors: [Color.green, Color.green.opacity(0.2)]),
      startPoint: .top,
      endPoint: .bottom
    )
  }
}

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Oct 17 2024 22:11:07 GMT-0900 (Hawaii-Aleutian Daylight Time)