SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & 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.

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
    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.