SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

Answered
0
0

Hello again,
I think this is a quickie 🙂 I have a template for the rollover bound to SeriesInfo and Im trying to get the axis title for the series and I cant find that property anywhere.
Here is my template. Thank you very much

<ItemsControl DataContext="{Binding ElementName=rolloverModifier}" ItemsSource="{Binding RolloverData.SeriesInfo}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <TextBlock Grid.Column="0" Grid.Row="0"
                           Margin="3,3,20,3"
                           FontSize="10"
                           FontWeight="Bold"
                           Foreground="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}"
                           Text="{Resx Distance}" />
                <TextBlock Grid.Column="1" Grid.Row="0"
                           Margin="3,3,3,3"
                           FontSize="10"
                           FontWeight="Bold"
                           Foreground="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}"
                           Text="{Binding XValue, Converter={StaticResource ComparableToDoubleConverter}}"  
                           />
                    
                <TextBlock Grid.Column="2" Grid.Row="0"
                           Margin="3,3,20,3"
                           FontSize="10"
                           FontWeight="Bold"
                           Foreground="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}"
                           Text="{Resx Speed}" />
                <TextBlock Grid.Column="3" Grid.Row="0"
                           Margin="3,3,3,3"
                           FontSize="10"
                           FontWeight="Bold"
                           Foreground="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}"
                           Text="{Binding YValue, Converter={StaticResource ComparableToDoubleConverter}}" />
            </Grid>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>
  • You must to post comments
Best Answer
1
0

Hi Marcel,

Please try out this solution – uses MultiBinding and ValueConverter, looks for AxisTitle using DataSeries.SeriesName, so you still need to set it, but to any value you want.

Put this inside the DataTemplate:

                        <TextBlock Grid.Row="0"
                                   Grid.Column="4"
                                   Margin="3,3,3,3"
                                   FontSize="10"
                                   FontWeight="Bold"
                                   Foreground="{Binding SeriesColor,
                                                        Converter={StaticResource ColorToBrushConverter}}">
                            <TextBlock.Text>
                                <MultiBinding Converter="{StaticResource SeriesNameToAxisTitleConverter}" Mode="OneTime">
                                    <Binding Path="SeriesName" />
                                    <Binding ElementName="sciChart" Path="." />
                                </MultiBinding>
                            </TextBlock.Text>
                        </TextBlock>

ValueConverter code:

    public class SeriesNameToAxisTitleConverter: IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var seriesName = (string)values[0];
            var sciChartSurface = (ISciChartSurface)values[1];

            var currentSeries =
                sciChartSurface.RenderableSeries.SingleOrDefault(series => series.DataSeries.SeriesName == seriesName);

            var yAxisId = currentSeries.YAxisId;
            var axisTitle = sciChartSurface.YAxes.Single(axis => axis.Id == yAxisId).AxisTitle;

            return axisTitle;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

Is this a suitable way to achieve what do you want?

Best regards,
Yuriy

  • Marcel
    Hello Yuriy, yes it is suitable, thank you very much! Have a nice day!
  • You must to post comments
0
0

I solved this problem by binding to SeriesName and set this before with the name for the YAxis, but surely there is a better way

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.