Exists a way to share the same legend between two chart areas ? I Would like to do something like this:
I'm using a RadChart with the property UseDefaultLayout equals false:
I create too a ChartLegend with the property UseAutoGeneratedItems equals true:
And after I created two ChartAreas
I created a PieSeries for each chartarea:
Note that I used the same Legend Label for both series, and the same Legend Name for both chart area, but when it is built on screen I had duplicated items. For example, Toyota appears twice and with same color. I would like to know if I can achieve the both chart sharing the same legend.
Thanks.
I'm using a RadChart with the property UseDefaultLayout equals false:
Telerik.Windows.Controls.RadChart telerikChart =
new
Telerik.Windows.Controls.RadChart();
telerikChart.UseDefaultLayout =
false
;
I create too a ChartLegend with the property UseAutoGeneratedItems equals true:
ChartLegend legend =
new
ChartLegend();
legend.UseAutoGeneratedItems =
true
;
legend.Header =
string
.Empty;
legend.Name =
"MyOwnLegend"
;
And after I created two ChartAreas
ChartArea firstChart =
new
ChartArea();
firstChart.LegendName =
"MyOwnLegend"
;
ChartArea secondChart =
new
ChartArea();
secondChart.LegendName =
"MyOwnLegend"
;
I created a PieSeries for each chartarea:
DataSeries firstPieSerie =
new
DataSeries();
firstPieSerie.Definition =
new
DoughnutSeriesDefinition();
firstPieSerie.Definition.ItemLabelFormat =
"p"
;
firstPieSerie.Add(
new
DataPoint() { YValue = 0.215208267, LegendLabel =
"Toyota"
});
firstPieSerie.Add(
new
DataPoint() { YValue = 0.192960612, LegendLabel =
"General Motors"
});
firstPieSerie.Add(
new
DataPoint() { YValue = 0.151830229, LegendLabel =
"Volkswagen"
});
firstPieSerie.Add(
new
DataPoint() { YValue = 0.125964366, LegendLabel =
"Ford"
});
firstPieSerie.Add(
new
DataPoint() { YValue = 0.091152353, LegendLabel =
"Honda"
});
firstPieSerie.Add(
new
DataPoint() { YValue = 0.079093251, LegendLabel =
"Nissan"
});
firstPieSerie.Add(
new
DataPoint() { YValue = 0.079093251, LegendLabel =
"PSA"
});
firstPieSerie.Add(
new
DataPoint() { YValue = 0.064697675, LegendLabel =
"Hyundai"
});
DataSeries secondPieSerie =
new
DataSeries();
secondPieSerie.Definition =
new
PieSeriesDefinition();
secondPieSerie.Definition.ItemLabelFormat =
"p"
;
secondPieSerie.Add(
new
DataPoint() { YValue = 0.215408267, LegendLabel =
"Toyota"
});
secondPieSerie.Add(
new
DataPoint() { YValue = 0.112460212, LegendLabel =
"General Motors"
});
secondPieSerie.Add(
new
DataPoint() { YValue = 0.111430229, LegendLabel =
"Volkswagen"
});
secondPieSerie.Add(
new
DataPoint() { YValue = 0.115464266, LegendLabel =
"Ford"
});
secondPieSerie.Add(
new
DataPoint() { YValue = 0.011452253, LegendLabel =
"Honda"
});
secondPieSerie.Add(
new
DataPoint() { YValue = 0.019493251, LegendLabel =
"Nissan"
});
secondPieSerie.Add(
new
DataPoint() { YValue = 0.019493251, LegendLabel =
"PSA"
});
secondPieSerie.Add(
new
DataPoint() { YValue = 0.014497275, LegendLabel =
"Hyundai"
});
Note that I used the same Legend Label for both series, and the same Legend Name for both chart area, but when it is built on screen I had duplicated items. For example, Toyota appears twice and with same color. I would like to know if I can achieve the both chart sharing the same legend.
Thanks.