Pre loader

Virtualization and SciChartLegend

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

Hello!

I have a SciChartSurface with 193 series on it and my application needs to display a legend with 193 items. The requirement is that a legend should be located underneath the plot as a scrollable panel with items arranged in a wrap-panel fashion. The problem is that it takes a long time to render this many items because WrapPanel does not use Virtualization.

I found a 3-rd party control (https://github.com/sbaeumlisberger/VirtualizingWrapPanel) that implements virtualization in a WrapPanel. However, it is designed to work inside a ListBox/ListView and does not as an ItemPanelTemplate for SciChartLegend.

Is it possible to render LegendData in a custom control? I’ve noticed that LegendData is a ChartDataObject. However, when I bind its SeriesInfo property my ListBox is not populated.

Here is my XAML:

In my SciChartSurface I’ve added a modifier:

<s:SciChartSurface.ChartModifier>
                    <s:ModifierGroup>
                        <!--  Turn this legend off because we've got a custom one below  -->
                        <s:LegendModifier GetLegendDataFor="AllSeries" ShowLegend="False" />
                        <local:ErrorBarExclusionLegendModifier x:Name="mwErrorBarExcluder" />
                        <s:TooltipModifier />
                        <local:MouseClickChartModifier RightClickPosition="{Binding RightClickPosition, Mode=OneWayToSource}" />
                    </s:ModifierGroup>
</s:SciChartSurface.ChartModifier>

Then I declare a ListBox:

<ListBox
                Grid.Row="4"
                Grid.Column="0"
                Height="220"
                ItemTemplate="{StaticResource SciChartLegendItemTemplate}"
                ItemsSource="{Binding LegendData, ElementName=mwErrorBarExcluder, Converter={StaticResource SeriesConv}}">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <wtk:VirtualizingWrapPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>

Since I can’t bind ItemsSource to ChartDataObject I wrote a simple converter that extracts the collection of SeriesInfo objects:

public object Convert(object aValue, Type aTargetType, object aParameter, CultureInfo aCulture)
{
    ChartDataObject fSource = aValue as ChartDataObject;

    return fSource?.SeriesInfo;
}

What am I doing wrong?

Thank you in advance for your suggestions.

Version
6.2.1.13304
  • You must to post comments
0
0

I resolved my own issue. Turned out ErrorBarExclusionLegendModifier is a local class that filters series. It updated ChartDataObject.SeriesInfo but not the object itself so the PropertyChanged event was never fired. I modified it to expose ObservableCollection instead and removed the converter. Now it works. https://github.com/sbaeumlisberger/VirtualizingWrapPanel is a useful control.

  • You must to post comments
Showing 1 result
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