willdale / SwiftUICharts

A charts / plotting library for SwiftUI. Works on macOS, iOS, watchOS, and tvOS and has accessibility features built in.
MIT License
844 stars 105 forks source link

Custom Legend for Bar Charts #70

Closed tfeige91 closed 3 years ago

tfeige91 commented 3 years ago

Is it possible to draw a custom Legend for a bar chart? I have many bars but only two conditions and want to place only those two conditions in a legend below the chart. What I get is a Legend with one Item for each bar.

In the Docs it says that legends is part of BarChartData but I can't add id there.

willdale commented 3 years ago

Custom legends are not possible. They get generated based on the data provided.

You could look at Grouped Bar Charts? https://github.com/willdale/SwiftUICharts#grouped-bar-chart

tfeige91 commented 3 years ago

Setting up a Grouped Bar Chart with only one group did the trick :) Thanks!

willdale commented 3 years ago

No worries, glad it's working.