Your search did not match any results.

Charts - Pie with Custom Labels

This demo illustrates how to customize the PieChart component labels.

www.wikipedia.org
Backend API
@(Html.DevExtreme().PieChart() .ID("pie") .Palette(VizPalette.Bright) .Title("Olympic Medals in 2008") .Legend(l => l .Orientation(Orientation.Horizontal) .ItemTextPosition(Position.Right) .HorizontalAlignment(HorizontalAlignment.Center) .VerticalAlignment(VerticalEdge.Bottom) .ColumnCount(4) ) .Export(e => e.Enabled(true)) .Series(s => s .Add() .ArgumentField("Country") .ValueField("Medals") .Label(l => l .Visible(true) .Font(f => f.Size(16)) .Connector(c => c .Visible(true) .Width(0.5) ) .Position(PieChartLabelPosition.Columns) .CustomizeText(@<text> function(arg) { return arg.valueText + " (" + arg.percentText + ")"; } </text>) ) ) .DataSource(new[] { new { Country = "USA", Medals = 110 }, new { Country = "China", Medals = 100 }, new { Country = "Russia", Medals = 72 }, new { Country = "Britain", Medals = 47 }, new { Country = "Australia", Medals = 46 }, new { Country = "Germany", Medals = 41 }, new { Country = "France", Medals = 40 }, new { Country = "South Korea", Medals = 31 } }) )
using DevExtreme.AspNet.Data; using DevExtreme.AspNet.Mvc; using DevExtreme.NETCore.Demos.Models; using DevExtreme.NETCore.Demos.Models.SampleData; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; namespace DevExtreme.NETCore.Demos.Controllers { public class ChartsController : Controller { public ActionResult PieWithCustomLabels() { return View(); } } }
#pie { height: 440px; }

The series.label object allows you to specify the following settings:

  • visible
    Specifies the visibility of point labels.

  • position
    Specifies a label position relative to the PieChart.

    • outside
      The labels are outside the component.

    • columns
      The labels are outside the component and are arranged in columns. In this demo, you can see this mode in action.

    • inside
      The labels are inside the points.

  • customizeText
    A function that returns text displayed by point labels.

  • font
    Specifies font properties for label text. This demo uses the nested size property to change the font size.

  • connector
    Specifies connector properties for labels. In this demo, the nested visible property is enabled, and the connector width is set to 0.5.

You can also format label text and change word wrap mode, specify the background color and borders, and rotate and shift the labels.