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;
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.
Regards
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?
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. How can align these the X2 and X Axis labels one-for-one?
That sample couldn't be more perfect! Tricky solution with the hidden layer, I like it a lot.
Thank you very much!
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);