Hello, Chris,
To be honest, your approach is a tricky one, but it may achieve your goal. Well done!
However, I can suggest you a simpler approach. Actually, the square next to the legend text represents a
LegendItemMarker which is a derivative of
LightVisualElement. You can handle the ChartElement.LegendElement.
VisualItemCreating event, create the default
LegendItemElement and assign an
ElementShape to the ItemElement.MarkerElement.
Shape:
public
RadForm1()
{
InitializeComponent();
this
.radChartView1.ChartElement.LegendElement.VisualItemCreating += LegendElement_VisualItemCreating;
BarSeries barSeries =
new
BarSeries(
"Performance"
,
"RepresentativeName"
);
barSeries.LegendTitle =
"Q1"
;
barSeries.DataPoints.Add(
new
CategoricalDataPoint(177,
"Harley"
));
barSeries.DataPoints.Add(
new
CategoricalDataPoint(128,
"White"
));
barSeries.DataPoints.Add(
new
CategoricalDataPoint(143,
"Smith"
));
barSeries.DataPoints.Add(
new
CategoricalDataPoint(111,
"Jones"
));
barSeries.DataPoints.Add(
new
CategoricalDataPoint(118,
"Marshall"
));
this
.radChartView1.Series.Add(barSeries);
BarSeries barSeries2 =
new
BarSeries(
"Performance"
,
"RepresentativeName"
);
barSeries2.LegendTitle =
"Q2"
;
barSeries2.DataPoints.Add(
new
CategoricalDataPoint(153,
"Harley"
));
barSeries2.DataPoints.Add(
new
CategoricalDataPoint(141,
"White"
));
barSeries2.DataPoints.Add(
new
CategoricalDataPoint(130,
"Smith"
));
barSeries2.DataPoints.Add(
new
CategoricalDataPoint(88,
"Jones"
));
barSeries2.DataPoints.Add(
new
CategoricalDataPoint(109,
"Marshall"
));
this
.radChartView1.Series.Add(barSeries2);
this
.radChartView1.ShowLegend =
true
;
}
private
void
LegendElement_VisualItemCreating(
object
sender, LegendItemElementCreatingEventArgs e)
{
e.ItemElement =
new
LegendItemElement(e.LegendItem);
e.ItemElement.MarkerElement.Shape =
new
HeartShape();
}
You can also create your own
ElementShape and draw a single line as it is demonstrated below:
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get
quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.
Learn More.