Skip to content
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

Legend not showing all values on stacked bar chart #34

Closed
geeklingo opened this issue Mar 17, 2021 · 6 comments
Closed

Legend not showing all values on stacked bar chart #34

geeklingo opened this issue Mar 17, 2021 · 6 comments

Comments

@geeklingo
Copy link

I have a chart where i stack 5 different values. On the demo app, I can see all 3 legends being displayed on the graph (England, Wales & Scotland). But when I try to adapt to my data, I can only show 2 of the 5 in the legend.

Note: This is the legend only, the stacked graph is showing all 5 correctly.

@geeklingo
Copy link
Author

Actually, maybe because I'm not setting the legendTag?
image

@geeklingo
Copy link
Author

How do we set that attribute (legendtag)? I can't see any reference in the readme to it.

@willdale
Copy link
Owner

The legendTag is a way of handling Legends internally for the touch overlay, I'll see if I can remove it from the public API.

The legends for StackedBarChart are taken from the GroupingData.

Can you post some code?

@geeklingo
Copy link
Author

I've got my grouping data like this. It must be working as the charts are showing the correct stacked bars and tapping on the bars is showing the correct group and value. It's just the legend that doesn't seem to be pulling all the values.
The only difference in my code and the demo is that I use a for loop to populate MultiBarChartDataPoint and Sets.

            var data : GroupingData {
                switch self {
                case .type1:       return GroupingData(title: "Type 1",    colour: ColourStyle(colour:Color(UIColor.systemGray)))
                case .type2:     return GroupingData(title: "Type 2",  colour: ColourStyle(colour:Color(UIColor.systemGreen)))
                case .type3:      return GroupingData(title: "Type 3",   colour: ColourStyle(colour:Color(UIColor.systemYellow)))
                case .type4:    return GroupingData(title: "Type 4", colour: ColourStyle(colour: Color(UIColor.systemRed)))
                case .type5:    return GroupingData(title: "Type 5", colour: ColourStyle(colour: .primary))
                }
            }

@geeklingo
Copy link
Author

Oh hahahaha nevermind, i'm such an idiot.
let groups : [GroupingData] =

I didn't have the full set in there.

@willdale
Copy link
Owner

You got there a second before me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants