I am trying to build a composite bubble chart that has dates along the xAxis. Basically, price over time, with the sales volume driving the size. I haven't been able to make this work at all. I did it in Excel (below).
Does anyone have a demo of something like this they can provide?
Hello,
Which versions of NetAdvantage and Visual Studio are you using? Also, which language are you programming in?
Here is the code that I am using. I've tried a bunch of different combinations of settings and it just will not display the Bubble chart by time. Can anyone help?
public Form1()
{
InitializeComponent();
DataTable dt = new DataTable();
dt.Columns.Add("Label", typeof(string));
dt.Columns.Add("X", typeof(DateTime));
dt.Columns.Add("Y", typeof(double));
dt.Columns.Add("R", typeof(double));
dt.Rows.Add("01/01/2013", to_date("01/01/2013"), 10, 5);
dt.Rows.Add("01/01/2013", to_date("02/01/2013"), 40, 3);
dt.Rows.Add("01/01/2013", to_date("03/01/2013"), 30, 4);
dt.Rows.Add("01/01/2013", to_date("04/01/2013"), 30, 2);
ultraChart1.DataSource = dt;
this.ultraChart1.ChartType = ChartType.Composite;
ChartArea area = new ChartArea();
this.ultraChart1.CompositeChart.ChartAreas.Add(area);
//Create X axis - time axis
AxisItem axisX = new AxisItem();
axisX.DataType = AxisDataType.Time;
axisX.Extent = 100;
axisX.Labels.ItemFormat = AxisItemLabelFormat.ItemLabel;
//axisX.Labels.ItemFormatString = "<DATA_VALUE:MM/dd/yyyy>";
axisX.Labels.ItemFormatString = "<ITEM_LABEL>";
//axisX.Labels.ItemFormatString = "";
axisX.OrientationType = AxisNumber.X_Axis;
axisX.SetLabelAxisType = SetLabelAxisType.DateData;
axisX.Labels.Orientation = TextOrientation.VerticalLeftFacing;
axisX.RangeType = AxisRangeType.Custom;
axisX.RangeMin = 0;
axisX.RangeMax = 50;
area.Axes.Add(axisX);
//Create X axis - numeric axis
AxisItem axisY = new AxisItem();
axisY.Extent = 40;
axisY.DataType = AxisDataType.Numeric;
axisY.Labels.ItemFormatString = "<DATA_VALUE:###,###,##0.##>";
axisY.OrientationType = AxisNumber.Y_Axis;
axisY.LineColor = Color.Red;
axisY.RangeType = AxisRangeType.Custom;
axisY.RangeMin = 0;
axisY.RangeMax = 50;
area.Axes.Add(axisY);
ChartLayerAppearance myColumnLayer = new ChartLayerAppearance();
myColumnLayer.ChartType = ChartType.BubbleChart;
myColumnLayer.ChartArea = area;
ChartLayerAppearance myColumnLayer2 = new ChartLayerAppearance();
myColumnLayer2.ChartType = ChartType.ScatterChart;
myColumnLayer2.ChartArea = area;
XYZSeries s1 = new XYZSeries();
s1.Label = "test";
s1.DataBind(dt, "X", "Y", "R", "Label");
//s1.DataBind(dt, "X", "Y", "R");
s1.Visible = true;
s1.PEs.Add(new PaintElement(Color.Yellow));
s1.PEs.Add(new PaintElement(Color.Red));
s1.PEs.Add(new PaintElement(Color.Green));
s1.PEs.Add(new PaintElement(Color.Pink));
myColumnLayer.Series.Add(s1);
myColumnLayer2.Series.Add(s1);
ultraChart1.CompositeChart.Series.Add(s1);
myColumnLayer.AxisX = axisX;
myColumnLayer.AxisY = axisY;
this.ultraChart1.CompositeChart.ChartLayers.Add(myColumnLayer);
//CompositeLegend myLegend = new CompositeLegend();
//myLegend.ChartLayers.Add(myColumnLayer2);
//myLegend.ChartLayers[0].LegendItem = LegendItemType.Point;
//myLegend.Bounds = new Rectangle(3, 83, 25, 15);
//myLegend.BoundsMeasureType = MeasureType.Percentage;
//myLegend.PE.ElementType = PaintElementType.Gradient;
//myLegend.PE.FillGradientStyle = GradientStyle.ForwardDiagonal;
//myLegend.PE.Fill = Color.CornflowerBlue;
//myLegend.PE.FillStopColor = Color.Transparent;
//myLegend.Border.CornerRadius = 10;
//myLegend.Border.Thickness = 1;
ultraChart1.Tooltips.Format = TooltipStyle.LabelPlusDataValue;
//this.ultraChart1.CompositeChart.Legends.Add(myLegend);
ultraChart1.Legend.Visible = true;
}
private DateTime to_date(string val)
DateTime dt;
System.Globalization.DateTimeFormatInfo formatInfo;
formatInfo = new System.Globalization.DateTimeFormatInfo();
dt = DateTime.ParseExact(val, "MM/dd/yyyy", formatInfo);
return dt;
Thanks. I sent a support ticket in for deeper analysis and to request a sample. That would be pretty horrific if you can't do a bubble chart over time. That's a very valid type of analysis (i.e. Price or Cost over Time).
I tried your number idea by changing the dates to 20130101 through 20130401 as numbers to try and fake it out and, while it rendered, it did two things. 1. I couldn't figure out how to re-format it to draw as a date string (i.e. MM/dd/yyyy), and 2. Whether I do Automatic or Custom range types, it would create invalid numeric dates, like 20130250, which is like saying 2013-02-50. I get that it thinks it's a number now, but obviously it's not valid for date/time purposes.
I'm not really understanding why I can create it in Excel in like 2 minutes, but it's seemingly impossible here.
Hello ryork,
I`m glad to see that you are using a code from one of my samples.
If you want to solve your task, you could implement additional layer with DateTime and Numeric axis. By this way you could show your DateTime axis and hide your Numeric axis from Bubble layer. I made small sample for you. Please take a look at the attached smaple and let me know if you have any questions.
Regards
Here is the sample.
Also I missed to mention about customization of your DateTime axis. For example you could use the code:
AxisItem axisX2 = new AxisItem();
axisX2.DataType =AxisDataType.Time;
axisX2.Extent = 100;
axisX2.Labels.ItemFormat =AxisItemLabelFormat.Custom;
axisX2.Labels.ItemFormatString ="<ITEM_LABEL: dd/MM/yyyy>";
axisX2.OrientationType =AxisNumber.X_Axis;
axisX2.Labels.Orientation =TextOrientation.Custom;
axisX2.Labels.OrientationAngle = 45;
axisX2.Labels.HorizontalAlign =StringAlignment.Far;
axisX2.TimeAxisStyle.TimeAxisStyle =RulerGenre.Discrete;
area.Axes.Add(axisX2);
Georgi -
Hello, just wanted to share. In noodling around with this, I believe I found a simpler solution. Instead of overlaying an X2 axis (that wasn't lining up), I got rid of that and simply created an IRenderLabel Interface to re-factor the numeric OADate values back into a real date, then formatted it. Looks great now! I attached the project for future reference.
One question: It would however be really nice if there was a way to specify that the tickmarks only painted where a data value exists, similar to the .Discrete style for NumericTimeSeries. Is this possible for pure Numeric axis types?
Hello ryork
ryork said:There is one small issue that I've found. The X2 Axis formatted dates, aren't lining up with the X-Axis numeric dates, which makes the bubble location seem off
You are right about this. I forgot about this in my sample. I check your solution and for my opinion is perfect. If you have any questions, feel free to write us.