Pre loader

Advanced RolloverModifier: binding to XValues, Formatting Text

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

In addition to vaquita50’s post just now on RolloverModifier, I also want to output the x value (once for all series) in the rollover summary (but I don’t want to hijack that thread).

I also want to apply custom number formatting for each series. So series 0 number format might be “{N:3}”, series 1 might be “{0}g”, etc. Is such an example available or easy enough to produce?

Also, how do I force the box to exist, even when not over a valid x value? In the example, the box almost disappears to an empty (but still there!) border… ???

Thanks.
AC

  • You must to post comments
0
0

Hi Andy,

The RolloverModifier samples demonstrate that the RolloverModifier is simply a data-source, which gives you an ObservableCollection<SeriesInfo> to bind to.

There is a long explanation in the answer RolloverLabelTemplate show X and Y Value Separated which shows how to get the X Value in the Rollover legend output, and how to apply a custom string format to the X or Y Value.

Hope this helps,
Andrew

  • You must to post comments
0
0

Hi Andrew,

Already seen the examples, browsed through the definitions, not managed to make it work, hence here! I saw the XValue, but my output-x-value solution is all rather hacky. Not to worry – it works at least.

And in case anyone else needs to know, after much hacking around I came up with this to display something if there is no data…

            &lt;ItemsControl.Style&gt;
                &lt;Style TargetType=&quot;{x:Type ItemsControl}&quot;&gt;
                    &lt;Style.Triggers&gt;
                        &lt;DataTrigger Binding=&quot;{Binding Path=RolloverData.SeriesInfo,Converter={StaticResource EmptyCollectionConverter}}&quot; Value=&quot;True&quot;&gt;
                            &lt;Setter Property=&quot;Template&quot;&gt;
                                &lt;Setter.Value&gt;
                                    &lt;ControlTemplate TargetType=&quot;{x:Type ItemsControl}&quot;&gt;
                                        &lt;TextBlock Text=&quot;No data selected&quot; Margin=&quot;5,0&quot; HorizontalAlignment=&quot;Center&quot; /&gt;
                                    &lt;/ControlTemplate&gt;
                                &lt;/Setter.Value&gt;
                            &lt;/Setter&gt;
                        &lt;/DataTrigger&gt;
                    &lt;/Style.Triggers&gt;
                &lt;/Style&gt;
            &lt;/ItemsControl.Style&gt;



public class EmptyCollectionConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var collection = value as ICollection;

        if (collection == null)
        {
            return null;
        }

        return collection.Count == 0;
    }

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

Hope it helps someone!

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies