Skip to main content
A newer version of this page is available. .

WebChartControl.CustomizePieTotalLabel Event

Occurs when the WebChartControl draws total labels for pie and donut series.

Namespace: DevExpress.XtraCharts.Web

Assembly: DevExpress.XtraCharts.v21.2.Web.dll

NuGet Package: DevExpress.Web.Visualization

Declaration

public event CustomizePieTotalLabelEventHandler CustomizePieTotalLabel

Event Data

The CustomizePieTotalLabel event's data class is CustomizePieTotalLabelEventArgs. The following properties provide information specific to this event:

Property Description
Series Returns a pie series whose total label is customized.
Text Gets or sets the total label text.
TextColor Gets or sets the total label’s text color.
TotalValue Returns the total label value.

Remarks

This example shows how to format the Doughnut series total label text depending on the total value of the pie slice:

The images show pie total labels before and after customization

using DevExpress.Utils;
using DevExpress.XtraCharts;
using DevExpress.XtraCharts.Web;
using System;
using System.Collections.Generic;

namespace PieChartSample {
    public partial class WebForm1 : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
            WebChartControl chart = new WebChartControl();
            chart.ID = "WebChart";
            chart.RenderFormat = RenderFormat.Svg;
            chart.Height = 400;
            chart.Width = 400;
            this.Controls.Add(chart);

            Series series = new Series("Donut", ViewType.Doughnut);
            series.DataSource = DataPoint.GetDataPoints();
            series.SetDataMembers("Argument", "Value");

            series.LabelsVisibility = DefaultBoolean.False;
            chart.Series.Add(series);

            PieSeriesView seriesView = (PieSeriesView)series.View;
            seriesView.TotalLabel.Visible = true;

            chart.CustomizePieTotalLabel += Chart_CustomizePieTotalLabel;
        }

        private void Chart_CustomizePieTotalLabel(object sender, CustomizePieTotalLabelEventArgs e) {
            if (e.TotalValue > 1000) {
                e.TextColor = System.Drawing.Color.Green;
                e.Text = $"Total value:{Environment.NewLine}{Math.Round(e.TotalValue / 1000, 2)}K";
            }
        }
    }
    public class DataPoint {
        public string Argument { get; set; }
        public double Value { get; set; }
        public static List<DataPoint> GetDataPoints() {
            return new List<DataPoint> {
                    new DataPoint { Argument = "Russia",    Value = 225.12},
                    new DataPoint { Argument = "Canada",    Value = 148.456},
                    new DataPoint { Argument = "USA",       Value = 211.78},
                    new DataPoint { Argument = "China",     Value = 322.123},
                    new DataPoint { Argument = "Brazil",    Value = 99.511965},
                    new DataPoint { Argument = "Australia", Value = 183.68685},
                    new DataPoint { Argument = "India",     Value = 169.28759}
                };
        }
    }
}
See Also