我正在尝试在.NET 4.0图表中设置固定数量的次网格线,其X轴是对数刻度。
我尝试设置“Axis.Minor.Interval”属性,这只会使网格线消失。
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个小网格线。
由于
答案 0 :(得分:5)
经过几个小时的撞击我的头在墙上遇到同样的问题,似乎我偶然发现了答案:
令人费解的是,如果将MinorGrid Interval设置为1,那么您将获得传统的对数网格标记,每十年十个:
aChart.ChartAreas[0].AxisX.IsLogarithmic = true;
aChart.ChartAreas[0].AxisX.MinorGrid.Interval = 1;
aChart.ChartAreas[0].AxisX.MinorGrid.Enabled = true;
希望有所帮助。
答案 1 :(得分:0)
这里也是一样。 我的 xaml 代码:
<WindowsFormsHost.Child>
<DVC:Chart
x:Name="MyChart"
Width="400"
Height="250"
BackColor="Transparent"
Paint="IdVgChart_Paint">
<DVC:Chart.ChartAreas>
<DVC:ChartArea x:Name="IdVgChartArea" BackColor="Transparent">
<DVC:ChartArea.AxisX>
<DVC:Axis
IntervalAutoMode="VariableCount"
IntervalOffset="0"
IntervalOffsetType="Auto"
IntervalType="Auto"
IsMarginVisible="False">
<DVC:Axis.MajorTickMark>
<DVC:TickMark LineWidth="2" />
</DVC:Axis.MajorTickMark>
<DVC:Axis.MinorTickMark>
<DVC:TickMark
Enabled="True"
LineWidth="1"
TickMarkStyle="OutsideArea" />
</DVC:Axis.MinorTickMark>
<DVC:Axis.MajorGrid>
<DVC:Grid
LineColor="Gray"
LineDashStyle="Dot"
LineWidth="2" />
</DVC:Axis.MajorGrid>
<DVC:Axis.MinorGrid>
<DVC:Grid
Enabled="true"
LineColor="Gray"
LineDashStyle="Dot"
LineWidth="1" />
</DVC:Axis.MinorGrid>
</DVC:Axis>
</DVC:ChartArea.AxisX>
<DVC:ChartArea.AxisY>
<DVC:Axis
Interval="0"
IntervalAutoMode="VariableCount"
IntervalOffset="0"
IntervalOffsetType="Number"
IntervalType="Number"
IsLogarithmic="True"
IsMarginVisible="False"
LogarithmBase="10"
Maximum="1e-4"
Minimum="1e-12">
<DVC:Axis.MajorTickMark>
<DVC:TickMark LineWidth="2" />
</DVC:Axis.MajorTickMark>
<DVC:Axis.MinorTickMark>
<DVC:TickMark
Enabled="True"
Interval="1"
LineWidth="1"
TickMarkStyle="OutsideArea" />
</DVC:Axis.MinorTickMark>
<DVC:Axis.MajorGrid>
<DVC:Grid
Enabled="True"
LineColor="Gray"
LineDashStyle="Dot"
LineWidth="2" />
</DVC:Axis.MajorGrid>
<DVC:Axis.MinorGrid>
<DVC:Grid
Enabled="true"
Interval="1"
LineColor="Gray"
LineDashStyle="Dot"
LineWidth="1" />
</DVC:Axis.MinorGrid>
</DVC:Axis>
</DVC:ChartArea.AxisY>
<DVC:ChartArea.CursorX>
<DVC:Cursor IsUserEnabled="False" IsUserSelectionEnabled="False" />
</DVC:ChartArea.CursorX>
<DVC:ChartArea.CursorY>
<DVC:Cursor IsUserEnabled="False" IsUserSelectionEnabled="False" />
</DVC:ChartArea.CursorY>
</DVC:ChartArea>
</DVC:Chart.ChartAreas>
</DVC:Chart>
</WindowsFormsHost.Child>