If I have a large number of series (or data points in a single pie series), the legend gets cut off. I tried to template the chart to put a ScrollViewer around the LegendPanel, but that didn't work since the XamWebChart.cs code adds the LegendPanel to its RootElement, so I get this:
XamWebChart Warning: Element is already the child of another element
This was my template (which I applied in code behind):
<ControlTemplate TargetType="igChart:XamWebChart"> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <Grid x:Name="RootElement" Background="{TemplateBinding Background}" Margin="{TemplateBinding Padding}" > <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto" MaxWidth="200"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid x:Name="CaptionPanel" Grid.Row="0" Grid.ColumnSpan="2" Grid.Column="0"/> <Grid x:Name="ScenePanel" Grid.Column="0" Grid.Row="1"/> <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Grid.Column="1" Grid.Row="1" > <Grid x:Name="LegendPanel" Grid.Column="1" Grid.Row="1" /> </ScrollViewer> <!--<igChart:Legend x:Name="LegendPanel" Grid.Column="1" Grid.Row="1" MaxWidth="200"/>--> </Grid> </Border></ControlTemplate>
Is there any way to get some sort of scrolling in the legend so I can see all the items in a pie series (even beyond 50 or so gets cut off depending on the control size)?
Thanks,Keith
I've tried this solution and it only works if the legend items don't exceed the height of the canvas within the legend template. If it does the rest of the list will be clipped. I've tried replacing the canvas with a listbox and bind the list box source to the "items" property of the template but I get an empty list. I thought my binding was incorrect but when I debug the code and after the chart has been data bounded, I looked at the "chart.legend.items", I found that it was empty. Can anyone shine some light on this?
have you tried scrolling to the bottom of the legend? using the sample code i posted, the data in the legend will not be initially visible since there is only one series.
This code introduces a legend box with a scroll but no legend item is displayed. I am using infragistics data visualization chart. I am using the code you specified for silverlight but am still unable to see any data in the legend box.
Am I missing something?
OK, thanks that worked much better. :-)
whoops, the code i posted was for WPF and there is a slight difference. you need to change the ContentPresenter to a Canvas named RootElement.
<igChart:XamWebChart x:Name="XamWebChart1"> <igChart:XamWebChart.Legend> <igChart:Legend> <igChart:Legend.Style> <Style TargetType="igChart:Legend"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="igChart:Legend"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <ScrollViewer Height="200"> <Canvas x:Name="RootElement" Height="300"/> </ScrollViewer> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </igChart:Legend.Style> </igChart:Legend> </igChart:XamWebChart.Legend> <igChart:XamWebChart.Series> <igChart:Series ChartType="Column" Label="Series 1"> <igChart:Series.DataPoints> <igChart:DataPoint Value="10" Label="point1" /> <igChart:DataPoint Value="20" Label="point2" /> <igChart:DataPoint Value="30" Label="point3" /> </igChart:Series.DataPoints> </igChart:Series> </igChart:XamWebChart.Series> </igChart:XamWebChart>