Search code examples
c#winformsvisual-studiochartsbubble-chart

Unproportional Bubble Chart with the size paramater


I´ve created a bubble chart and I put in some testing values as follow:

    this.chart1.Series["blueBubble"].Points.AddXY(2, 3, 6);
    this.chart1.Series["redBubble"].Points.AddXY(1, 0, 7);
    this.chart1.Series["yellowBubble"].Points.AddXY(1, 3, 8);

As I put in the size of the particular bubble to the third parameter of AddXY function, the sizing is done in a completely wrong proportional representation. See picture:

enter image description here

How can I change the bubble sizes to the right proposition representation?


Solution

  • This looks really weird.

    The best explanation I have is that the sizes always start with the smallest one set and scale them going from 1 to the largest one set in proprtional steps.

    Sounds awfully strange? Yup.

    Here are the notes on MSDN on BubbleScaleMax and BubbleScaleMin

    If set to Auto, the smallest plotted bubble is displayed using the minimum size.

    If set to Auto, the largest plotted bubble will be displayed using the maximum size.

    Setting these properties to anything else but Auto is tricky; you could use this:

     chart1.Series[0]["BubbleScaleMin"] = "0";
    

    Or any number smaller than your smallest size.

    Or, if you prefer, here is a workaround: Add a transparent dummy point with size = 0 and suitable x- and y-values:

    int i = this.chart1.Series[0].Points.AddXY(1, 1, 0);
    this.chart1.Series[0].Points[i].Color = Color.Transparent;
    

    Before and after:

    enter image description hereenter image description here