CaptainBli
CaptainBli

Reputation: 4201

Syncfusion Chart Trackball Style

In my Syncfusion WPF application, ChartTrackBallBehavior shows I can add some style to ChartTrackBallStyle. The Style doesn't have any documentation. I can't figure out what I can set in the chart.

Has anyone used this control and styled the Label to match their corporate look? I need to change the look of the label that shows up in the Axis. I have found the following Setters for the Style so far that changes the appearance of the ball but not the label.

    <sfc:SfChart.Behaviors>
      <sfc:ChartTrackBallBehavior ShowLine="True" LabelHorizontalAlignment="Center" LabelVerticalAlignment="Near" >
        <sfc:ChartTrackBallBehavior.ChartTrackBallStyle>
          <Style TargetType="sfc:ChartTrackBallControl" >
            <Setter Property="Control.Visibility" Value="Visible" />
            <Setter Property="Control.Background" Value="AliceBlue" />
            <Setter Property="Control.FontSize" Value="6" />
          </Style>
        </sfc:ChartTrackBallBehavior.ChartTrackBallStyle>
      </sfc:ChartTrackBallBehavior>
    </sfc:SfChart.Behaviors>

Upvotes: 2

Views: 1172

Answers (2)

SilverTop87
SilverTop87

Reputation: 26

Use the template "TrackBallLabelTemplate", which is set in the definition of the Primary Axis, not in SfChart.Behaviors. Following is the code that worked for us:

<sfc:SfChart.PrimaryAxis>
    <sfc:DateTimeCategoryAxis Header="SomeText" PlotOffset="10"
        LabelFormat="yyyy/MM/dd hh:MM:ss" LabelTemplate="{StaticResource labelTemplate}" LabelsIntersectAction="Hide"
        ShowTrackBallInfo="True" TrackBallLabelTemplate="{StaticResource trackTemplateX}"/>
</sfc:SfChart.PrimaryAxis>

My template is defined as follows:

</Grid.Resources>
    <DataTemplate x:Key="trackTemplateX">
        <Grid Background="Black">
            <TextBlock Text="{Binding ValueX}" Foreground="White"  Margin="5" FontSize="14"/>
        </Grid>
    </DataTemplate>
</Grid.Resources>

Upvotes: 1

sheik abuthaheer
sheik abuthaheer

Reputation: 98

We are able to customize the track ball label style by using the TrackBallLabelTemplat property of ChartAxis as shown in the below code snippet

<sfchart:SfChart.PrimaryAxis>
         <sfchart:NumericalAxis  ShowTrackBallInfo="True" >
                  <sfchart:NumericalAxis.TrackBallLabelTemplate>
                          <DataTemplate >
                                <Border BorderThickness="2" BorderBrush="Black" Padding="3" Background="White">
                                      <TextBlock  FontSize="16" Text="{Binding ValueX}" Foreground="Black"></TextBlock>
                                </Border>
                           </DataTemplate>
                  </sfchart:NumericalAxis.TrackBallLabelTemplate>
         </sfchart:NumericalAxis>
</sfchart:SfChart.PrimaryAxis>

Upvotes: 2

Related Questions