简体   繁体   中英

How do I remove the X axis labels from this chart?

Keeping myself concise and to the point I wish to remove the labels or at the very least modify them from my X-Axis :

在此处输入图片说明

I seem to be using a modified version of this library that allows me to use some tools usually won't work in wp7.

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

This is the LineSeries definitions as of right now :

<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>

In response to chridam I tried implementing his suggestion - No succes.

            <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>

Try specifying a style for Axis Label that sets the StringFormat property value to empty

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

Update: Another alternative is to apply the style template

<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>

to this:

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

For more resources on styling the chart, Styling a Silverlight Chart

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM