Nanang Hidayatulloh Ответов: 0

Направление графика zedgraph


Дорогой Мастер,

Я пытаюсь сделать плоттерную систему zedgraph на языке C# в системе измерения температуры и успешно построить график последовательных данных. Но направление не линейное, оно означает более низкую температуру не в первый раз, а в конце времени. Это мой код:



могу ли я изменить направление графика графика на линейное? как я могу это сделать?

Спасибо за вашу помощь

с уважением

Нананг

Что я уже пробовал:

<pre lang="C#">   // Set the titles and axis labels
            GraphPane myPane = ZedGraphControl1.GraphPane;

            //Set title axis labels and font color
            myPane.Title.Text = &quot;Temperature vs. Time&quot;;
            myPane.Title.FontSpec.FontColor = Color.Black;

            myPane.XAxis.Title.Text = &quot;Time (Sec)&quot;;
            myPane.XAxis.Title.FontSpec.FontColor = Color.Black;

            myPane.YAxis.Title.Text = &quot;Temperature (Celcius)&quot;;
            myPane.YAxis.Title.FontSpec.FontColor = Color.Black;

            //Fill the chart background with a color gradient
            myPane.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F);
            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F);

            myPane.XAxis.Scale.FontSpec.IsAntiAlias = true;
            myPane.YAxis.Scale.FontSpec.IsAntiAlias = true; 

            //Add grid lines to the plot and make them gray
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.MajorGrid.Color = Color.LightGray;

            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.Color = Color.LightGray;

            //Enable point value tooltips and handle point value event
            ZedGraphControl1.IsShowPointValues = true;
           ZedGraphControl1.PointValueEvent += new ZedGraphControl.PointValueHandler(PointValueHandler);

            //Show the horizontal scroll bar
            ZedGraphControl1.IsShowHScrollBar = true;

            //Automatically set the scrollable range to cover the data range from the curves
            ZedGraphControl1.IsAutoScrollRange = true;

            //Add 10% to scale range
            ZedGraphControl1.ScrollGrace = 0.1;

            //Horizontal pan and zoom allowed
            ZedGraphControl1.IsEnableHPan = true;
            ZedGraphControl1.IsEnableHZoom = true;

            //Vertical pan and zoom not allowed
            ZedGraphControl1.IsEnableVPan = false;
            ZedGraphControl1.IsEnableVZoom = false;

            //Set the initial viewed range
           // ZedGraphControl1.GraphPane.XAxis.Scale.MinAuto = true;
           // ZedGraphControl1.GraphPane.XAxis.Scale.MaxAuto = true;


            //Let Y-Axis range adjust to data range
            ZedGraphControl1.GraphPane.IsBoundedRanges = true;

            //Set the margins to 10 points
            myPane.Margin.All = 10;

            //Hide the legend
            // myPane.Legend.IsVisible = false;

            //Set start point for XAxis scale
            myPane.XAxis.Scale.BaseTic = 0;

            //Set start point for YAxis scale
            myPane.YAxis.Scale.BaseTic = 0;

            //Set max/min XAxis range
            myPane.XAxis.Scale.Min = 0.0;
           // myPane.XAxis.Scale.Max = 7200;
            myPane.XAxis.Scale.MinorStep = 5;
            myPane.XAxis.Scale.MajorStep = 10;


            //Set max/min YAxis range
            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.Max = 400;
            myPane.YAxis.Scale.MinorStep = 5;
            myPane.YAxis.Scale.MajorStep = 10;
            RollingPointPairList list = new RollingPointPairList(7400);

            //Initially, a curve is added with no data points (list is empty)
            //Color is red, and there will be no symbols
            //LineItem curve = myPane.AddCurve(&quot;Temperature&quot;, list, Color.Red, SymbolType.None);

            //Scale the axis
           myPane.AxisChange();


private void initCurves()
        {
            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();
            PointPairList list3 = new PointPairList();

            Samples = 10000;
            NoOfCurves = 3;

            // Samples = int.Parse(XTextBox.Text);
            // NoOfCurves = (int)NoOfDataNumericUpDown.Value;

            for (int j = 0; j &lt; NoOfCurves; j++)
            {
                PointPairList tempppl = new PointPairList();

                for (double x = 0; x &lt; Samples; x++)
                {
                    tempppl.Add(x, -1);
                }

                list1.Add(tempppl);
                list2.Add(tempppl);
                list3.Add(tempppl);

            }

            // Generate a red curve with diamond
            // symbols, and &quot;Porsche&quot; in the legend
            ZedGraphControl1.GraphPane.AddCurve(&quot;Thermocouple #1&quot;,list1, Color.Red, SymbolType.None);
            ZedGraphControl1.GraphPane.AddCurve(&quot;Thermocouple #2&quot;, list2, Color.Blue, SymbolType.None);
            ZedGraphControl1.GraphPane.AddCurve(&quot;Thermocouple #3&quot;, list3, Color.Brown, SymbolType.None);

            // Tell ZedGraph to refigure the
            // axes since the data have changed
            ZedGraphControl1.AxisChange();
        }</pre>

0 Ответов