1

我正在尝试在 X 轴为对数刻度的 .NET 4.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 条次要网格线。

谢谢

4

2 回答 2

5

在用同样的问题把我的头撞在墙上几个小时之后,我似乎偶然发现了答案:

莫名其妙地,如果你将 MinorGrid Interval 设置为 1,那么你会得到传统的对数网格标记,每十年十个:

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

希望有帮助。

于 2012-10-08T16:05:47.280 回答
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>
于 2021-01-04T09:56:12.017 回答