By default, a legend is always drawn in a square shape. But it is very not convenient for LineSeries. Because in the legend you need to show not only the color, but also the type of line.
You can, of course, create your own ElementShape (https://www.telerik.com/forums/change-shape-of-items-in-legend). But there is very little space (bounds.Width = 10 pixels) and it is impossible to qualitatively draw a line of a certain type, for example, an extra-long dotted line.
If you try to draw outside the bounding box, then the chart either always cuts everything outside the bounds of this rectangle (ChartElement.LegendElement.StackElement.Orientation = Orientation.Vertical), or partially and not quite right (ChartElement.LegendElement.StackElement.Orientation = Orientation.Horizontal)
Example:
private void LegendElement_VisualItemCreating(object sender, LegendItemElementCreatingEventArgs e)
{
e.ItemElement = new LegendItemElement(e.LegendItem);
e.ItemElement.MarkerElement.Shape = new LineShape();
}
public class LineShape : ElementShape
{
public override GraphicsPath CreatePath(Rectangle bounds)
{
var path = new GraphicsPath();
var rect = new Rectangle(bounds.X - 50, bounds.Y + bounds.Height / 2, bounds.Width + 50, 2);
path.AddRectangle(rect);
return path;
}
}
What is the result drawn on the legend - see the attached image.
Obviously, the logic of drawing a legend for LineSeries, should be completely different. Current version - definitely not satisfied