This is a migrated thread and some comments may be shown as answers.

RadLegend

13 Answers 534 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 05 Mar 2013, 12:35 PM
Hello,

I am struggling to include a  <telerik:RadLegendtag in my code. I have been using your documentation at http://www.telerik.com/help/wpf/radlegend-overview.html as a reference but always get an error message. 

I have included a reference to Telerik.Windows.Controls.dll as well as including xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" as a namespace declaration in my XAML, but whenever I try to use a <telerik:RadLegendtag I get an error stating "The type 'telerik:RadLegend' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been build."

Any help on this would be appreciated.

Andrew.




13 Answers, 1 is accepted

Sort by
0
Accepted
Goran
Top achievements
Rank 1
answered on 06 Mar 2013, 02:12 PM
Hi Andrew,

I am also having problems with RadLegend, but of other nature, so I bumped to your post while searching for information. Probably the reason that you receive such error is that you are having an older version of Telerik.Windows.Controls.dll referenced in your project. If I am not mistaken this control has been introduced in v2013_1_0220.

Since RadLegend currently supports only ChartView controls, you will also need to add reference to Telerik.Windows.Controls.Chart.dll and Telerik.Windows.Data.dll.
0
Andrew
Top achievements
Rank 1
answered on 07 Mar 2013, 03:33 PM
Thanks, Goran.

That was indeed the problem. I'd read in another forum post that the control was introduced Q4 2012, which is when we got the dlls. Updating to the latest dlls sorted the problem and I can now show legends with my pie charts. 

However I am now having another problem. I am populating my chart by binding the Item Source and setting the value and label of each section of the pie chart. Now whenever I set up a legend the legend labels only showing the percentages and I can't find a way of setting them to show the chart labels. Is there a way to set up the legend so that it shows the same labels I set on the chart?

Here is an example of what I'm trying to do: 

<telerik:RadPieChart x:Name="StatusChart" Palette="Metro">
                                 
    <telerik:RadPieChart.Behaviors>
        <telerik:ChartSelectionBehavior DataPointSelectionMode="Single" />
    </telerik:RadPieChart.Behaviors>
 
    <telerik:PieSeries Name="statusChartSeries" ItemsSource="{Binding}" ShowLabels="True">
                                     
        <telerik:PieSeries.LegendSettings>
            <telerik:DataPointLegendSettings />
        </telerik:PieSeries.LegendSettings>
                                     
        <telerik:PieSeries.ValueBinding>
            <telerik:PropertyNameDataPointBinding PropertyName="Value"/>
        </telerik:PieSeries.ValueBinding>
                                     
        <telerik:PieSeries.LabelDefinitions>
            <telerik:ChartSeriesLabelDefinition>
                <telerik:ChartSeriesLabelDefinition.Binding>
                    <telerik:PropertyNameDataPointBinding PropertyName="Name" />
                </telerik:ChartSeriesLabelDefinition.Binding>
            </telerik:ChartSeriesLabelDefinition>
        </telerik:PieSeries.LabelDefinitions>
                                     
    </telerik:PieSeries>
</telerik:RadPieChart>
 
<telerik:RadLegend Name="statusChartLegend" Items="{Binding ElementName=StatusChart, Path=LegendItems}"
            HorizontalAlignment="Left"  VerticalAlignment="Bottom" />

I have tried to set up the binding of the Legend in a similar way to the chart values and labels, using telerik:RadLegend.Items but they don't seem to have a telerik:PropertyNameDataPointBinding value. 

Any pointers?

Thanks.
0
Goran
Top achievements
Rank 1
answered on 07 Mar 2013, 04:15 PM
Hi Andrew,

RadLegend contains ItemTemplate property, which you can use for this purpose.You can access your custom type Name property using Presenter.DataItem.Name.

What I am having problems with, is that if a number of items is dynamically changed in the PieChart (Example from 5 slices to 4), RadLegend will still show 5 items, while PieChart will show 4).

Goran
0
Nurali
Top achievements
Rank 1
answered on 15 Jul 2013, 08:23 AM
I was facing off with this error when I was using standard telerik namespace. 

