如何在Microsoft的.NET 4.0图表中将MinorGrid行的数量修复为固定数量? [英] How can I fix the number of MinorGrid lines to a fixed number in Microsoft's .NET 4.0 Chart?

查看:197
本文介绍了如何在Microsoft的.NET 4.0图表中将MinorGrid行的数量修复为固定数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在一个.NET 4.0图表中设置固定数量的次要网格线,其X轴为对数刻度。

I am trying to set a fixed number of minor grid lines in a .NET 4.0 Chart whose X axis is in a Logarithmic scale.

我尝试设置Axis.Minor.Interval属性,这只会使网格线消失。

I try to set the "Axis.Minor.Interval" property, this only makes the grid lines disappear.

chart1.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
            chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Number;
            chart1.ChartAreas[0].AxisX.Interval = 100d;

            chart1.ChartAreas[0].AxisX.MajorGrid.IntervalType = DateTimeIntervalType.Number;
            chart1.ChartAreas[0].AxisX.MajorGrid.IntervalOffsetType = DateTimeIntervalType.Number;
            chart1.ChartAreas[0].AxisX.MajorGrid.Interval = 10d;

            chart1.ChartAreas[0].AxisX.MinorGrid.IntervalType = DateTimeIntervalType.Number;
            chart1.ChartAreas[0].AxisX.MinorGrid.IntervalOffsetType = DateTimeIntervalType.Number;
            chart1.ChartAreas[0].AxisX.MinorGrid.Interval = 5;

我的目标是每十年有一个主网格的对数刻度,显示10条次网格线。

My goal is to have a logarithmic scale with a major grid every decade, showing 10 minor grid lines.

感谢

推荐答案

有相同的确切问题,它似乎我偶然得到的答案:

After hours of banging my head on the wall with the same exact problem, it seems I've stumbled onto the answer:

不可避免地,如果你设置MinorGrid间隔为1,那么你得到传统的对数网格标记,每十年十次:

Inexplicably, if you set the MinorGrid Interval to 1, then you get the traditional Logarithmic grid marks, ten per decade:

aChart.ChartAreas[0].AxisX.IsLogarithmic = true;
aChart.ChartAreas[0].AxisX.MinorGrid.Interval = 1;
aChart.ChartAreas[0].AxisX.MinorGrid.Enabled = true;

希望有帮助。

这篇关于如何在Microsoft的.NET 4.0图表中将MinorGrid行的数量修复为固定数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