Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
534 views
in Technique[技术] by (71.8m points)

c# - Logarithmic Vertical and Horizontal Axes lines in MS Chart Control

The image presents a logarithmic graph. I want to create a similar graph using MS Chart control. I know there is a way to convert normal graph to logarithmic graph but i am not able to create vertical and horizontal axes lines (light gray in color) similar to the graph below.

Logarithmic graph with vertical and horizontal axes lines

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could try to set the chart's axes IsLogarithmic property to true and set up their MinorGrid as follows:

private static void SetupAxis(Axis axis)
{
    // Set the logarithmic scale mode:
    axis.IsLogarithmic = true;

    // Enable the minor grid lines:
    axis.MinorGrid.Enabled = true;
    // Set the color of the minor grid lines:
    axis.MinorGrid.LineColor = Color.Gray;
    // Set the inverval to 1:
    axis.MinorGrid.Interval = 1;

    // Enable the major grid lines:
    axis.MajorGrid.Enabled = true;
    // If not set, the major grid lines are defaulted to the black color
}

Usage:

ChartArea area = chart1.ChartAreas[0];

SetupAxis(area.AxisX);
SetupAxis(area.AxisY);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...