⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmgraph.cs

📁 车载GPS?今天这个就是最好的工具
💻 CS
📖 第 1 页 / 共 5 页
字号:

                /*////////////////////////////////////////
                // From MouseMove event of Pego control //
                //////////////////////////////////////////
                private void Pego1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
                {
                    Int32 nA;
                    Int32 nX; 
                    Int32 nY;
                    Double fX = 0;
                    Double fY = 0; 				  
                    Int32 nLeft;
                    Int32 nTop; 
                    Int32 nRight; 
                    Int32 nBottom; 
                    Int32 pX;  
                    Int32 pY;
                    System.Drawing.Point pt;				
                    System.Drawing.Rectangle rect;  

                    // get last mouse location within control //'
                    pt = Pego1.PeUserInterface.Cursor.LastMouseMove;
                    pX = pt.X;
                    pY = pt.Y;

                    // test to see if this is within grid area //'
                    rect = Pego1.PeFunction.GetRectGraph();
                    nTop = rect.Top;
                    nLeft = rect.Left;
                    nRight = rect.Right;
                    nBottom = rect.Bottom;

                    if( pX > nLeft && pX < nRight && pY > nTop && pY < nBottom)
                    {
                        nA = 0;      // Initialize axis if using OverlapMultiAxes, else this function will
                                     // return the axis if MultiAxesSubsets is used without OverlapMultiAxes
                        nX = pX;     // Initialize nX and nY with mouse location
                        nY = pY;
                        Pego1.PeFunction.ConvPixelToGraph(ref nA,ref nX,ref nY,ref fX,ref fY, false, false, false);
                        this.Text = fX.ToString() + "   -   " + fY.ToString();
                    }
                    else	
                        this.Text = "Outside Grid";
                }
                *///////////////////////////////////////////////////////
            }
            else if(m_nChart == 8)
            {
                //*********************************************************************'
                //*********************************************************************'
                //008  Graph showing use of PointColors

                //! Right button click to show popup menu. //
                //! Double Click to show customization dialog. //
                //! Vertical scroll bar revolves through subsets. //

                // This example builds upon the basic CreateSimpleGraph '000' example chart //
                CreateSimpleGraph();

                // Now to control color on per point basis, we use the
                // PointColors property array to assign a color to each
                // piece of YData.
                Int32 s, p;
                for( s = 0; s <= 3; s++)
                {
                    for( p = 0; p <= 11; p++)
                    {
                        if (s == 0)
                            Pego1.PeColor.PointColors[s, p] = Color.FromArgb(15 + ((p + 1) * 20), 0, 0);
                        else if (s == 1) 
                            Pego1.PeColor.PointColors[s, p] = Color.FromArgb(0, 15 + ((p + 1) * 20), 0);
                        else if (s == 2) 
                            Pego1.PeColor.PointColors[s, p] = Color.FromArgb(0, 0, 15 + ((p + 1) * 20));
                        else if(s == 3) 
                            Pego1.PeColor.PointColors[s, p] = Color.FromArgb(0, 15 + ((p + 1) * 20), 15 + ((p + 1) * 20));
                    }
                }

                // Set SubsetColor to match brightest PointColor for each subset //
                Pego1.PeColor.SubsetColors[0] = Color.FromArgb(198, 0, 0);
                Pego1.PeColor.SubsetColors[1] = Color.FromArgb(0, 198, 0);
                Pego1.PeColor.SubsetColors[2] = Color.FromArgb(0, 0, 198);
                Pego1.PeColor.SubsetColors[3] = Color.FromArgb(0, 198, 198);

                // Show 1 subset at a time //
                Pego1.PeUserInterface.Scrollbar.ScrollingSubsets = 1;

                Pego1.PeTable.What = TableWhat.AllSubsets;
                Pego1.PeFont.FontSize = FontSize.Large;

                // Change some colors //
                Pego1.PeColor.GraphBackground = Color.Empty;
                Pego1.PeColor.GraphGradientStyle = 0;
                Pego1.PeColor.Shadow = Color.Black;

                // Or, to get rid of legend, un-comment this code //'
                // Pego1.SubsetsToLegend[0] = -1;

                // Add a table //
                Pego1.PeTable.Show = GraphPlusTable.Both;
                Pego1.PeData.Precision = 0;

                // Slant the Point Labels //
                Pego1.PeGrid.ForceVerticalPoints = ForceVerticalPoints.Slanted;

                Pego1.PePlot.Method = GraphPlottingMethod.Bar;
                Pego1.PeConfigure.BorderTypes = TABorder.NoBorder;
            }
            else if(m_nChart == 9)
            {
                //*********************************************************************'
                //*********************************************************************'
                //009  Graph showing use of BestFitCoeffs

                // This example builds upon the basic CreateSimpleGraph '000' example chart //
                CreateSimpleGraph();

                // Reduce to just two subsets //
                Pego1.PeData.Subsets = 2;

                // Set BestFitDegree and Plotting Method //
                Pego1.PePlot.Option.BestFitDegree = BestFitDegree.Third;
                Pego1.PePlot.Method = GraphPlottingMethod.PointsPlusBestFitCurve;

                // Call PEreinitialize and PEresetimage //
                Pego1.PeFunction.Reinitialize();     // Reinitialize can be used to read ManualMaxY, etc
                Pego1.PeFunction.ResetImage(0, 0);   // ResetImage is needed to calculate coeffs.

                // Now add annotations that represents coefficients //

                //** First subset's coeffs. **'
                String t;
                t = "Texas y = " + String.Format( "{0:#.##}", Pego1.PePlot.Option.BestFitCoeffs[0, 3]) + "x^3 ";
                if(Pego1.PePlot.Option.BestFitCoeffs[0, 2] >= 0)
                    t = t + "+ ";
                t = t + String.Format("{0:#.##}", Pego1.PePlot.Option.BestFitCoeffs[0, 2]) + "x^2 ";
                if(Pego1.PePlot.Option.BestFitCoeffs[0, 1] >= 0)
                    t = t + "+ ";
                t = t + String.Format("{0:#.##}", Pego1.PePlot.Option.BestFitCoeffs[0, 1]) + "x ";
                if(Pego1.PePlot.Option.BestFitCoeffs[0, 0] >= 0)
                    t = t + "+ ";
                t = t + String.Format("{0:#.##}", Pego1.PePlot.Option.BestFitCoeffs[0, 0]);
                t = t + '\n'; // Line feed

                // Second subset's coeffs. //
                t =  t + "Florida y = " + String.Format("{0:#.##}", Pego1.PePlot.Option.BestFitCoeffs[1, 3]) + "x^3 ";
                if(Pego1.PePlot.Option.BestFitCoeffs[1, 2] >= 0)
                    t = t + "+ ";
                t = t + String.Format("{0:#.##}", Pego1.PePlot.Option.BestFitCoeffs[1, 2]) + "x^2 ";
                if(Pego1.PePlot.Option.BestFitCoeffs[1, 1] >= 0)
                    t = t + "+ ";
                t = t + String.Format("{0:#.##}", Pego1.PePlot.Option.BestFitCoeffs[1, 1]) + "x ";
                if(Pego1.PePlot.Option.BestFitCoeffs[1, 0] >= 0)
                    t = t + "+ ";
                t = t + String.Format("{0:#.##}", Pego1.PePlot.Option.BestFitCoeffs[1, 0]);

                // Put text into a line annotations //'
                Pego1.PeAnnotation.Line.YAxis[0] = Pego1.PeGrid.Configure.ManualMaxY - 1;
                //Pego1.PeAnnotation.Line.HorizontalType[0] = -1;  // no line, just text
                Pego1.PeAnnotation.Line.YAxisText[0] = t;

                // Increases line annotation text size to max
                Pego1.PeFont.LineAnnotationTextSize = 100;
                Pego1.PeAnnotation.Show = true;
            }
            else if(m_nChart == 10)
            {
                //*********************************************************************'
                //*********************************************************************'
                //010  Graph showing Stacked Bar

                //! Try this... Right Click chart and change the Plotting Method to Horizontal Bar Stacked. //

                // This example builds upon the basic CreateSimpleGraph '000' example chart //
                CreateSimpleGraph();

                // Enable Stacked type charts //
                Pego1.PePlot.Allow.StackedData = true;
                Pego1.PePlot.Allow.HorzBarStacked = true;

                // Set plotting method //
                Pego1.PePlot.Method = GraphPlottingMethod.BarStacked;

                // Add a table //
                Pego1.PeTable.Show = GraphPlusTable.Both;
                Pego1.PeData.Precision = DataPrecision.TwoDecimals;
            }
            else if(m_nChart == 11)
            {
                //*********************************************************************'
                //*********************************************************************'
                //011  Graph showing MultiSubTitles

                //! Look for the text immediately above and below image. //

                // This example builds upon the basic CreateSimpleGraph '000' example chart //
                CreateSimpleGraph();

                //! Note that strings below always have two pipe symbols "|" //

                // Set Multi Sub and Bottom Titles //
                Pego1.PeString.MultiSubTitles[0] = "Top Left|Top Center|Top Right";
                Pego1.PeString.MultiSubTitles[1] = "|Second Line only centered|";

                // Note that bottom titles get drawn from bottom up //
                Pego1.PeString.MultiBottomTitles[0] = "Second Line only on left||";
                Pego1.PeString.MultiBottomTitles[1] = "Bottom Left|Bottom Center|Bottom Right";

                // Other various properties //
                Pego1.PeColor.BitmapGradientMode = true;
                Pego1.PeColor.QuickStyle = QuickStyle.LightLine;
                Pego1.PePlot.MarkDataPoints = true;
            }
            else if(m_nChart == 12)
            {
                //*********************************************************************'
                //*********************************************************************'
                //012  Graph showing MultiAxesSubsets 1

                //! Right button click to show popup menu. //
                //! Double Click to show customization dialog. //
                //! Left-Click and drag to draw zoom box. Use popup memu or 'z' to undo zoom. //

                // This example builds upon the basic CreateSimpleGraph '000' example chart //
                CreateSimpleGraph();

                // Now sub-divide subsets into 4 individual axes //
                // Each axis with one subset in each //
                Pego1.PeGrid.MultiAxesSubsets[0] = 1;
                Pego1.PeGrid.MultiAxesSubsets[1] = 1;
                Pego1.PeGrid.MultiAxesSubsets[2] = 1;
                Pego1.PeGrid.MultiAxesSubsets[3] = 1;

                // Set first axis parameters //
                Pego1.PeGrid.WorkingAxis = 0;
                Pego1.PeString.YAxisLabel = "Label 1";
                Pego1.PePlot.Method = GraphPlottingMethod.Bar;

                // Set second axis parameters //
                Pego1.PeGrid.WorkingAxis = 1;
                Pego1.PeString.YAxisLabel = "Label 2";
                Pego1.PePlot.Method = GraphPlottingMethod.Bar;
                Pego1.PeGrid.Configure.YAxisScaleControl = ScaleControl.Log;

                // Set third axis parameters //
                Pego1.PeGrid.WorkingAxis = 2;
                Pego1.PeString.YAxisLabel = "Label 3";
                Pego1.PePlot.Method = GraphPlottingMethod.Bar;

                // Set fourth axis parameters //
                Pego1.PeGrid.WorkingAxis = 3;
                Pego1.PeString.YAxisLabel = "Label 4";
                Pego1.PePlot.Method = GraphPlottingMethod.Bar;

                // Reset WorkingAxis when done //
                Pego1.PeGrid.WorkingAxis = 0;

                // Add Axis Separator //
                Pego1.PeGrid.Option.MultiAxesSeparators = MultiAxesSeparators.ThickPlusTick;

                // Axis Sizing //
                Pego1.PeUserInterface.Allow.MultiAxesSizing = true;

                // Get rid of 3d stuff //
                Pego1.PePlot.DataShadows = DataShadows.None;

                // Other various properties //
                Pego1.PeColor.BitmapGradientMode = true;
                Pego1.PeColor.QuickStyle = QuickStyle.DarkNoBorder;
                Pego1.PePlot.MarkDataPoints = true;

            }
            else if(m_nChart == 13)
            {
                //*********************************************************************'
                //*********************************************************************'
                //013  Graph showing MultiAxesSubsets 2

                //! Right button click to show popup menu. //
                //! Double Click to show customization dialog. //
                //! Left-Click and drag to draw zoom box. Use popup memu or 'z' to undo zoom. //

                // This example builds upon the basic CreateSimpleGraph '000' example chart //
                CreateSimpleGraph();

                // Now sub-divide subsets 4 into individual axes //
                // Each axis with 2 subsets in each //
                Pego1.PeGrid.MultiAxesSubsets[0] = 2;
                Pego1.PeGrid.MultiAxesSubsets[1] = 2;

                // Set first axis parameters //
                Pego1.PeGrid.WorkingAxis = 0;
                Pego1.PeString.YAxisLabel = "Label 1";
                Pego1.PePlot.Method = GraphPlottingMethod.Bar;

                // Set second axis parameters //
                Pego1.PeGrid.WorkingAxis = 1;
                Pego1.PeString.YAxisLabel = "Label 2";
                Pego1.PePlot.Method = GraphPlottingMethod.Bar;

                // Reset WorkingAxis when done //
                Pego1.PeGrid.WorkingAxis = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -