Search code examples
iosswiftios-charts

How to get consistent bubble sizes in BubbleChartView in Charts for iOS


EDIT

I've spent a very long time trying to find a relationship between BubbleChartDataEntry.size and BarLineChartViewBase.leftAxis/rightAxis min and max values. I can't seem to find a connection. I'm trying to get bubbles of absolute size that correspond to the axis unit of measure, rather than normalized sizes per set, where the largest BubbleChartDataEntry.size is the height of the chart.

Any help with the below problem is appreciated. Please stop voting to close this. I need some assistance.


There's a really great Cocoapod for iOS called Charts that I'm trying.

Say I have a BubbleChartView where the leftAxis or rightAxis min and max is 0 and 20.

The chart is rendered with two BubbleChartDataEntry bubbles, size 9 and 10. The bubbles are about the same height as the left/right axis.

Then the chart is rendered with two different BubbleChartDataEntry bubbles, size 4.5 and 5. These bubbles are also about the same height as left/right axis even though their sizes are half the previous bubbles.

This appears to happen because of a normalization setting on the bubble data. If normalization is disabled, the bubbles are much, much larger than before.

Is there a setting or suggested way to render bubbles so that their sizes use the same unit of measure as the left/right axis? For example, a bubble with size 10 will have a height equal to 10 units on the left/right axis.


Solution

  • Posting in case this might be helpful. For now I'm adding an extra invisible bubble where bubble size = height of axis. All visible bubbles render with diameters that match units on the vertical axis. This may be an unusual use-case but it solves the requirements.