开发者

Silverlight toolkit chart: axes do not always display 0 and maximum value

I am using the chart control provided in the silverlight toolkit.

I have defined 3 axes (code below). Now the series in the chart change at a user's command. Sometimes, the 0 value of the origin and the maximum axis value do not get displayed. They are not necessarily missing at the same time. I am out of idea on why this is happening. The values in the series are within the same range as they are bound on (0, 1000). Is this behaviour normal?

      <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>
                        开发者_StackOverflow社区    </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>


Unless you specify the Minimum and Maximum values on the Axis the toolkit will automaticaly calculate values for them. If I recall correctly from the last time I looked at teh source code it attempts to center the set values within a central 80% of the chart area, it adjust the Axis Minimum and Maximum values to acheive this.

Since you know that the range is (0, 1000) just add the appropriate Minimum and Maximum properties to the LinearAxis.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