0

保持简洁,并且我希望删除标签或至少从我的 X-Axis 修改它们:

在此处输入图像描述

我似乎正在使用这个库的修改版本,它允许我使用一些通常在 wp7 中不起作用的工具。

xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"

这是截至目前的 LineSeries 定义:

<charting:Chart x:Name="chart" Title="Humidity Readings" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Foreground="#FF3C58C8">
    <chartingToolkit:LineSeries x:Name="HumidityGraph" Title="Humidity" BorderThickness="2"  ItemsSource="{Binding Data}" IndependentValuePath="Time" DependentValuePath="Measurement"/>
</charting:Chart>

为了回应chridam,我尝试实施他的建议 - 没有成功。

            <charting:Chart x:Name="chart" Title="Humidity Readings" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Foreground="#FF3C58C8">
                <charting:Chart.LegendStyle>
                    <Style TargetType="visualizationToolkit:Legend">
                        <Setter Property="Width" Value="0"/>
                        <Setter Property="Height" Value="0"/>
                    </Style>

                </charting:Chart.LegendStyle>
                <!--there doesn't seem to be an AxisLabelStyle that I can create a style in.-->

                    <Style x:Key="EmptyStyle" TargetType="charting:NumericAxisLabel">
                        <Setter Property="StringFormat" Value="" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="charting:NumericAxisLabel">
                                    <TextBlock />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                <chartingToolkit:LineSeries x:Name="HumidityGraph" Title="Humidity" BorderThickness="2"  ItemsSource="{Binding Data}" IndependentValuePath="Time" DependentValuePath="Measurement" TransitionDuration="0:1:1.5" FontSize="18.667">
                    <charting:LinearAxis AxisLabelStyle="{StaticResource EmptyStyle}" Orientation="X" ShowGridLines="True"/>
                </chartingToolkit:LineSeries>
            </charting:Chart>
4

1 回答 1

1

尝试为 Axis Label 指定一种将StringFormat属性值设置为空的样式

<chartingToolkit:CategoryAxis> 
   <chartingToolkit:CategoryAxis.AxisLabelStyle> 
      <Style TargetType="AxisLabel"> 
         <Setter Property="StringFormat" Value=""></Setter> 
      </Style> 
   </chartingToolkit:CategoryAxis.AxisLabelStyle> 
</chartingToolkit:CategoryAxis>

更新: 另一种选择是应用样式模板

<Style x:Key="EmptyStyle" TargetType="charting:NumericAxisLabel"> 
    <Setter Property="StringFormat" Value="" /> 
    <Setter Property="Template"> 
        <Setter.Value> 
            <ControlTemplate TargetType="charting:NumericAxisLabel"> 
                <TextBlock /> 
            </ControlTemplate> 
        </Setter.Value> 
    </Setter> 
</Style>

对此:

<charting:LineSeries.DependentRangeAxis>    
        <charting:LinearAxis AxisLabelStyle="{StaticResource EmptyStyle}"    
            Orientation="X"    
            ShowGridLines="True"/>    
</charting:LineSeries.DependentRangeAxis>

有关设置图表样式的更多资源,样式化 Silverlight 图表

于 2012-10-19T08:22:10.863 回答