Silverlight Toolkit图表删除网格线

时间:2014-09-16 12:46:37

标签: xaml silverlight charts toolkit

我继承了StackedColumnSeries图表上的工作,并将其转换为StackedBarSeries,因此图表就在我身边,我有两个问题:

  1. 最小值不会从零开始。
  2. 我无法隐藏垂直网格线。
  3. 请有人帮助我。

    xaml代码如下:

    <Style x:Key="XAxisLabel" TargetType="charting:AxisLabel">
        <Setter Property="StringFormat" Value="{}{0:#,k}"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="charting:AxisLabel">
                    <TextBlock Text="{TemplateBinding FormattedContent}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="YAxisLabel" TargetType="charting:AxisLabel">
        <Setter Property="StringFormat" Value=""></Setter>
        <Setter Property="Visibility" Value="Collapsed"></Setter>
    </Style>
    
    <Style x:Key="SummaryGraphStyle" TargetType="charting:Chart">
        <Setter Property="PlotAreaStyle">
            <Setter.Value>
                <Style TargetType="Grid">
                    <Setter Property="HorizontalAlignment" Value="Left"/>
                    <Setter Property="Background" Value="Transparent"/>
                </Style>
            </Setter.Value>
        </Setter>
    
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="charting:Chart">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <!--<datavis:Title Content="{TemplateBinding Title}" Style="{TemplateBinding TitleStyle}"/>-->
                            <Grid Margin="0,0,0,15" Grid.Row="1">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
    
                                <Charting_Primitives:EdgePanel x:Name="ChartArea">
                                    <Grid ShowGridLines="False" HorizontalAlignment="Left" Canvas.ZIndex="-1"/>
    
                                    <Border BorderBrush="Black" BorderThickness="1,0,0,0" Canvas.ZIndex="10"/>
    
                                </Charting_Primitives:EdgePanel>
                            </Grid>
    
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid ShowGridLines="False" HorizontalAlignment="Center" x:Name="SummaryGraphGrid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <charting:Chart Loaded="Loaded" Width="{Binding ElementName=Graph, Path=GraphWidth}" Grid.Column="0" BorderBrush="Transparent"  x:Name="SummaryGraph"
                                            Style="{StaticResource SummaryGraphStyle}" BorderThickness="0" 
                                            VerticalAlignment="Stretch" HorizontalAlignment="Center">
    
                <charting:Chart.Axes>
                    <charting:LinearAxis AxisLabelStyle="{StaticResource YAxisLabel}" Minimum="0" Location="Right" ShowGridLines="False" BorderThickness="0" Orientation="Y" Background="Transparent"/>
                    <charting:CategoryAxis AxisLabelStyle="{StaticResource XAxisLabel}" Margin="5,0,0,0" Location="Left" ShowGridLines="False" BorderThickness="0" Background="Transparent" Orientation="X" />
                </charting:Chart.Axes>
            </charting:Chart>
        </Grid>
    </Grid>
    

    Image of barchart with lines etc

1 个答案:

答案 0 :(得分:0)

我设法找到一段代码来解决这个问题,代码被添加了代码。

((StackedBarSeries)this.SummaryGraph.Series[0]).DependentAxis = new LinearAxis() { Minimum = 0, Orientation = AxisOrientation.X };

enter image description here