Pre loader

Horizontal orientation for legend

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

Hi,

Is it possible to set legend item orientation to horizontal? Normally they all stack vertically.

Thanks,
Charith

  • You must to post comments
0
0

Hi Charith,

Unfortunately, there aren’t any ways to do this except modifying control’s template. As a workaround, you could use VisualTreeHelper to get ItemsControl in code and change Orientation of used Panel, or replace it by another panel. Something like the following should help:

            var itemsControl = legendControl.Template.FindName("PART_LegendItems", legendControl) as ItemsControl;
            if (itemsControl != null)
            {
                var factoryPanel = new FrameworkElementFactory(typeof (StackPanel));
                factoryPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

                itemsControl.ItemsPanel = new ItemsPanelTemplate {VisualTree = factoryPanel};
            }

I logged your request and we will try to improve SciChartLegend in future.

Best regards,
Yuriy

  • Andrew Burnett-Thompson
    Just to add my 2p: Funnily enough someone else asked a similar question today on email. I would suggest re-templating as then you can do anything (That's the power of WPF!) There is a forum post on custom templating the Legend Control here. Hope this helps! Andrew
  • You must to post comments
0
0

Just an update, we are about to release SciChart v3.1, which will include a few enhancements to the legend. In v3.1, syntax to achieve a horizontal legend will include:

<!-- New to SciChart v3.1! LegendModifier exposes ability to dock a legend inside a chart, change orientation -->
<SciChart:LegendModifier  ShowLegend="True"
          LegendPlacement="Top"
          Orientation="Horizontal" 
          ShowSeriesMarkers="True"
          ShowVisibilityCheckboxes="True" 
          Margin="10" />

<!-- OR -->

<SciChartLegend Orientation="Horizontal"/>

That’s it!

  • 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