0

我正在使用 silverlight 工具包中提供的图表控件。

我已经定义了 3 个轴(下面的代码)。现在图表中的系列在用户的命令下发生变化。有时,不会显示原点的 0 值和最大轴值。它们不一定同时丢失。我不知道为什么会这样。该系列中的值与它们绑定在 (0, 1000) 上的范围相同。这种行为正常吗?

      <chartingToolkit:Chart.Axes>
            <chartingToolkit:LinearAxis x:Name="LeftYAxis"
                                        Orientation="Y"
                                        Location="Left"
                                        BorderThickness="0.5"
                                        >

                <chartingToolkit:LinearAxis.AxisLabelStyle>
                    <Style TargetType="chartingToolkit:AxisLabel" >
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="chartingToolkit:AxisLabel">
                                    <Grid Background="Transparent">
                                        <Border x:Name="AxisLabelMarker"
                                                Background="Transparent"
                                                BorderBrush="Blue"
                                                BorderThickness="0"
                                                >

                                            <TextBlock Text="{Binding}"
                                                       Grid.Column="0"
                                                       />
                                        </Border>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </chartingToolkit:LinearAxis.AxisLabelStyle>
            </chartingToolkit:LinearAxis>
            <chartingToolkit:CategoryAxis Orientation="X"
                                        Title="Percentage Increase in Bid Value"
                                        Location="Bottom"
                                        BorderThickness="0.5" 
                                       >

                <chartingToolkit:CategoryAxis.AxisLabelStyle>
                    <Style TargetType="chartingToolkit:AxisLabel" >
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="chartingToolkit:AxisLabel">
                                    <Grid Background="Transparent">
                                        <Border x:Name="AxisLabelMarker"
                                                Background="Transparent"
                                                BorderBrush="Blue"
                                                BorderThickness="0"
                                                >
                                            <TextBlock Text="{Binding}"
                                                       Grid.Column="0"
                                                       />
                                        </Border>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </chartingToolkit:CategoryAxis.AxisLabelStyle>
            </chartingToolkit:CategoryAxis>
            <chartingToolkit:LinearAxis x:Name="RightYAxis"
                                        Orientation="Y"
                                        Location="Right"
                                        BorderThickness="0.5"
                                        >
                <chartingToolkit:LinearAxis.AxisLabelStyle>
                    <Style TargetType="chartingToolkit:AxisLabel">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="chartingToolkit:AxisLabel">
                                    <TextBlock Text="{Binding}"
                                               />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </chartingToolkit:LinearAxis.AxisLabelStyle>
            </chartingToolkit:LinearAxis>
        </chartingToolkit:Chart.Axes>
4

1 回答 1

3

除非您在轴上指定最小值和最大值,否则工具包将自动为它们计算值。如果我上次查看源代码时没记错的话,它会尝试将设置值集中在图表区域的中心 80% 内,它会调整轴最小值和最大值以实现这一点。

既然您知道范围是 (0, 1000),只需将适当的MinimumMaximum属性添加到LinearAxis.

于 2010-02-17T22:24:27.480 回答