liveview-native / liveview-native-swiftui-charts

Swift Charts addon library for LiveView Native
MIT License
3 stars 2 forks source link

Add `AxisTick`, `AxisValue`, and `AxisValueLabel` #83

Closed carson-katri closed 1 year ago

carson-katri commented 1 year ago

Closes #10 Closes #12

This also adds a new AxisValue element that can be used with AxisMarks to create custom axis marks.

Here is the Swift code and equivalent markup:

AxisMarks(values: [1, 2, 3, 4, 5]) { value in
  AxisValueLabel {
    Image(systemName: "\(value.as(Int.self)).circle.fill")
  }
  AxisTick()
}
<AxisMarks>
  <%= for value <- [1, 2, 3, 4, 5] do %>
    <AxisValue value={value}>
      <AxisValueLabel>
        <Image system-name={"#{value}.circle.fill"} />
      </AxisValueLabel>
      <AxisTick />
    </AxisValue>
  <% end %>
</AxisMarks>