I have a chart with 5 lines, I need to be able to do NullHandling.InterpolateSimple on 2 of my lines and then NullHandling.DontPlot on 3 of them. I assume the only way to do this is with a composite chart consisting of 5 different line charts with the appropriate NullHandling method set on each? If so, how do I create these separate line charts? I have messed w/this all day and can't even get 1 to draw :( My code I have is below...all I get is the axis but no line. What am I missing? And once i get this one line working do i just repeat all the code for the remaining 4 lines?
// // Dev Target //
DataTable dt = new DataTable(); dt.Columns.Add("Date", typeof(string)); dt.Columns.Add("Value", typeof(int)); dt.Rows.Add(new object[] { "10/31/2011", 2099}); dt.Rows.Add(new object[] { "11/08/2011", null}); dt.Rows.Add(new object[] { "11/15/2011", 2400 }); dt.Rows.Add(new object[] { "11/22/2011", null }); dt.Rows.Add(new object[] { "11/30/2011", 2800 }); dt.Rows.Add(new object[] { "12/07/2011", null }); dt.Rows.Add(new object[] { "12/15/2011", 2999 }); dt.Rows.Add(new object[] { "12/22/2011", null }); dt.Rows.Add(new object[] { "12/31/2011", 3250 });
// // First chart area //
ultraChart1.ChartType = ChartType.Composite;
ChartArea devTargetArea = new ChartArea(); ultraChart1.CompositeChart.ChartAreas.Add(devTargetArea); // // Axis... //
AxisItem xAxis = new AxisItem(); xAxis.OrientationType = AxisNumber.X_Axis; xAxis.DataType = AxisDataType.Numeric; xAxis.Labels.ItemFormatString = ""; xAxis.Labels.Orientation = TextOrientation.VerticalLeftFacing; xAxis.Extent = 40; ultraChart1.CompositeChart.ChartAreas[0].Axes.Add(xAxis);
AxisItem yAxis = new AxisItem(); yAxis.OrientationType = AxisNumber.Y_Axis; yAxis.DataType = AxisDataType.Numeric; yAxis.TickmarkStyle = AxisTickStyle.Smart; yAxis.Labels.HorizontalAlign = System.Drawing.StringAlignment.Near; yAxis.Labels.VerticalAlign = System.Drawing.StringAlignment.Near; yAxis.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; yAxis.Labels.Visible = true; yAxis.Labels.ItemFormat = AxisItemLabelFormat.DataValue; yAxis.MajorGridLines.Visible = true; ultraChart1.CompositeChart.ChartAreas[0].Axes.Add(yAxis); // // Create the series //
NumericSeries devTargetSeries = new NumericSeries(); devTargetSeries.Data.DataSource = dt; devTargetSeries.Data.LabelColumn = "Date"; devTargetSeries.Data.ValueColumn = "Value"; ultraChart1.CompositeChart.Series.Add(devTargetSeries); ChartLayerAppearance devTargetLayer = new ChartLayerAppearance(); devTargetLayer.ChartType = ChartType.LineChart; devTargetLayer.ChartArea = ultraChart1.CompositeChart.ChartAreas[0]; devTargetLayer.AxisX = xAxis; devTargetLayer.AxisY = yAxis; devTargetLayer.Series.Add(devTargetSeries); ultraChart1.CompositeChart.ChartLayers.Add(devTargetLayer);
LineChartAppearance lcp = new LineChartAppearance(); lcp.DrawStyle = LineDrawStyle.Solid; lcp.MidPointAnchors = false; lcp.Thickness = 4; lcp.NullHandling = NullHandling.InterpolateSimple; devTargetLayer.ChartTypeAppearance = lcp;
Thanks for the help as I have this working now. But, I have a couple of cosmetic issues to iron out.
Below is the SS of what I have done w/the composite chart and then below that is the normally drawn line chart.
1) The TitleTop is getting drawn inside the chart area. Usually the chart is drawn, then there is some margin around the entire chart and the title would be drawn in the top whitespace, how can I do this here? (Compare w/the 2nd image)
2) Why is the X/Y axis border so thick, look to the right of the 7000 that line is thicker than normal. (Again, compare with the second image you will see the line is thinner)
3) Do you have to use that legend style when you have a composite chart? Can I make the legend look like the one in the 2nd image? This composite legend you can't even make out the color of the lines since they are so thin in the legend, and also there is no good place to draw it since it runs into the chart itself.
4) How can I make the dates along the X-Axis angled? I've messed w/orientation options and they don't seem to change the angle at all.
Thanks,
Lucas
Yes, that's correct.
Ahhh thank you! That was it. So then for the rest of the lines I just have to add a series and and a layer for each, right?
Hi DmgInc,
I noticed that some of the requirements for CompositeChart axes are not met in your code. X axis should have DataType of String or Time and SetLabelAxisType property set to ContinuousData. Here are some useful links - http://help.infragistics.com/Help/NetAdvantage/ASPNET/2012.1/CLR4.0/html/Chart_Requirements_for_Series_Binding.html, http://help.infragistics.com/Help/NetAdvantage/ASPNET/2012.1/CLR4.0/html/Chart_Axis_Requirements_for_Composite_Charts.html.
Let me know if this helps.
My problem is, no line is getting drawn. This is all I get