mattias Posted April 26, 2007 Report Share Posted April 26, 2007 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 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. 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 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 More sharing options...
Frank Posted May 3, 2007 Report Share Posted May 3, 2007 The sample uses conditional attributes to color the points. Conditional attributes show in the legend box as well. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.