C# 在Microsoft';中,如何将MinorGrid行数固定为固定数;s.NET4.0图表?

C# 在Microsoft';中,如何将MinorGrid行数固定为固定数;s.NET4.0图表?,c#,winforms,charts,C#,Winforms,Charts,我试图在X轴为对数刻度的.NET4.0图表中设置固定数量的次要网格线 我尝试设置“Axis.Minor.Interval”属性,这只会使网格线消失 chart1.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount; chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Number; cha

我试图在X轴为对数刻度的.NET4.0图表中设置固定数量的次要网格线

我尝试设置“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条小网格线


谢谢

几个小时以来,我一直用同样的问题把头撞在墙上,似乎我无意中找到了答案:

令人费解的是,如果将MinorGrid间隔设置为1,则会得到传统的对数网格标记,每十年十次:

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

希望这能有所帮助。

在几个小时的时间里,我用同样的问题把头撞在墙上,似乎我无意中找到了答案:

令人费解的是,如果将MinorGrid间隔设置为1,则会得到传统的对数网格标记,每十年十次:

aChart.ChartAreas[0].AxisX.IsLogarithmic = true;
aChart.ChartAreas[0].AxisX.MinorGrid.Interval = 1;
aChart.ChartAreas[0].AxisX.MinorGrid.Enabled = true;
希望有帮助。

这里也有同样的事情。 我的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>

这里也一样。 我的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>


请只提供测试和工作代码。这无法编译。我将答案更新为C#,而以前是用VB。一个微不足道的改变。请只提供测试和工作代码。这无法编译。我将答案更新为C#,而以前是用VB。微不足道的变化。