I am facing a problem while developing a composite chart with spline and scatter chart layer. Both the layers are not display with no error. Kindly reply me back if any body find a problem in the following code ;
SqlConnection conn = new SqlConnection("Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=ZIPCODEDB;Data Source=192.168.0.101\\sqlexpress"); conn.Open(); DataTable dtseries3rd = new DataTable(); DataTable oTable = new DataTable(); dtseries3rd.Columns.Add("col1", typeof(double)); dtseries3rd.Columns.Add("col2", typeof(double)); SqlCommand cmd1 = null; cmd1 = new SqlCommand("select * from [5th-95th-optionalchart-girlsweightforstature]", conn); cmd1.Connection = conn; SqlDataAdapter oDatapter = new SqlDataAdapter(); oDatapter.SelectCommand = cmd1; oDatapter.Fill(oTable); foreach (DataRow dr in oTable.Rows) { dtseries3rd.Rows.Add(new object[] { dr[1], dr[2] }); } this.ultraChart1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.Composite; ChartArea myChartArea = new ChartArea(); this.ultraChart1.CompositeChart.ChartAreas.Add(myChartArea); AxisItem xAxis = new AxisItem(ultraChart1, AxisNumber.X_Axis); xAxis.DataType = AxisDataType.String; xAxis.Labels.ItemFormat = AxisItemLabelFormat.ItemLabel; xAxis.Labels.Orientation = TextOrientation.VerticalLeftFacing; xAxis.Extent = 140; xAxis.LineColor = Color.DodgerBlue; xAxis.LineEndCapStyle = LineCapStyle.DiamondAnchor; xAxis.LineThickness = 4; xAxis.Labels.ItemFormatString = "<ITEM_LABEL:##.#>"; myChartArea.Axes.Add(xAxis); AxisItem yAxis = new AxisItem(ultraChart1, AxisNumber.Y_Axis); yAxis.DataType = AxisDataType.Numeric; yAxis.Labels.ItemFormat = AxisItemLabelFormat.DataValue; yAxis.Extent = 40; yAxis.LineColor = Color.RoyalBlue; yAxis.LineEndCapStyle = LineCapStyle.DiamondAnchor; yAxis.LineThickness = 4; yAxis.Labels.ItemFormatString = "<DATA_VALUE:##.##>"; myChartArea.Axes.Add(yAxis);
NumericSeries seriesArea1 = new NumericSeries(); seriesArea1.Data.DataSource = dtseries3rd; seriesArea1.Data.LabelColumn = "col1"; seriesArea1.Data.ValueColumn = "col2"; PaintElement pe1 = new PaintElement(); PaintElement pe2 = new PaintElement(System.Drawing.Color.Red); pe1.Fill = Color.Green; pe1.FillOpacity = 90; seriesArea1.PEs.Add(pe1); ChartLayerAppearance stepAreaLayer = new ChartLayerAppearance(); stepAreaLayer.AxisX = xAxis; stepAreaLayer.AxisY = yAxis; stepAreaLayer.ChartArea = myChartArea; stepAreaLayer.ChartType = ChartType.SplineChart; ultraChart1.CompositeChart.Series.Add(seriesArea1); stepAreaLayer.Series.Add(seriesArea1); ultraChart1.CompositeChart.ChartLayers.Add(stepAreaLayer); ChartLayerAppearance ScatterLayer = new ChartLayerAppearance(); ScatterLayer.AxisX = xAxis; ScatterLayer.AxisY = yAxis; ScatterLayer.ChartArea = myChartArea; ScatterLayer.ChartType = ChartType.ScatterChart; NumericSeries mySeries = new NumericSeries(); mySeries.Points.Add(new NumericDataPoint(12.3, "adsf", false)); ScatterLayer.Series.Add(mySeries); ultraChart1.CompositeChart.ChartLayers.Add(ScatterLayer);
Hi,
Excuse me for the late answer. I was out of office due to some health problems.
Does the problem still exist?
Hello,
Thanks for the reply but this isn't any more infect I am trying to change my code a bit and quite successful to display a spline chart but again scatter layer is not display after setting AxisY for that scatter scatter layer, following is the code kindly look into it;
this.ultraChart1.ChartType = ChartType.Composite; SqlConnection conn = new SqlConnection("Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=ZIPCODEDB;Data Source=Nortec01\\sqlexpress"); conn.Open(); #region Define Percentile NumericSeries series3rd = new NumericSeries(); NumericSeries series5th = new NumericSeries(); NumericSeries series10th = new NumericSeries(); NumericSeries series25th = new NumericSeries(); NumericSeries series50th = new NumericSeries(); NumericSeries series75th = new NumericSeries(); NumericSeries series90th = new NumericSeries(); NumericSeries series95th = new NumericSeries(); NumericSeries series97th = new NumericSeries(); #endregion #region Database Connectivity SqlCommand cmd = new SqlCommand("select * from [3rd-97th-birth36-boyslengthforage]", conn); SqlDataReader rdr = null; rdr = cmd.ExecuteReader(); while (rdr.Read()) { string age = rdr[01].ToString(); double HeadCircum3rd = double.Parse(rdr[02].ToString()); series3rd.Points.Add(new NumericDataPoint(HeadCircum3rd, age, false)); //double HeadCircum5th = double.Parse(rdr[03].ToString()); double HeadCircum5th = Convert.ToDouble(rdr[03]);// -Convert.ToDouble(HeadCircum3rd); series5th.Points.Add(new NumericDataPoint(HeadCircum5th, age, false)); //double weight2 = double.Parse(rdr[04].ToString()); double HeadCircum10th = Convert.ToDouble(rdr[04]);// - Convert.ToDouble(HeadCircum3rd); series10th.Points.Add(new NumericDataPoint(HeadCircum10th, age, false)); double HeadCircum25th = Convert.ToDouble(rdr[05]);// - Convert.ToDouble(HeadCircum3rd); series25th.Points.Add(new NumericDataPoint(HeadCircum25th, age, false)); double HeadCircum50th = Convert.ToDouble(rdr[06]);// - Convert.ToDouble(HeadCircum3rd); series50th.Points.Add(new NumericDataPoint(HeadCircum50th, age, false)); double HeadCircum75th = Convert.ToDouble(rdr[07]);// - Convert.ToDouble(HeadCircum3rd); series75th.Points.Add(new NumericDataPoint(HeadCircum75th, age, false)); double HeadCircum90th = Convert.ToDouble(rdr[08]);// - Convert.ToDouble(HeadCircum3rd); series90th.Points.Add(new NumericDataPoint(HeadCircum90th, age, false)); double HeadCircum95th = Convert.ToDouble(rdr[09]);// - Convert.ToDouble(HeadCircum3rd); series95th.Points.Add(new NumericDataPoint(HeadCircum95th, age, false)); double HeadCircum97th = Convert.ToDouble(rdr[10]);// - Convert.ToDouble(HeadCircum3rd); series97th.Points.Add(new NumericDataPoint(HeadCircum97th, age, false)); } #endregion ChartArea area = new ChartArea(); AxisItem xAxisForLine = new AxisItem(); xAxisForLine.OrientationType = AxisNumber.X_Axis; xAxisForLine.DataType = AxisDataType.String; xAxisForLine.SetLabelAxisType = SetLabelAxisType.ContinuousData; xAxisForLine.Labels.ItemFormatString = "<ITEM_LABEL>"; xAxisForLine.LineThickness = 4; xAxisForLine.Labels.ItemFormat = AxisItemLabelFormat.ItemLabel; xAxisForLine.Labels.Orientation = TextOrientation.VerticalRightFacing; xAxisForLine.Extent = 40; xAxisForLine.LineColor = Color.DodgerBlue; xAxisForLine.LineEndCapStyle = LineCapStyle.DiamondAnchor; AxisItem yAxisForLine = new AxisItem(); yAxisForLine.OrientationType = AxisNumber.Y_Axis; yAxisForLine.DataType = AxisDataType.Numeric; yAxisForLine.Labels.ItemFormatString = "<DATA_VALUE:##.##>"; yAxisForLine.Labels.ItemFormat = AxisItemLabelFormat.DataValue; yAxisForLine.Extent = 40; yAxisForLine.LineColor = Color.RoyalBlue; yAxisForLine.LineEndCapStyle = LineCapStyle.DiamondAnchor; yAxisForLine.LineThickness = 4; area.Axes.Add(xAxisForLine); area.Axes.Add(yAxisForLine); ChartLayerAppearance lineLayer = new ChartLayerAppearance(); lineLayer.ChartType = ChartType.SplineChart; lineLayer.Series.Add(series3rd); lineLayer.Series.Add(series5th); lineLayer.ChartArea = area; lineLayer.AxisX = xAxisForLine; lineLayer.AxisY = yAxisForLine; this.ultraChart1.CompositeChart.ChartAreas.Add(area); this.ultraChart1.CompositeChart.ChartLayers.Add(lineLayer); ChartLayerAppearance ScatterLayer = new ChartLayerAppearance(); ScatterLayer.AxisX = xAxisForLine; //ScatterLayer.AxisY = yAxisForLine; ScatterLayer.ChartArea = area; ScatterLayer.ChartType = ChartType.ScatterChart; NumericSeries mySeries = new NumericSeries(); mySeries.Points.Add(new NumericDataPoint(80, "23.5", false)); ScatterLayer.Series.Add(mySeries); ultraChart1.CompositeChart.ChartLayers.Add(ScatterLayer);
HI,
Try setting:
xAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.ContinuousData;
and let me know if this helps.