Implementation of ZedGraph's multiple Y-axis in Winform (with source code download)

Keywords: C# Attribute

scene

In Winforn, the attributes of ZedGraph curve, coordinate axis and scale are set:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100112573

Effect

 

Realization

Add two Y axes

ZedGraph has two Y axes by default, so it has its own YAxis attribute and Y2Axis attribute.

The first Y axis is displayed on the left by default and the second one on the right by default.

Open and set the second Y axis.

//Second article Y Axis heading
myPane.Y2Axis.Title.Text = "Second article Y Axis heading";
//Second article Y Shaft font
//myPane.Y2Axis.Title.FontSpec = myFont;
//Let second Y Shaft display
myPane.Y2Axis.IsVisible = true;

 

Add more Y-axis

More than two Y-axes will be added to the list of their Y-axes after they are newly built.

 // Creating Article 3 Y axis
            YAxis yAxis3 = new YAxis("Third article Y Axis heading");
            //Add to Y Axial list
            myPane.YAxisList.Add(yAxis3);
            //Setting the color of the scale line font
            yAxis3.Scale.FontSpec.FontColor = Color.Green;
            //Setting the font color of the title
            yAxis3.Title.FontSpec.FontColor = Color.Green;
            //Set up Y Shaft color
            yAxis3.Color = Color.Green;
            // turn off the opposite tics so the Y2 tics don't show up on the Y axis
            //Turn off the opposite tics,send y2 tics Not shown y Shaft
            yAxis3.MajorTic.IsInside = false;
            yAxis3.MinorTic.IsInside = false;
            yAxis3.MajorTic.IsOpposite = false;
            yAxis3.MinorTic.IsOpposite = false;
            // Align the Y2 axis labels so they are flush to the axis
            //alignment Y2 Axis label to align with axis
            yAxis3.Scale.Align = AlignP.Inside;

            // Creating Article 4 Y axis
            YAxis yAxis4 = new YAxis("Fourth article Y Axis heading");
            //Add to Y Axial list
            myPane.YAxisList.Add(yAxis4);
            yAxis4.Scale.FontSpec.FontColor = Color.Blue;
            yAxis4.Title.FontSpec.FontColor = Color.Blue;
            yAxis4.Color = Color.Blue;
            // turn off the opposite tics so the Y2 tics don't show up on the Y axis
            yAxis4.MajorTic.IsInside = false;
            yAxis4.MinorTic.IsInside = false;
            yAxis4.MajorTic.IsOpposite = false;
            yAxis4.MinorTic.IsOpposite = false;
            // Align the Y2 axis labels so they are flush to the axis
            yAxis4.Scale.Align = AlignP.Inside;

 

 

This is the creation of third and fourth Y axes, and more, and so on.

Source download

https://download.csdn.net/download/badao_liumang_qizhi/11635361

Posted by latino.ad7 on Sun, 06 Oct 2019 07:29:30 -0700