2012-10-18 37 views
0

保持自己简明扼要我要删除的标签或至少是从我的修改它们的点X轴:如何从该图表中删除X轴标签?

enter image description here

我似乎可以用这个库,使修改后的版本我使用一些工具通常不会在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> 

回答

0

尝试指定用于轴标签样式,设置了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> 

有关造型图表更多的资源,Styling a Silverlight Chart

+0

似乎你的代码不会在我的项目工作。 “类型'CategoryAxis'的值不能被添加到'Collection'1'类型的集合或字典中” – CodePrimate

+0

我已经完成了一个更新,你也许可以尝试一下,让我知道那是怎么回事。 – chridam

+0

我试了一堆不同的东西。我已经用所有代码更新了我的回复。似乎没有任何工作。 – CodePrimate