I have followed the example at: https://wordpress-931910-4332701.cloudwaysapps.com/documentation/ios/current/legend-modifier.html for creating a legend with a custom item.
The initial problem I am trying to solve is that the default legend has a black background but my chart is white. If I set the background of the legend to white, this is a problem because the series text is white, so you can’t read it any longer. Therefore in order to have a legend with a white background to match my chart, I needed custom legend items to be able to set the series text color to black.
I have created my ChartLegendCell.swift file based on the example and my ChartLegendCell.xib which has a UIView and a UILabel. I incorporate these into my code exactly as in the example. However the legend does not show up upon render. I added a breakpoint inside the ChartLegendCell.swift class and I see bindSeriesInfo method called twice per series. What I noticed is that the first time it is called, printing out self.bounds shows (0,0,230,35) which is correct, but the second time it is called self.bounds is (0,0,0,0).
Is there more code which needs to be added in the ChartLegendCell.swift to make sure the width and height aren’t 0?
- Brad Taber asked 4 years ago
- You must login to post comments
Hi, Brad.
Unfortunately, we can’t reproduce your issue. Take a look at the archive files I’ve attached. There is a legend with a custom legend item and it produces the following result, see screenshot.
If you still have this issue, please provide some reproducible example so we stay on the same page trying to help you.
- Andriy P answered 4 years ago
- You must login to post comments
Please login first to submit.