SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
Hi,
Is it possible to set legend item orientation to horizontal? Normally they all stack vertically.
Thanks,
Charith
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
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!
Please login first to submit.