Jump to content
Software FX Community

Bubble chart axis problem


mattias
 Share

Recommended Posts

Hi! I'm a complete ChartFX newbie so excuse me if this is a trivial question. I want to create a bubble chart based on data from business objects, but have problems getting the X axis and legend to show the information I want.

Basically I have a business object (lets call it BubbleObject) with three properties of type Single named X, Y and Size, and one string property called Name. I want the X and Y properties to be the coordinates of each bubble, Size to control its size and Name to show up in the legend. So I add a chart to a web form, configure it to use a 2D Bubble chart type with MultiColors. Then I add the following code to Page_Load


    Dim bubbles() As BubbleObject = { _       New BubbleObject(1, 1, 1, "First"), _       New BubbleObject(2, 2, 2, "Second"), _       New BubbleObject(3, 3, 3, "Third")}     Chart1.AxisX.Min = 0     Chart1.AxisX.Max = 5     Chart1.AxisX.Step = 1     Chart1.AxisY.Min = 0     Chart1.AxisY.Max = 5     Chart1.AxisY.Step = 1     Chart1.DataSourceSettings.Fields.Add(New FieldMap("X", FieldUsage.XValue))     Chart1.DataSourceSettings.Fields.Add(New FieldMap("Y", FieldUsage.Value))     Chart1.DataSourceSettings.Fields.Add(New FieldMap("Size", FieldUsage.Value))     Chart1.DataSourceSettings.Fields.Add(New FieldMap("Name", FieldUsage.Label))     'Chart1.DataSourceSettings.Style = DataSourceStyles.KeepLabels     Chart1.DataSource = bubbles


The end result looks like this

Posted Image

The problem here is, I guess, that the x axis is a "categorical axis" when I want a "numerical axis" that shows 0 ... 5. The "Numerical and Categorical Axes" topic in the Programmer's Guide explains the difference but doesn't say how to chose one or the other. If I uncomment the line setting the DataSourceSettings.Style to KeepLables I get this instead.

 Posted Image

 Now the axis is OK but the legend doesn't display the object names. What I want is something inbetween that would look like this

Posted Image 

 The "Bubble Charts" winforms demo application seems to get this right somehow, and I've tried copying all sorts of properties from it to my own application, but so far nothing has helped. So what's the easiest way to get the chart to look the way I want it to?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...