MS图表控件中的对数垂直和水平轴线
该图像呈现对数图。 我想使用MS Chart控件创建一个类似的图形。 我知道有一种方法可以将法线图转换为对数图,但我无法创建垂直和水平轴线(浅灰色),类似于下图。
您可以尝试将图表的轴IsLogarithmic
属性设置为true
, MinorGrid
如下方式设置其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);