Multiple Series on a Chart

Thread is closed for posting
1 posts, 0 answers
  1. Ebenezer
    Ebenezer avatar
    39 posts
    Member since:
    Dec 2012

    Posted 24 Jun 2014 Link to this post

    I need a urgent help trying to create multiple series on a chart. One series two is drawing on the chart and I don't know what I am missing. Below is my code and attached is an image of what I am getting now. I need something like what is in this link.
    http://www.telerik.com/help/reporting/understandingelementsseriesseriesproperties.html
    Any help will be appreciated.

    private void chart1_NeedDataSource(object sender, EventArgs e)
            {
                DataSet ds;
                Telerik.Reporting.Processing.Chart chart;
                DateTime stepDate;
                DateTime stepDateNew;
                string interval, AverageName, AverageNameNew, pointLabel, pointLabelnew, interval2;
                int average, Child1, Child2, step, statusId;

                if (_series == null || _seriesNew == null)
                {

                    chart = sender as Telerik.Reporting.Processing.Chart;

                    ds = CreateChartDataSet();

                    DataView view = ds.Tables[0].DefaultView;

                    Telerik.Reporting.Chart chartDef = (Telerik.Reporting.Chart)chart.ItemDefinition;
                    _series = new Telerik.Reporting.Charting.ChartSeries();
                    _seriesNew = new Telerik.Reporting.Charting.ChartSeries();

                    AverageName = string.Empty;
                    AverageNameNew = string.Empty;

                    SetXAxisRange(view);

                    foreach (DataRowView rowView in view)
                    {
                        statusId = (int)rowView["ID"];
                        step = int.Parse(rowView["Step"].ToString());
                        average = (int)rowView["average"];
                        interval = rowView["Interval"].ToString();
                        interval2 = rowView["IntervalNew"].ToString();
                        handlingPlanName = rowView["AverageName"].ToString();
                        handlingPlanNameNew = rowView["AverageNameNew"].ToString();
                        likelihood = (int)rowView["Child1"];
                        consequence = (int)rowView["Child2"];                   
                        if (interval != interval2 )
                        {
                            DateTime.TryParse(interval, out stepDate);
                            string str = null;
                            str += stepDate.ToString("MM/dd/yy");
                            pointLabel = str;
                        }

                        else
                            pointLabel = string.Empty;
                         
                        if (interval != interval2)
                        {
                            DateTime.TryParse(interval2, out stepDateNew);
                            string strNew = null;
                            strNew += stepDateNew.ToString("MM/dd/yy");
                            pointLabelnew = strNew;
                        }
                        else
                            pointLabelnew = string.Empty;

    /*******Below this  code is the only portion showing on the report ********************************************/
                        Telerik.Reporting.Charting.ChartSeriesItem seriesItem = CreateSeriesItem(pointLabel, average, statusId);

                        _series.AddItem(seriesItem);


                        Telerik.Reporting.Charting.ChartSeriesItem seriesItemNew = CreateSeriesItemNew(pointLabelnew, average, statusId);

                        _seriesNew.AddItem(seriesItemNew);
                        //}
                        foreach (DataRow dtrow in ds.Tables[0].Rows)
                        {

                            if (string.IsNullOrEmpty(handlingPlanName) && DateTime.TryParse(interval, out stepDate))
                                handlingPlanName = "New Report to Check Children's age";                                             

                        }
                        _series.Appearance.LineSeriesAppearance.Color = Color.Teal;
                        _series.Name = handlingPlanName;
                        _series.Type = ChartSeriesType.Line;
                        chart1.ChartTitle.TextBlock.Text = "New Report to Check Children's age";
                        chartDef.Series.Clear();
                        chartDef.Series.Add(_series);

                        foreach (DataRow dtrowNew in ds.Tables[0].Rows)
                        {
                            if (string.IsNullOrEmpty(AverageNameNew) && DateTime.TryParse(interval2, out stepDateNew))
                                handlingPlanNameNew = "New Report to Check Children's age";

                        }
                        _seriesNew.Appearance.LineSeriesAppearance.Color = System.Drawing.Color.Black;
                        _seriesNew.Appearance.LineSeriesAppearance.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
                        _seriesNew.Appearance.LineSeriesAppearance.PenStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                        _seriesNew.Appearance.LineSeriesAppearance.Width = 5;
                        _seriesNew.Name = AverageNameNew;
                        _seriesNew.Type = ChartSeriesType.Line;
                        chart1.ChartTitle.TextBlock.Text = "New Report to Check Children's age";
                        chartDef.Series.Clear();
                        chartDef.Series.Add(_seriesNew);

                    }

                }

            }
Back to Top