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
Hi Graham,
If I specify the style as you have demonstrated for the legend in a resource dictionary then I get a "AG_E_PARSER_BAD_TYPE" runtime error. Why is that so? How can I resolve it?
Thanks
That resolves the issue. Thanks for all your help.
Does that work for your purposes?
-Graham
If you can decide the maximum width that you will allow for the legend, you can set it as the max with of the legend control and the width of the items control and you will get the desired truncation. The max width of the legend control is what drives the truncation of the labels, so just set it to whatever width you are setting for the items control in the fake canvas and you should be fine. Here is a screen shot:
And here is the xaml that produced it:
<igChart:Legend MaxWidth="150"> <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}"> <local:FakeCanvas x:Name="RootElement" HorizontalAlignment="Left" > <local:FakeCanvas.ItemsControl> <ListBox ScrollViewer.HorizontalScrollBarVisibility="Hidden" Height="70" Width="150" /> </local:FakeCanvas.ItemsControl> </local:FakeCanvas> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </igChart:Legend.Style> </igChart:Legend>
In my project the legend labels sometimes runs to as many as 30 characters . In such a scenario we cannot assign the width of the listbox to that of the label. Therefore I would want truncation or wrapping of label .
How can I achieve that? If I use default legend provided by infragistics the labels gets truncated. I would want the same functionality to continue.