Data Labels in ASP.NET MVC Charts

Data label can be added to a chart series by enabling the Visible option in the dataLabel. By default, the labels will arrange smartly without overlapping.

@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
Marker(mr=> mr.Visible(true).DataLabel(dl=>dl.Visible(true))).
XName("x").
YName("y").
DataSource(ViewBag.dataSource). Name("Gold").Width(2).Add();
}).PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
           new Data{ x= "Jan", y= 3,   fill= "#498fff", text= "January" },
           new Data{ x= "Feb", y= 3.5, fill= "#ffa060", text= "February" },
           new Data{ x= "Mar", y= 7,   fill= "#ff68b6", text= "March" },
           new Data{ x= "Apr", y= 13.5,fill= "#81e2a1", text= "April" }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public string fill;
            public string text;
        }

Position

Using Position property, you can place the label either on Top, Middle,Bottom or Outer (outer is applicable for column and bar type series).

@Html.EJS().Chart("container").Series(series =>
                     {
                     series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
                     Marker(mr=> mr.Visible(false).DataLabel(dl=>dl.Visible(true).Position(Syncfusion.EJ2.Charts.LabelPosition.Middle))).
                     XName("x").
                     YName("y").
                     DataSource(ViewBag.dataSource).
                     Name("Gold").
                     Width(2).Add();
                     }).PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
           new Data{ x= "Jan", y= 3,   fill= "#498fff", text= "January" },
           new Data{ x= "Feb", y= 3.5, fill= "#ffa060", text= "February" },
           new Data{ x= "Mar", y= 7,   fill= "#ff68b6", text= "March" },
           new Data{ x= "Apr", y= 13.5,fill= "#81e2a1", text= "April" }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public string fill;
            public string text;
        }

The position Outer is applicable for column and bar type series.

Data Label Template

Label content can be formatted by using the template option. Inside the template, you can add the placeholder text ${point.x} and ${point.y} to display corresponding data points x & y value. Using Template property, you can set data label template in chart.

<div id="ControlRegion">
                  @Html.EJS().Chart("container").Series(series =>
                     {
                     series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
                     Marker(mr=> mr.Visible(false).DataLabel(dl=>dl.Visible(true).Position(Syncfusion.EJ2.Charts.LabelPosition.Middle).Template("#template"))).
                     XName("x").
                     YName("y").
                     DataSource(ViewBag.dataSource).
                     Name("Gold").
                     Width(2).Add();
                     }).PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Title("Olympic Medal Counts - RIO").Render()
<script id="template">
    <div style="background:#f5f5f5; border: 1px solid black; padding: 3px 3px 3px 3px">
        <div>${point.x}</div>
        <div>${point.y}</div>
    </div>
</script>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
           new Data{ x= "Jan", y= 3,   fill= "#498fff", text= "January" },
           new Data{ x= "Feb", y= 3.5, fill= "#ffa060", text= "February" },
           new Data{ x= "Mar", y= 7,   fill= "#ff68b6", text= "March" },
           new Data{ x= "Apr", y= 13.5,fill= "#81e2a1", text= "April" }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public string fill;
            public string text;
        }

Text Mapping

Text from the data source can be mapped using Name property.

@Html.EJS().Chart("container").Series(series =>
   {
    @Html.EJS().Chart("container").Series(series =>
                     {
                     series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
                     Marker(mr=> mr.Visible(false).DataLabel(dl=>dl.Visible(true).Name("text"))).
                     XName("x").
                     YName("y").
                     DataSource(ViewBag.dataSource).
                     Name("Gold").
                     Width(2).Add();
                     }).PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
           new Data{ x= "Jan", y= 3,   fill= "#498fff", text= "January" },
           new Data{ x= "Feb", y= 3.5, fill= "#ffa060", text= "February" },
           new Data{ x= "Mar", y= 7,   fill= "#ff68b6", text= "March" },
           new Data{ x= "Apr", y= 13.5,fill= "#81e2a1", text= "April" }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public string fill;
            public string text;
        }

Format

Data label for the chart can be formatted using Format property. You can use the global formatting options, such as ‘n’, ‘p’, and ‘c’.

@Html.EJS().Chart("container").Series(series =>
   {
    @Html.EJS().Chart("container").Series(series =>
                     {
                     series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
                     Marker(mr=> mr.Visible(false).DataLabel(dl=>dl.Visible(true).Format("n2"))).
                     XName("x").
                     YName("y").
                     DataSource(ViewBag.dataSource).
                     Name("Gold").
                     Width(2).Add();
                     }).PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
           new Data{ x= "Jan", y= 3,   fill= "#498fff", text= "January" },
           new Data{ x= "Feb", y= 3.5, fill= "#ffa060", text= "February" },
           new Data{ x= "Mar", y= 7,   fill= "#ff68b6", text= "March" },
           new Data{ x= "Apr", y= 13.5,fill= "#81e2a1", text= "April" }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public string fill;
            public string text;
        }
Value Format Resultant Value Description
1000 n1 1000.0 The number is rounded to 1 decimal place.
1000 n2 1000.00 The number is rounded to 2 decimal places.
1000 n3 1000.000 The number is rounded to 3 decimal place.
0.01 p1 1.0% The number is converted to percentage with 1 decimal place.
0.01 p2 1.00% The number is converted to percentage with 2 decimal place.
0.01 p3 1.000% The number is converted to percentage with 3 decimal place.
1000 c1 $1000.0 The currency symbol is appended to number and number is rounded to 1 decimal place.
1000 c2 $1000.00 The currency symbol is appended to number and number is rounded to 2 decimal place.

Margin

Margin for data label can be applied to using Left, Right, Bottom and Top properties.

@{
    var border = new { width = 2, color = "red" };
    var margin = new { left = 15, right = 15, bottom = 15, top = 15 };
 }

@Html.EJS().Chart("container").Series(series =>
                     {
                     series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
                     Marker(mr=> mr.Visible(false).DataLabel(dl=>dl.Visible(true).Border(border).Margin(margin))).
                     XName("x").
                     YName("y").
                     DataSource(ViewBag.dataSource).
                     Name("Gold").
                     Width(2).Add();
                     }).PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
           new Data{ x= "Jan", y= 3,   fill= "#498fff", text= "January" },
           new Data{ x= "Feb", y= 3.5, fill= "#ffa060", text= "February" },
           new Data{ x= "Mar", y= 7,   fill= "#ff68b6", text= "March" },
           new Data{ x= "Apr", y= 13.5,fill= "#81e2a1", text= "April" }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public string fill;
            public string text;
        }

Customization

stroke and border of data label can be customized using Fill and Border properties. Rounded corners can be customized using Rx and Ry properties.

@{
    var border = new { width = 2, color = "red" };
    var margin = new { left = 15, right = 15, bottom = 15, top = 15 };
 }
 @Html.EJS().Chart("container").Series(series =>
                     {
                     series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
                     Marker(mr=> mr.Visible(false).DataLabel(dl=>dl.Visible(true).Border(border).Name("text").Rx(10).Ry(10).Fill("skyblue"))).
                     XName("x").
                     YName("y").
                     DataSource(ViewBag.dataSource).
                     Name("Gold").
                     Width(2).Add();
                     }).PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
           new Data{ x= "Jan", y= 3,   fill= "#498fff", text= "January" },
           new Data{ x= "Feb", y= 3.5, fill= "#ffa060", text= "February" },
           new Data{ x= "Mar", y= 7,   fill= "#ff68b6", text= "March" },
           new Data{ x= "Apr", y= 13.5,fill= "#81e2a1", text= "April" }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public string fill;
            public string text;
        }

Rx and Ry properties requires Border values not to be null.

Handling Overlapping Data Labels

Use the labelIntersectAction property to specify how overlapping data labels are handled.

The available options are:

  • None - Displays all data labels even when they overlap.
  • Hide - Hides overlapping data labels.
  • Rotate90 - Rotates overlapping data labels by 90 degrees.
  • RelocateVertically - Relocates overlapping data labels vertically.
  • RelocateHorizontally - Relocates overlapping data labels horizontally.

The RelocateVertically and RelocateHorizontally options are supported only for the following series types:

  • StackingColumn
  • StackingColumn100
  • StackingBar
  • StackingBar100

These relocation modes enable the Smart Data Label feature, which improves readability by relocating overlapping data labels and connecting them to their corresponding data points using connector lines. Use the smartLabelSettings property to customize relocated labels through the background, pointerShape, border, connectorLineStyle, and offset settings. The offset property is applicable only when labelIntersectAction is set to RelocateVertically. Note that the seriesOverlapAction property in smartLabelSettings is not applicable for RelocateVertically and RelocateHorizontally.

@{
    var border = new
    {
        color = "black",
        dashArray = "2",
        width = 2
    };

    var connectorLineStyle = new
    {
        color = "black",
        width = 2
    };

    var smartLabelSettings = new
    {
        background = "#4f4f4f",
        border = border,
        connectorLineStyle = connectorLineStyle,
        pointerShape = "Arrow",
        offset = 0.5
    };
}

@(
    Html.EJS().Chart("container")
        .Title("Chart Title")
        .Tooltip(tooltip => tooltip.Enable(true))
        .LegendSettings(legend => legend.Visible(true))
        .PrimaryXAxis(axis => axis
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
        )
        .PrimaryYAxis(axis => axis
            .Visible(false)
        )
        .Series(series =>
        {
            series
                .Name("Category A")
                .DataSource(ViewBag.dataA)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn)
                .Fill("#254061")
                .ColumnWidth(0.6)
                .Marker(marker => marker
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .Name("text")
                        .Fill("Transparent")
                        .LabelIntersectAction(
                            Syncfusion.EJ2.Charts.DataLabelIntersectAction.RelocateVertically
                        )
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Category B")
                .DataSource(ViewBag.dataB)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn)
                .Fill("#376092")
                .ColumnWidth(0.6)
                .Marker(marker => marker
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .Name("text")
                        .Fill("Transparent")
                        .LabelIntersectAction(
                            Syncfusion.EJ2.Charts.DataLabelIntersectAction.RelocateVertically
                        )
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Category C")
                .DataSource(ViewBag.dataC)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn)
                .Fill("#4f81bd")
                .ColumnWidth(0.6)
                .Marker(marker => marker
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .Name("text")
                        .Fill("Transparent")
                        .LabelIntersectAction(
                            Syncfusion.EJ2.Charts.DataLabelIntersectAction.RelocateVertically
                        )
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Category D")
                .DataSource(ViewBag.dataD)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn)
                .Fill("CornflowerBlue")
                .ColumnWidth(0.6)
                .Marker(marker => marker
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .Name("text")
                        .Fill("Transparent")
                        .LabelIntersectAction(
                            Syncfusion.EJ2.Charts.DataLabelIntersectAction.RelocateVertically
                        )
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Category E")
                .DataSource(ViewBag.dataE)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn)
                .Fill("LightBlue")
                .ColumnWidth(0.6)
                .Marker(marker => marker
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .Name("text")
                        .Fill("Transparent")
                        .LabelIntersectAction(
                            Syncfusion.EJ2.Charts.DataLabelIntersectAction.RelocateVertically
                        )
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Category F")
                .DataSource(ViewBag.dataF)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn)
                .Fill("LightSteelBlue")
                .ColumnWidth(0.6)
                .Marker(marker => marker
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .Name("text")
                        .Fill("Transparent")
                        .LabelIntersectAction(
                            Syncfusion.EJ2.Charts.DataLabelIntersectAction.RelocateVertically
                        )
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Category G")
                .DataSource(ViewBag.dataG)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn)
                .Fill("Moccasin")
                .ColumnWidth(0.6)
                .Marker(marker => marker
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .Name("text")
                        .Fill("Transparent")
                        .LabelIntersectAction(
                            Syncfusion.EJ2.Charts.DataLabelIntersectAction.RelocateVertically
                        )
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Category H")
                .DataSource(ViewBag.dataH)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn)
                .Fill("LightGrey")
                .ColumnWidth(0.6)
                .Marker(marker => marker
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .Name("text")
                        .Fill("Transparent")
                        .LabelIntersectAction(
                            Syncfusion.EJ2.Charts.DataLabelIntersectAction.RelocateVertically
                        )
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();
        })
        .Render()
)
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

public class HomeController : Controller
{
    public ActionResult Index()
    {
        List<Data> dataA = new List<Data>
        {
            new Data { x = "Period 1", y = 35, text = "35%" },
            new Data { x = "Period 2", y = 30, text = "30%" },
            new Data { x = "Period 3", y = 32, text = "32%" }
        };

        List<Data> dataB = new List<Data>
        {
            new Data { x = "Period 1", y = 22, text = "22%" },
            new Data { x = "Period 2", y = 25, text = "25%" },
            new Data { x = "Period 3", y = 24, text = "24%" }
        };

        List<Data> dataC = new List<Data>
        {
            new Data { x = "Period 1", y = 14, text = "14%" },
            new Data { x = "Period 2", y = 16, text = "16%" },
            new Data { x = "Period 3", y = 15, text = "15%" }
        };

        List<Data> dataD = new List<Data>
        {
            new Data { x = "Period 1", y = 10, text = "10%" },
            new Data { x = "Period 2", y = 11, text = "11%" },
            new Data { x = "Period 3", y = 12, text = "12%" }
        };

        List<Data> dataE = new List<Data>
        {
            new Data { x = "Period 1", y = 7, text = "7%" },
            new Data { x = "Period 2", y = 8, text = "8%" },
            new Data { x = "Period 3", y = 6, text = "6%" }
        };

        List<Data> dataF = new List<Data>
        {
            new Data { x = "Period 1", y = 5, text = "5%" },
            new Data { x = "Period 2", y = 5, text = "5%" },
            new Data { x = "Period 3", y = 5, text = "5%" }
        };

        List<Data> dataG = new List<Data>
        {
            new Data { x = "Period 1", y = 4, text = "4%" },
            new Data { x = "Period 2", y = 3, text = "3%" },
            new Data { x = "Period 3", y = 4, text = "4%" }
        };

        List<Data> dataH = new List<Data>
        {
            new Data { x = "Period 1", y = 3, text = "3%" },
            new Data { x = "Period 2", y = 2, text = "2%" },
            new Data { x = "Period 3", y = 2, text = "2%" }
        };

        ViewBag.dataA = dataA;
        ViewBag.dataB = dataB;
        ViewBag.dataC = dataC;
        ViewBag.dataD = dataD;
        ViewBag.dataE = dataE;
        ViewBag.dataF = dataF;
        ViewBag.dataG = dataG;
        ViewBag.dataH = dataH;

        return View();
    }