Then I changed it to 
xmlns:telerikLegend="clr-namespace:Telerik.Windows.Controls.ChartView;assembly=Telerik.Windows.Controls.Chart"

now it works.

(http://www.telerik.com/help/wpf/p_telerik_windows_controls_chartview_categoricalstrokedseries_legendsettings.html)

My All dll's version is 2013.2.611.40
0
Petar Marchev
Telerik team
answered on 16 Jul 2013, 12:14 PM
Hello,

Andrew, perhaps you can use the TitleBinding property of the DataPointLegendSettings:
<telerik:DataPointLegendSettings TitleBinding="Name" />

Regards,
Petar Marchev
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Vinay
Top achievements
Rank 1
answered on 04 Jul 2018, 05:19 AM

i have the  legend items getting displayed in the chart area. I should be able to select and deselect the legend items based on the user preference. Is there any option to that?

Please post your answers

0
Martin Ivanov
Telerik team
answered on 04 Jul 2018, 10:04 AM
Hello Vinay,

The RadLegend control doesn't support selection. Instead, you can use RadListBox with a custom ItemTemplate.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Vinay
Top achievements
Rank 1
answered on 05 Jul 2018, 02:03 PM

Thank you Martin.

I have one more doubt. Can we add more than one <telerik:RadLegend.ItemTemplate> in the radlegend control .

If not how do we acess the LIneseries of the radcartesian chart from the control that is placed outside the radcartesian chart area.

Please help.

 

 

0
Martin Ivanov
Telerik team
answered on 05 Jul 2018, 03:37 PM
Hello Vinay,

You can set only a single ItemTemplate. However, if you want you can implement template selection using a ContentControl and its ContentTemplateSelector property. For example:
<telerik:RadLegend.ItemTemplate>
    <DataTemplate>
        <ContentControl Content="{Binding}" ContentTemplateSelector="{StaticResource MyCustomTemplateSelector}" />
    </DataTemplate>
</telerik:RadLegend.ItemTemplate>

About accessing the series of the chart, you can use the Series property of RadCartesianChart. The property holds a collection with the chart's series. Alternatively, if you define the series in XAML you can set their Name property and then use it in code to access the series.

Additionally, I've found an old project of main that shows how to implement some custom selection-like behavior in RadLegend. I attached it here so you can give it a try and see if this could be a good starting point for implementing your requirement.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Vinay
Top achievements
Rank 1
answered on 10 Jul 2018, 08:50 AM

Hello Martin,

I have ellipses on the line series of the radcartesianchart. I have two horizontal annotations namely high and low. If the ellipses of the line series crosses these annotations, The ellipses should change their color. Could you please provide a solution for this?

Thanks

0
Martin Ivanov
Telerik team
answered on 10 Jul 2018, 01:24 PM
Hello Vinay,

We don't have an example showing this. However, you can achieve this using the DefaultVisualStyle property of the series . Here are few steps to follow in order to implement this:
  1. Define a property of type Brush in the view model of the data point.
  2. When the value from the view model of the data point crosses the low/high line value, set the Brush property to another color.
  3. Define a Style that targets the WPF native Path control and set it to the DefaultVisualStyle property of the series.
  4. Define a Setter in the Style that sets the Width and Height properties. 
  5. Define a Setter in the Style that sets the Fill property. Bind the value of the setter to the Brush property define the view model of the data point (see point 1). Also keep in mind that if the Palette property of the chart is set the Setter with the Fill property won't work.
Changing the value of the Brush property will be reflect in the UI, thus changing the color of the ellipse.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Vinay
Top achievements
Rank 1
answered on 25 Jul 2018, 07:23 AM

Hello Martin,

How do I print the RadcartesianChart?. I need to print the line series along with x and Y axis(complete graph).

Regrds,

Vinay

 

 

0
Martin Ivanov
Telerik team
answered on 25 Jul 2018, 08:53 AM
Hello Vinay,

You can see how to print the chart in the ChartView's Exporting example in the demos application.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Chart
Asked by
Andrew
Top achievements
Rank 1
Answers by
Goran
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Nurali
Top achievements
Rank 1
Petar Marchev
Telerik team
Vinay
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or