【问题标题】:Logarithmic Vertical and Horizontal Axes lines in MS Chart ControlMS 图表控件中的对数垂直和水平轴线
【发布时间】:2014-10-23 15:53:28
【问题描述】:

图像呈现对数图。我想使用 MS Chart 控件创建一个类似的图表。我知道有一种方法可以将普通图转换为对数图,但我无法创建类似于下图的垂直和水平轴线(浅灰色)。

【问题讨论】:

    标签: c# mschart


    【解决方案1】:

    您可以尝试将图表的轴IsLogarithmic 属性设置为true 并设置它们的MinorGrid,如下所示:

    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
    }
    

    用法:

    ChartArea area = chart1.ChartAreas[0];
    
    SetupAxis(area.AxisX);
    SetupAxis(area.AxisY);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 2020-01-15
      • 1970-01-01
      • 1970-01-01
      • 2013-05-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多