    public class Data
    {
        public string x;
        public double y;
        public string text;
    }
}

Smart Label

Smart Label places data labels of Cartesian series so that they do not overlap each other, the markers, or the plot area boundary. Enable it by setting the EnableSmartLabels property to true. The default value is false.

How it works:

  • Positioning: A label stays at its default position when that position is free. Otherwise, the label is checked around its point at the top, right, bottom, and left positions, and then at the diagonal positions. The first position that is inside the plot area of its series and does not overlap any other label or marker is used. If no free position is found, the label is hidden.
  • Label and marker detection: A label is checked against the other data labels and the visible markers of all series.
  • Connector line: A relocated label that is more than 12 px away from its point is joined to the point with a connector line and an arrow pointer.
@(
    Html.EJS().Chart("container")
        .Title("Annual Crude Steel Production by Country (2016–2024)")
        .SubTitle("Source: wikipedia.org")
        .EnableSmartLabels(true)
        .LegendSettings(legend => legend.Visible(true))
        .PrimaryXAxis(axis => axis
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Double)
            .EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
            .MajorGridLines(g => g.Width(0))
        )
        .PrimaryYAxis(axis => axis
            .Title("Volume in million metric tons")
            .LineStyle(l => l.Width(0))
            .MajorTickLines(t => t.Width(0))
        )
        .Series(series =>
        {
            series
                .Name("Vietnam")
                .DataSource(ViewBag.vietnam)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Circle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                    )
                )
                .Add();

            series
                .Name("Indonesia")
                .DataSource(ViewBag.indonesia)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Triangle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                    )
                )
                .Add();

            series
                .Name("France")
                .DataSource(ViewBag.france)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Diamond)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                    )
                )
                .Add();

            series
                .Name("Poland")
                .DataSource(ViewBag.poland)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Rectangle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                    )
                )
                .Add();

            series
                .Name("Mexico")
                .DataSource(ViewBag.mexico)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Pentagon)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                    )
                )
                .Add();
        })
        .Render()
)
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

public class HomeController : Controller
{
    public ActionResult Index()
    {
        List<Data> vietnam = new List<Data>
        {
            new Data { x = 2016, y = 7.8 },
            new Data { x = 2017, y = 10.3 },
            new Data { x = 2018, y = 15.5 },
            new Data { x = 2019, y = 17.5 },
            new Data { x = 2020, y = 19.5 },
            new Data { x = 2021, y = 23.0 },
            new Data { x = 2022, y = 20.0 },
            new Data { x = 2023, y = 19.0 },
            new Data { x = 2024, y = 22.1 }
        };

        List<Data> indonesia = new List<Data>
        {
            new Data { x = 2016, y = 4.8 },
            new Data { x = 2017, y = 5.2 },
            new Data { x = 2018, y = 6.2 },
            new Data { x = 2019, y = 7.8 },
            new Data { x = 2020, y = 9.3 },
            new Data { x = 2021, y = 14.3 },
            new Data { x = 2022, y = 15.6 },
            new Data { x = 2023, y = 16.0 },
            new Data { x = 2024, y = 17.0 }
        };

        List<Data> france = new List<Data>
        {
            new Data { x = 2016, y = 14.6 },
            new Data { x = 2017, y = 15.5 },
            new Data { x = 2018, y = 15.4 },
            new Data { x = 2019, y = 14.4 },
            new Data { x = 2020, y = 11.6 },
            new Data { x = 2021, y = 13.9 },
            new Data { x = 2022, y = 12.1 },
            new Data { x = 2023, y = 10.0 },
            new Data { x = 2024, y = 10.8 }
        };

        List<Data> poland = new List<Data>
        {
            new Data { x = 2016, y = 8.9 },
            new Data { x = 2017, y = 10.3 },
            new Data { x = 2018, y = 10.8 },
            new Data { x = 2019, y = 9.0 },
            new Data { x = 2020, y = 7.9 },
            new Data { x = 2021, y = 8.5 },
            new Data { x = 2022, y = 7.4 },
            new Data { x = 2023, y = 6.4 },
            new Data { x = 2024, y = 7.1 }
        };

        List<Data> mexico = new List<Data>
        {
            new Data { x = 2016, y = 19.0 },
            new Data { x = 2017, y = 20.0 },
            new Data { x = 2018, y = 20.2 },
            new Data { x = 2019, y = 18.4 },
            new Data { x = 2020, y = 16.8 },
            new Data { x = 2021, y = 18.5 },
            new Data { x = 2022, y = 18.4 },
            new Data { x = 2023, y = 16.3 },
            new Data { x = 2024, y = 13.7 }
        };

        ViewBag.vietnam = vietnam;
        ViewBag.indonesia = indonesia;
        ViewBag.france = france;
        ViewBag.poland = poland;
        ViewBag.mexico = mexico;

        return View();
    }

