Swift Package Index


A simple animated LineChart example.


  • The last commit to main was about 2 months ago.

Swift Version Compatibility

  • main
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • main
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

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
    )
  }
}