Legend of Chart for WinForms C# Tutorial
The Windows Forms Chart control offers the support for the legends that is the descriptions of the charts on the plot. The items in the legend are series specific for the pie chart, and the data points will be displayed in the legend. There will be only one item displayed for line series for each series.
How to Display Legend in Chart
The property of DisplayLegend included in the Chart controls for Windows Forms determines if the legend will be displayed or not. The default value of the DisplayLegend is left as false. The legend for Chart is able to display a legend title and users can display the title text by using the property of LegendTitle.
How to Customize Legend in Chart
Users can change the position of the Chart title by using the property of TitleLocation. If we want to customize more of the title, we can use the TitleElement
Users can also dock the legend to each side of the Chart control by customizing the LegendLocation property.
The property of LegendLocation can be set to float over the chart view. The below C# code shows how to set the legend to stay at the location 120, 10 over the chart area. The LegendOffset property is only taken into consideration when the LegendLocation is set to Float.
How to Setup LegendItem in Chart
The individual data points are the elements that provide legend items in the Pie chart. Besides the Pie chart, the legend items will be provided by the series. Developers need to set two properties, DisplayInLegend and LegendTitle, to each provider so that to control the representation of legend items in the legend. These two properties are.
How to Change Title of LegendItem for Chart
The Items property of the chart legend can be used to customize the title. When users change the text in the legend item, the text in the data point or series will also change. The below C# code can be used to add the line series to the chart and change the title of the legend item via the legend Items collection.
How to Add and Remove LegendItems
To add or remove items from the legend by using the Items collection, we need to create a new instance of LegendItem and add to the Items collection. The Element property of the LegendItem allows users customizing the style of the marker.
|
UI Controlsfor Windows Forms .NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI DesignWinForms UI Controls WinForms Buttons UI Control WinForms Calendar UI ControlWinForms Carousel UI ControlWinForms Chart UI ControlChart PropertyChart GridChart Series TypesChart Series - AreaChart Series - BarChart Series - LineChart Series - ScatterChart Series - ScatterLineChart Series - PieChart Series - DonutChart Series - PolarChart Series - RadarChart AxesChart Axes - CategoricalChart Axes - DateTimeChart Axes - LinearChart Axes - LogarithmicChart Axes - PolarChart Axes - PlotModeChart Axes - RadicalChart Axes - Multiple AxesChart FeatureChart - Scroll and ZoomChart - SelectionChart - TooltipChart - TrackballChart - TitleChart - LegendChart - Smart LabelsChart - Drill DownChart Data BindingChart Custom PaletteChart Custom RenderingWinForms Clock UI ControlCommandBar UI ControlWinForms Dock UI ControlDesktop Alert UI ControlDropDown List UI ControlWinForms Editor UI ControlForms and Dialogs UI ControlWinForms GridView UI ControlWinForms ListView UI ControlWinForms Menu UI ControlWinForms ComboBox UI ControlWinForms PageView UI ControlPanels and Labels UI ControlWinForms Panorama UI ControlWinForms PDFViewer UI ControlWinForms Property Grid UI ControlWinForms Ribbon UI ControlWinForms PivotGrid UI ControlWinForms RichTextBox UI ControlWinForms Rotator UI ControlWinForms Scheduler UI ControlWinForms Shortcuts UI ControlWinForms SpellChecker UI ControlWinForms Track & Status UI ControlWinForms TreeView UI ControlWinForms Wizard UI ControlWinForms Test UI ControlWinForms Theme UI Control |