    public class Data
    {
        public double x;
        public double y;
    }
}

Note: When Smart Label is enabled, labelIntersectAction is ignored, and the data label position decides only the default position. Stacked column and bar series continue to use the RelocateVertically and RelocateHorizontally options.

Duplicate data labels

Use the ShowDuplicateLabels property of the chart to control labels that have the same text at the same location, such as labels of multiple series with identical values.

  • true (default) - Renders all the labels.
  • false - Renders only the first label and skips the others. The first label is decided by the series order and then the point order.

This property works with or without EnableSmartLabels.

@(
    Html.EJS().Chart("container")
        .Title("Annual Crude Steel Production by Country (2016–2024)")
        .SubTitle("Source: wikipedia.org")
        .EnableSmartLabels(true)
        .ShowDuplicateLabels(false)
        .LegendSettings(legend => legend.Visible(true))
        .PrimaryXAxis(axis => axis
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Double)
            .EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
            .MajorGridLines(g => g.Width(0))
        )
        .PrimaryYAxis(axis => axis
            .Title("Volume in million metric tons")
            .LineStyle(l => l.Width(0))
            .MajorTickLines(t => t.Width(0))
        )
        .Series(series =>
        {
            series
                .Name("Vietnam")
                .DataSource(ViewBag.vietnam)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Circle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                    )
                )
                .Add();

            series
                .Name("Indonesia")
                .DataSource(ViewBag.indonesia)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Triangle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                    )
                )
                .Add();

            series
                .Name("France")
                .DataSource(ViewBag.france)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Diamond)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                    )
                )
                .Add();

            series
                .Name("Poland")
                .DataSource(ViewBag.poland)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Rectangle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                    )
                )
                .Add();

            series
                .Name("Mexico")
                .DataSource(ViewBag.mexico)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Pentagon)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                    )
                )
                .Add();
        })
        .Render()
)
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

public class HomeController : Controller
{
    public ActionResult Index()
    {
        List<Data> vietnam = new List<Data>
        {
            new Data { x = 2016, y = 7.8 },
            new Data { x = 2017, y = 10.3 },
            new Data { x = 2018, y = 15.5 },
            new Data { x = 2019, y = 17.5 },
            new Data { x = 2020, y = 19.5 },
            new Data { x = 2021, y = 23.0 },
            new Data { x = 2022, y = 20.0 },
            new Data { x = 2023, y = 19.0 },
            new Data { x = 2024, y = 22.1 }
        };

        List<Data> indonesia = new List<Data>
        {
            new Data { x = 2016, y = 4.8 },
            new Data { x = 2017, y = 5.2 },
            new Data { x = 2018, y = 6.2 },
            new Data { x = 2019, y = 7.8 },
            new Data { x = 2020, y = 9.3 },
            new Data { x = 2021, y = 14.3 },
            new Data { x = 2022, y = 15.6 },
            new Data { x = 2023, y = 16.0 },
            new Data { x = 2024, y = 17.0 }
        };

        List<Data> france = new List<Data>
        {
            new Data { x = 2016, y = 14.6 },
            new Data { x = 2017, y = 15.5 },
            new Data { x = 2018, y = 15.4 },
            new Data { x = 2019, y = 14.4 },
            new Data { x = 2020, y = 11.6 },
            new Data { x = 2021, y = 13.9 },
            new Data { x = 2022, y = 12.1 },
            new Data { x = 2023, y = 10.0 },
            new Data { x = 2024, y = 10.8 }
        };

        List<Data> poland = new List<Data>
        {
            new Data { x = 2016, y = 8.9 },
            new Data { x = 2017, y = 10.3 },
            new Data { x = 2018, y = 10.8 },
            new Data { x = 2019, y = 9.0 },
            new Data { x = 2020, y = 7.9 },
            new Data { x = 2021, y = 8.5 },
            new Data { x = 2022, y = 7.4 },
            new Data { x = 2023, y = 6.4 },
            new Data { x = 2024, y = 7.1 }
        };

        List<Data> mexico = new List<Data>
        {
            new Data { x = 2016, y = 19.0 },
            new Data { x = 2017, y = 20.0 },
            new Data { x = 2018, y = 20.2 },
            new Data { x = 2019, y = 18.4 },
            new Data { x = 2020, y = 16.8 },
            new Data { x = 2021, y = 18.5 },
            new Data { x = 2022, y = 18.4 },
            new Data { x = 2023, y = 16.3 },
            new Data { x = 2024, y = 13.7 }
        };

        ViewBag.vietnam = vietnam;
        ViewBag.indonesia = indonesia;
        ViewBag.france = france;
        ViewBag.poland = poland;
        ViewBag.mexico = mexico;

        return View();
    }

    public class Data
    {
        public double x;
        public double y;
    }
}

Customization

