Avatar of ocaccy
ocaccy
Flag for Japan asked on

C# - Multi Splines on Chart Control.

Hi everyone.

In my app has myArray[x,5]. This myArray is populate every minute. I need add 5 Splines on the chart; one for each y in myArray. Put screenshot for viewing.
Although the values are differents, plot only this single line.
C#, VS2010 Ultimate, WinForms, not WPF.
All help is welcome, thanks in advance, ocaccy
single line spline chart
        public void AddData2_7()
            {
            DateTime timeStamp=DateTime.Now;

            foreach(Series ptSeries127 in chart2_7.Series)
                {
                AddNewPoint1227(timeStamp,ptSeries127);
                }
            }

        public void AddNewPoint1227(DateTime timeStamp,System.Windows.Forms.DataVisualization.Charting.Series ptSeries1227)
            {
            // Add new data point to its series.
            ptSeries1227.Points.AddXY(timeStamp.ToOADate(),Convert.ToDouble(a_s_Ritsu[cHR,3]));
            //ptSeries1227.Points.AddXY(timeStamp.ToOADate(),Convert.ToDouble(a_s_Ritsu[cHR,5]));
            //ptSeries1227.Points.AddXY(timeStamp.ToOADate(),Convert.ToDouble(a_s_Ritsu[cHR,7]));

            // remove all points from the source series older than 20 seconds.
            //double removeBefore = timeStamp.AddSeconds((double)(59) * (-1)).ToOADate();
            double removeBefore=timeStamp.AddMinutes((double)(10)*(-1)).ToOADate();

            //remove oldest values to maintain a constant number of data points
            while(ptSeries1227.Points[0].XValue<removeBefore)
                {
                ptSeries1227.Points.RemoveAt(0);
                }

            chart2_7.ChartAreas[0].AxisX.Minimum=ptSeries1227.Points[0].XValue;
            //chart2_7.ChartAreas[0].AxisX.Maximum = DateTime.FromOADate(ptSeries.Points[0].XValue).AddSeconds(60).ToOADate();
            chart2_7.ChartAreas[0].AxisX.Maximum=DateTime.FromOADate(ptSeries1227.Points[0].XValue).AddMinutes(10).ToOADate();
            chart2_7.Invalidate();
            }
void MakeChart()
	{
            #region chart2_7.Series.Add("seriesx")
            chart2_7.Series.Add("ID01");
            chart2_7.Series["ID01"].ChartArea="ChartArea1";
            chart2_7.Series["ID01"].ChartType=System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
            chart2_7.Series["ID01"].Color=System.Drawing.Color.Lime;
            chart2_7.Series["ID01"].Legend="Legend1";
            chart2_7.Series["ID01"].Name="ID01";

            chart2_7.Series.Add("ID02");
            chart2_7.Series["ID02"].ChartArea="ChartArea1";
            chart2_7.Series["ID02"].ChartType=System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
            chart2_7.Series["ID02"].Color=System.Drawing.Color.Orange;
            chart2_7.Series["ID02"].Legend="Legend1";
            chart2_7.Series["ID02"].Name="ID02";

            chart2_7.Series.Add("ID03");
            chart2_7.Series["ID03"].ChartArea="ChartArea1";
            chart2_7.Series["ID03"].ChartType=System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
            chart2_7.Series["ID03"].Color=System.Drawing.Color.BlueViolet;
            chart2_7.Series["ID03"].Legend="Legend1";
            chart2_7.Series["ID03"].Name="ID03";

            chart2_7.Series.Add("Warning");
            chart2_7.Series["Warning"].ChartArea="ChartArea1";
            chart2_7.Series["Warning"].ChartType=System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            chart2_7.Series["Warning"].Color=System.Drawing.Color.Blue;
            chart2_7.Series["Warning"].Legend="Legend1";
            chart2_7.Series["Warning"].Name="Warning";

            chart2_7.Series.Add("Alarm");
            chart2_7.Series["Alarm"].ChartArea="ChartArea1";
            chart2_7.Series["Alarm"].ChartType=System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            chart2_7.Series["Alarm"].Color=System.Drawing.Color.Red;
            chart2_7.Series["Alarm"].Legend="Legend1";
            chart2_7.Series["Alarm"].Name="Alarm";
            #endregion // chart2_7.Series.Add("seriesx")
}

Open in new window

C#.NET ProgrammingProgramming

Avatar of undefined
Last Comment
ocaccy

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ocaccy

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ocaccy

ASKER
This problem is over.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy