$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
How to put up legends of chart toolkit using c#
Home > How to > Chart Legend
What is legend used for? The element legend owns the ability to specify the representing meaning of each data series with a preset symbol and a name. And the legend element can be visible or invisible in the chart.
How to add a custom legend to chart using C# programming code? The KaxChart control allows users to modify and set many properties of the legend, like position, size, spacing, color, text and symbol style. And from this online tutorial, you will find detailed C# programming example for customizing the chart legend in ASP.NET application.

Legend Properties

Following four properties are used to help you modify and customize the settings of chart legend element. Changing the legend lable attributes to edit the style and appearance to distinguish the multiple series data surface.
  • Visible: you are free to display or hide the legend in the chart.
  • Appearance: the Appearance property allows users to design the size, the rotation degree, the fill type (like solid) and the color of the legend element. To put it in another way, this property controls the general look of the legend element.
  • Items: this property is responsible for the legend symbols and text that are used to represent each data series.
  • TextBlock: this property is offered to control the default text and appearance.
Here we offer a programming example which will show you how to use above mentioned legend properties using C# code.

KaxChart1.Legend.Visible = true;
KaxChart1.Legend.TextArea.Text = "Legend";
KaxChart1.Legend.TextArea.StyleSet.Fill.FillMode = ChartFillMode.Solid;
KaxChart1.Legend.TextArea.StyleSet.Fill.PrimaryColor = System.Drawing.Color.DarkOrange;

C# Code for Legend Layout

The layout of chart legend element covers several aspects, including legend sizing dimensions, legend position and the symbol of legend.
  1. Change the symbol of legend: the symbol that the legend uses to present each data series can be changed to different shapes, like circle, rectangle and diamond.
  2. Define the size of legend element: the height and width of legend can be customized respectively.
  3. Set the position of legend element: the legend can be placed at your desired location, like TopRight, CenterRight, BottomRight, Top, Center, Bottom, TopLeft, CenterLeft and BottomLeft. And all the legends will display horizontally.
Here we also attach a programming example for you to customize the legend layout using C# code.

KaxChart1.Legend.StyleSet.Position.AlignedPosition = AlignedPositions.TopRight;
KaxChart1.Legend.StyleSet.Border.Width = 3;
KaxChart1.Legend.StyleSet.Border.Color = System.Drawing.Color.CadetBlue;
Here we also attach a programming example for you to customize the legend layout using C# code.
ASP.NET AJAX UI Controls