Use the SmartLabelSettings property in the series DataLabel to customize relocated labels and their connector lines. Labels at their default position keep the DataLabel settings.

  • background - Sets the background color of the relocated label.
  • border - Sets the color, width, and dashArray of the relocated label border.
  • pointerShape - Sets the pointer at the point end of the connector line. The options are Arrow (default) and None.
  • connectorLineStyle - Sets the color, width, and opacity of the connector line and pointer. Set width to 0 or color to transparent to hide the line.
  • seriesOverlapAction - Specifies whether labels avoid series elements. See Series overlap action.

Note: The offset property is not applicable when Smart Label is enabled, because Smart Label automatically determines the final label position to avoid overlaps.

@{
    var smartLabelSettings = new
    {
        background = "#e0e0e0",
        border = new { color = "#404040", width = 1 },
        pointerShape = "Arrow",
        connectorLineStyle = new { color = "#404040", width = 1.5 }
    };
}

@(
    Html.EJS().Chart("container")
        .Title("Annual Crude Steel Production by Country (2016–2024)")
        .SubTitle("Source: wikipedia.org")
        .EnableSmartLabels(true)
        .LegendSettings(legend => legend.Visible(true))
        .PrimaryXAxis(axis => axis
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Double)
            .EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
            .MajorGridLines(g => g.Width(0))
        )
        .PrimaryYAxis(axis => axis
            .Title("Volume in million metric tons")
            .LineStyle(l => l.Width(0))
            .MajorTickLines(t => t.Width(0))
        )
        .Series(series =>
        {
            series
                .Name("Vietnam")
                .DataSource(ViewBag.vietnam)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Circle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Indonesia")
                .DataSource(ViewBag.indonesia)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Triangle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("France")
                .DataSource(ViewBag.france)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Diamond)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Poland")
                .DataSource(ViewBag.poland)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Rectangle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Mexico")
                .DataSource(ViewBag.mexico)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Pentagon)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();
        })
        .Render()
)
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

public class HomeController : Controller
{
    public ActionResult Index()
    {
        List<Data> vietnam = new List<Data>
        {
            new Data { x = 2016, y = 7.8 },
            new Data { x = 2017, y = 10.3 },
            new Data { x = 2018, y = 15.5 },
            new Data { x = 2019, y = 17.5 },
            new Data { x = 2020, y = 19.5 },
            new Data { x = 2021, y = 23.0 },
            new Data { x = 2022, y = 20.0 },
            new Data { x = 2023, y = 19.0 },
            new Data { x = 2024, y = 22.1 }
        };

        List<Data> indonesia = new List<Data>
        {
            new Data { x = 2016, y = 4.8 },
            new Data { x = 2017, y = 5.2 },
            new Data { x = 2018, y = 6.2 },
            new Data { x = 2019, y = 7.8 },
            new Data { x = 2020, y = 9.3 },
            new Data { x = 2021, y = 14.3 },
            new Data { x = 2022, y = 15.6 },
            new Data { x = 2023, y = 16.0 },
            new Data { x = 2024, y = 17.0 }
        };

        List<Data> france = new List<Data>
        {
            new Data { x = 2016, y = 14.6 },
            new Data { x = 2017, y = 15.5 },
            new Data { x = 2018, y = 15.4 },
            new Data { x = 2019, y = 14.4 },
            new Data { x = 2020, y = 11.6 },
            new Data { x = 2021, y = 13.9 },
            new Data { x = 2022, y = 12.1 },
            new Data { x = 2023, y = 10.0 },
            new Data { x = 2024, y = 10.8 }
        };

        List<Data> poland = new List<Data>
        {
            new Data { x = 2016, y = 8.9 },
            new Data { x = 2017, y = 10.3 },
            new Data { x = 2018, y = 10.8 },
            new Data { x = 2019, y = 9.0 },
            new Data { x = 2020, y = 7.9 },
            new Data { x = 2021, y = 8.5 },
            new Data { x = 2022, y = 7.4 },
            new Data { x = 2023, y = 6.4 },
            new Data { x = 2024, y = 7.1 }
        };

        List<Data> mexico = new List<Data>
        {
            new Data { x = 2016, y = 19.0 },
            new Data { x = 2017, y = 20.0 },
            new Data { x = 2018, y = 20.2 },
            new Data { x = 2019, y = 18.4 },
            new Data { x = 2020, y = 16.8 },
            new Data { x = 2021, y = 18.5 },
            new Data { x = 2022, y = 18.4 },
            new Data { x = 2023, y = 16.3 },
            new Data { x = 2024, y = 13.7 }
        };

        ViewBag.vietnam = vietnam;
        ViewBag.indonesia = indonesia;
        ViewBag.france = france;
        ViewBag.poland = poland;
        ViewBag.mexico = mexico;

        return View();
    }

    public class Data
    {
        public double x;
        public double y;
    }
}

Series overlap action

Use the seriesOverlapAction property in SmartLabelSettings to specify whether labels can overlap the series elements, such as lines, areas, columns, bars, and trendlines.

  • None (default) - Labels avoid only other labels and markers, so they can be placed over series elements.
  • Hide - Labels also avoid the elements of all visible series. A label moves to a free position if one exists, and is hidden only when none is available.

Note: In canvas rendering mode, Hide behaves like None.

@{
    var smartLabelSettings = new
    {
        seriesOverlapAction = "Hide"
    };
}

@(
    Html.EJS().Chart("container")
        .Title("Annual Crude Steel Production by Country (2016–2024)")
        .SubTitle("Source: wikipedia.org")
        .EnableSmartLabels(true)
        .LegendSettings(legend => legend.Visible(true))
        .PrimaryXAxis(axis => axis
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Double)
            .EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
            .MajorGridLines(g => g.Width(0))
        )
        .PrimaryYAxis(axis => axis
            .Title("Volume in million metric tons")
            .LineStyle(l => l.Width(0))
            .MajorTickLines(t => t.Width(0))
        )
        .Series(series =>
        {
            series
                .Name("Vietnam")
                .DataSource(ViewBag.vietnam)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Circle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Indonesia")
                .DataSource(ViewBag.indonesia)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Triangle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("France")
                .DataSource(ViewBag.france)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Diamond)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Poland")
                .DataSource(ViewBag.poland)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Rectangle)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();

            series
                .Name("Mexico")
                .DataSource(ViewBag.mexico)
                .XName("x")
                .YName("y")
                .Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line)
                .Marker(marker => marker
                    .Visible(true)
                    .Shape(Syncfusion.EJ2.Charts.ChartShape.Pentagon)
                    .DataLabel(dataLabel => dataLabel
                        .Visible(true)
                        .SmartLabelSettings(smartLabelSettings)
                    )
                )
                .Add();
        })
        .Render()
)
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

public class HomeController : Controller
{
    public ActionResult Index()
    {
        List<Data> vietnam = new List<Data>
        {
            new Data { x = 2016, y = 7.8 },
            new Data { x = 2017, y = 10.3 },
            new Data { x = 2018, y = 15.5 },
            new Data { x = 2019, y = 17.5 },
            new Data { x = 2020, y = 19.5 },
            new Data { x = 2021, y = 23.0 },
            new Data { x = 2022, y = 20.0 },
            new Data { x = 2023, y = 19.0 },
            new Data { x = 2024, y = 22.1 }
        };

        List<Data> indonesia = new List<Data>
        {
            new Data { x = 2016, y = 4.8 },
            new Data { x = 2017, y = 5.2 },
            new Data { x = 2018, y = 6.2 },
            new Data { x = 2019, y = 7.8 },
            new Data { x = 2020, y = 9.3 },
            new Data { x = 2021, y = 14.3 },
            new Data { x = 2022, y = 15.6 },
            new Data { x = 2023, y = 16.0 },
            new Data { x = 2024, y = 17.0 }
        };

        List<Data> france = new List<Data>
        {
            new Data { x = 2016, y = 14.6 },
            new Data { x = 2017, y = 15.5 },
            new Data { x = 2018, y = 15.4 },
            new Data { x = 2019, y = 14.4 },
            new Data { x = 2020, y = 11.6 },
            new Data { x = 2021, y = 13.9 },
            new Data { x = 2022, y = 12.1 },
            new Data { x = 2023, y = 10.0 },
            new Data { x = 2024, y = 10.8 }
        };

        List<Data> poland = new List<Data>
        {
            new Data { x = 2016, y = 8.9 },
            new Data { x = 2017, y = 10.3 },
            new Data { x = 2018, y = 10.8 },
            new Data { x = 2019, y = 9.0 },
            new Data { x = 2020, y = 7.9 },
            new Data { x = 2021, y = 8.5 },
            new Data { x = 2022, y = 7.4 },
            new Data { x = 2023, y = 6.4 },
            new Data { x = 2024, y = 7.1 }
        };

        List<Data> mexico = new List<Data>
        {
            new Data { x = 2016, y = 19.0 },
            new Data { x = 2017, y = 20.0 },
            new Data { x = 2018, y = 20.2 },
            new Data { x = 2019, y = 18.4 },
            new Data { x = 2020, y = 16.8 },
            new Data { x = 2021, y = 18.5 },
            new Data { x = 2022, y = 18.4 },
            new Data { x = 2023, y = 16.3 },
            new Data { x = 2024, y = 13.7 }
        };

        ViewBag.vietnam = vietnam;
        ViewBag.indonesia = indonesia;
        ViewBag.france = france;
        ViewBag.poland = poland;
        ViewBag.mexico = mexico;

        return View();
    }

    public class Data
    {
        public double x;
        public double y;
    }
}

Customizing Specific Point

You can also customize the specific marker and label using PointRender and TextRender event. PointRender event allows you to change the shape, color and border for a point, whereas the TextRender event allows you to change the text for the point.

@Html.EJS().Chart("container").TextRender("textRender").PointRender("pointRender").Series(series =>
                     {
                     series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
                     Marker(mr=> mr.Visible(false).DataLabel(dl=>dl.Visible(true))).
                     XName("x").
                     YName("y").
                     DataSource(ViewBag.dataSource).
                     Name("Gold").
                     Width(2).Add();
                     }).PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Title("Olympic Medal Counts - RIO").Render()
<script>
pointRender = function (args) {
        if (args.point.index === 2) {
            args.fill = 'red'
        }
    },
textRender = function (args) {
            if (args.point.index === 2) {
                args.text = 'Maximum Temperature';
                args.color = 'red';
            }
            else {
                args.cancel = true;
            }
        }
</script>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
           new Data{ x= "Jan", y= 3,   fill= "#498fff", text= "January" },
           new Data{ x= "Feb", y= 3.5, fill= "#ffa060", text= "February" },
           new Data{ x= "Mar", y= 7,   fill= "#ff68b6", text= "March" },
           new Data{ x= "Apr", y= 13.5,fill= "#81e2a1", text= "April" }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public string fill;
            public string text;
        }

Show percentage based on each series points

You can calculate the percentage value based on the sum for each series using the SeriesRender and TextRender events in the chart. In SeriesRender calculate the sum of each series y values and In TextRender calculate percentage value based on the sum value and modify the text.

<div class="control-section">
    <div style="text-align:center">
        @Html.EJS().Chart("container").TextRender("onTextRender").SeriesRender("onSeriesRender").Series(series =>
   {

       series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column)
       .Marker(mr => mr.DataLabel(dl => dl.Visible(true).Font(ff => ff.FontWeight("600").Color("#ffffff")).Position(Syncfusion.EJ2.Charts.LabelPosition.Top))).XName("x")
       .YName("yValue").DataSource(ViewBag.dataSource1).Name("Gold").Width(2).Add();
       series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column)
        .Marker(mr => mr.DataLabel(dl => dl.Visible(true).Font(ff => ff.FontWeight("600").Color("#ffffff")).Position(Syncfusion.EJ2.Charts.LabelPosition.Top))).XName("x").YName("yValue1").DataSource(ViewBag.dataSource2)
       .Name("Silver").Width(2).Add();
       series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column)
        .Marker(mr => mr.DataLabel(dl => dl.Visible(true).Font(ff => ff.FontWeight("600").Color("#ffffff")).Position(Syncfusion.EJ2.Charts.LabelPosition.Top))).XName("x")
        .YName("yValue2").DataSource(ViewBag.dataSource3).Name("Brozen").Width(2).Add();

   }).PrimaryYAxis(px => px.LabelStyle(ls => ls.Color("transparent")).LineStyle(ls => ls.Width(0)).MajorTickLines(mg => mg.Width(0))
   .MajorGridLines(mg => mg.Width(0))
   ).PrimaryXAxis(px => px.Interval(1)
   .ValueType(Syncfusion.EJ2.Charts.ValueType.Category).MajorGridLines(mg => mg.Width(0))
   ).Tooltip(tt => tt.Enable(true)).ChartArea(area => area.Border(br => br.Color("transparent"))
   ).LegendSettings(lg => lg.Visible(false)).Title("Olympic Medal Counts - RIO").Render()
    </div>
</div>
<script>
    var total = [];

    function onSeriesRender(args) {
        for (var i = 0; i < args.data.length; i++) {
            if (!total[args.data[i].x]) total[args.data[i].x] = 0;
            total[args.data[i].x] = total[args.data[i].x] + parseInt(args.data[i].y);
        }
    }
    function onTextRender(args) {
        var percentage = (parseInt(args.text) / total[args.point.x]) * 100;
        percentage = percentage % 1 === 0 ? percentage : percentage.toFixed(2);
        args.text = percentage + "%";
    }

</script>
public ActionResult Index()
        {
            List<ColumnChartData> chartData1 = new List<ColumnChartData>
            {
                new ColumnChartData { x= "USA", y = 46 },
                new ColumnChartData { x= "GBR", y = 27 },
                new ColumnChartData { x= "CHN", y = 26 }
            };
            ViewBag.dataSource1 = chartData1;

            List<ColumnChartData> chartData2 = new List<ColumnChartData>
            {
                new ColumnChartData { x= "USA", y = 37 },
                new ColumnChartData { x= "GBR", y = 23 },
                new ColumnChartData { x= "CHN", y = 18 }
            };
            ViewBag.dataSource2 = chartData2;

            List<ColumnChartData> chartData3 = new List<ColumnChartData>
            {
                new ColumnChartData { x= "USA", y = 38 },
                new ColumnChartData { x= "GBR", y = 17 },
                new ColumnChartData { x= "CHN", y = 26 }
            };
            ViewBag.dataSource3 = chartData3;
            return View();
        }
    public class ColumnChartData
        {
            public string x;
            public double y;
        }