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

[Solved] Chart Legent Problem

4 Answers 128 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Francisco
Top achievements
Rank 1
Francisco asked on 29 Mar 2011, 07:30 PM

Hi,

I work with DynamicObject  and biding radgridview and the radgridview biding with radchart. When  view de chart de legent see the neme Item1, Item2, Item3 etc...  I want to see the series name what is the problem:

 

 

temMapping

 

 

itemMapping = new ItemMapping();

 

 

ChartDetail.SeriesMappings.Clear();

 

 

 

SeriesMapping seriesMapping = new SeriesMapping();

 

 

ChartDetail.ItemsSource = table.ToList();

 

 

 

 

 

string x = aChart[0].Replace("[", "").Replace("]", "");

 

 

 

 

string[] series = aChart[1].Replace("],[", "$").Replace("[", "").Replace("]", "").Split('$');

 

 

 

 

string[] sgroup = aChart[2].Replace("],[", "$").Replace("[", "").Replace("]", "").Split('$');

 

 

 

seriesMapping.SeriesDefinition =

 

new DoughnutSeriesDefinition();

 

ChartDetail.DefaultView.ChartLegend.Header = x;

ChartDetail.DefaultView.ChartTitle.Content = aChart[4].ToString().Trim();

itemMapping =

 

new ItemMapping();

 

 

itemMapping.DataPointMember =

 

DataPointMember.XCategory;

 

 

itemMapping.FieldName = x;
seriesMapping.LegendLabel = x;

 

seriesMapping.ItemMappings.Add(itemMapping);

 

 

 

for (int i = 0; i < series.Count(); i++)

 

 

{

 

itemMapping =

 

new ItemMapping();

 

 

itemMapping.DataPointMember =

 

DataPointMember.YValue;

 

 

itemMapping.FieldName = SLGeoviewerClassLibrary.Model.

 

Common.RemoveInvalidChars(series[i].ToString().Trim());

 

 

seriesMapping.ItemMappings.Add(itemMapping);

 

}

ChartDetail.SeriesMappings.Add(seriesMapping);

 

 

 


ChartDetail.SeriesMappings.Add(seriesMapping);

Please help me...... ;)

 

4 Answers, 1 is accepted

Sort by
0
Francisco
Top achievements
Rank 1
answered on 29 Mar 2011, 07:42 PM
0
Giuseppe
Telerik team
answered on 01 Apr 2011, 12:48 PM
Hi Francisco,

Generally the default legend display mode for Pie / Doughnut series types is LegendDisplayMode.DataPointLabel -- you need to set the seriesMapping.SeriesDefinition.LegendDisplayMode property to LegendDisplayMode.SeriesLabel in order to visualize the seriesMapping.LegendLabel value.

Note however that changing the legend display mode, will also change the coloring of the doughnut slices and all of them will be visualized in the same color.

If that is not what you want (i.e. you want to keep the distinct coloring of the doughnut slices), you can keep the legend display mode property as is, but disable the automatic generation of legend items by setting ChartLegend.UseAutoGeneratedItems property to false and then manually add ChartLegendItem to the ChartLegend.Items collection:
RadChart1.DefaultView.ChartLegend.UseAutoGeneratedItems = false;
RadChart1.DefaultView.ChartLegend.Items.Add(new ChartLegendItem() { Label = "TEST" });


Greetings,
Giuseppe
the Telerik team
0
Raja Rajeswari
Top achievements
Rank 1
answered on 28 Jul 2011, 08:19 AM
hi,

I have created the Pie chart with Legend lables by making Autogenerated columns = false
When i try to set the Interactivity settings Legend is not getting highlighted.What might be the reason
how to fix this issue.Please find the code that how i set the Legend.

 <telerik:ChartLegend Name="LegendPieflip" Visibility="Visible"    LegendItemMarkerShape="SquareRounded" UseAutoGeneratedItems="True"   >
                                                    <telerik:ChartLegendItem  Label="xxxx" MarkerFill="HotPink" ></telerik:ChartLegendItem>
                                                    <telerik:ChartLegendItem Label="yyyy" MarkerFill="DodgerBlue"></telerik:ChartLegendItem>
 
                                                </telerik:ChartLegend>

Regards,
Chakri

0
Giuseppe
Telerik team
answered on 01 Aug 2011, 03:24 PM
Hello Raja Rajeswari,

The built-in hover interactivity settings are supported only when the legend generates its items automatically. Could you elaborate why do you need to generate the legend items manually in your scenario?


Greetings,
Giuseppe
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
Chart
Asked by
Francisco
Top achievements
Rank 1
Answers by
Francisco
Top achievements
Rank 1
Giuseppe
Telerik team
Raja Rajeswari
Top achievements
Rank 1
Share this question
or