I have a chart with the CursorModifier setting on. This CursorModifier shows the y-coordinate values of all the curves, as tooltips on the graph surface.
Is it possible to programmatically get these values in C# code, so as to display them in another part of the window simultaneously?
- Amarnath S asked 2 years ago
- You must login to post comments
H Amarnath,
Yes you can. The CursorModifier, RolloverModifier and TooltipModifier expose a property called SeriesData.
They all work the same way. If you look at the RolloverModifier documentation we have an example.
Consuming RolloverModifier.SeriesData in an ItemsControl
You can create a RolloverModifier legend in a few lines of XAML. Here is ours, below:
<Border Grid.Column="1" Margin="23,23" HorizontalAlignment="Left"
VerticalAlignment="Top" Background="#77222222"
BorderBrush="#323539" BorderThickness="2" Padding="5">
<Border.Effect>
<DropShadowEffect BlurRadius="10" ShadowDepth="5"
Color="Black" Direction="-45"/>
</Border.Effect>
<ItemsControl ItemsSource="{Binding ElementName=RolloverModifier,
Path=SeriesData.SeriesInfo}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!-- Bind to the SeriesName using the Stroke as foreground -->
<TextBlock Grid.Column="0"
Margin="3,3,20,3"
FontSize="13"
FontWeight="Bold"
Foreground="{Binding Stroke,
Converter={StaticResource ColorToBrushConverter}}"
Text="{Binding SeriesName}" />
<!-- Bind to the Series Value, using the Stroke as foreground-->
<!-- When binding to XValue, YValue of type IComparable, StringFormat
<!-- is mandatory due to a -->
<!-- XAML bug that cannot convert IComparable to text, even though
<!-- underlying type is double -->
<StackPanel Grid.Column="1"
Margin="3,3,20,3"
Orientation="Horizontal">
<TextBlock FontSize="13"
FontWeight="Bold"
Foreground="{Binding Stroke,
Converter={StaticResource ColorToBrushConverter}}"
Text="{Binding XValue,
StringFormat=X: \{0:0.00\}}" />
</StackPanel>
<StackPanel Grid.Column="2"
Margin="3,3,20,3"
Orientation="Horizontal">
<TextBlock FontSize="13"
FontWeight="Bold"
Foreground="{Binding Stroke,
Converter={StaticResource ColorToBrushConverter}}"
Text="{Binding YValue,
StringFormat=Y: \{0:0.00\}}" />
</StackPanel>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Best regards,
Andrew
- Andrew Burnett-Thompson answered 2 years ago
- You must login to post comments
Please login first to submit.