I am trying write a template to Legend control. I have version 10.3, .net 4, xamDataChart, with a few line series.
My Legend is Horizontal and I want this to wrap when i have many items(series). Something thing like tab control showing multiple lines. Is this possible? I have to have my Legend at the Top.
I have custom Legend template and Legendtemplateitem, but it's not working. I just comented the ScrowViewer and replace this for a WrapPanel.
Any Help is welcome.
<ControlTemplate x:Key="xamDataChartLegendTemplate" TargetType ="Charts:Legend">
<Grid>
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="4" Background="{TemplateBinding Background}">
<Grid Margin="{TemplateBinding Padding }">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="0" Content="{TemplateBinding Content}" />
<!--<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="auto" VerticalScrollBarVisibility="auto" BorderThickness="0" Background="Transparent">-->
<WrapPanel Orientation="Horizontal" Grid.Row="1">
<ContentPresenter Grid.Row="1" x:Name="ContentPresenter" />
</WrapPanel>
<!--</ScrollViewer>-->
</Grid >
</Border>
<Border IsHitTestVisible="False" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" CornerRadius="4" Background="{StaticResource GenericOverlay}" />
</Grid>
</ControlTemplate>
<
DataTemplate x:Key="xamDataChartCustomLegendItemTemplate">
.Visibility}">
.LegendItemBadgeTemplate}" />
}"/>
Thanks. That did work. But I have another problem now. The legend doesn't render over the chart like the one showed in the example. The chart and legend come as two different entities. Is there a way to render the legend over the chart.
Hello,
I have been looking into your post and I can say that you have to add the Legend object to the Visual tree as well as the XamDataChart, so I can suggest you add the following code at the end of the one you have shared:
this.LayoutRoot.Children.Add(leg);
Hope this helps you.
Hi,
I am new Infragistics and I am trying to simply plot a 2 line series on the XamDataChart and show the legend for the two series through C# programming. Unfortunately the legend doesn't come up at all. Can I know what the reason might be. I am exactly using the same code as the given in the online documentation. Below is the code I am using. I would really appreciate if you could help me with this.
Thanks.
SimpleDataCollection data = new SimpleDataCollection(); XamDataChart DataChart = new XamDataChart(); Legend leg = new Legend { Content = "Legend", Margin = new Thickness(20), VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Right }; DataChart.Margin = new Thickness(5); DataChart.DataContext = data;
// XAxis CategoryXAxis xmXAxis = new CategoryXAxis(); xmXAxis.Interval = 50; xmXAxis.ItemsSource = data; xmXAxis.Label = "{Label}";
// YAxis NumericYAxis xmYAxis = new NumericYAxis(); DataChart.Axes.Add(xmXAxis); DataChart.Axes.Add(xmYAxis);
// Series LineSeries series = new LineSeries(); series.ValueMemberPath = "Value"; series.XAxis = xmXAxis; series.YAxis = xmYAxis; series.ItemsSource = data; series.Title = "Navya"; series.Legend = leg;
LineSeries series1 = new LineSeries(); series1.ValueMemberPath = "Value"; series1.XAxis = xmXAxis; series1.YAxis = xmYAxis; series1.ItemsSource = data; series1.Title = "nnn"; series1.Legend = leg; DataChart.Legend = leg; DataChart.Legend.Visibility = Visibility.Visible; DataChart.Series.Add(series); this.LayoutRoot.Children.Add(DataChart);
Hello Varun,
This Product Idea hasn't been implemented yet, but we will try to revisit it for the first version that will be shipped next year (13.1).
What is the status of this Product Idea - PI12060038.
Has this been incorporated in any of the release?