Bar Charts in ASP.NET MVC Charts Component

8 Oct 202424 minutes to read

Bar

To render a bar series in your chart, you need to follow a few steps to configure it correctly. Here’s a concise guide on how to do this:

  • Set the series type: Define the series Type as Bar in your chart configuration. This indicates that the data should be represented as a bar chart, which makes it easy to compare values across categories.
@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
         .IsIndexed(true)
   ).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<AxisLabelData> chartData = new List<AxisLabelData>
            {
                new AxisLabelData { x= "South Korea", y= 39.4 },
                new AxisLabelData { x= "India", y= 61.3 }, 
                new AxisLabelData { x= "Pakistan", y= 20.4 },
                new AxisLabelData { x= "Germany", y= 65.1 }, 
                new AxisLabelData { x= "Australia", y= 15.8 },
                new AxisLabelData { x= "Italy", y= 29.2 },
                new AxisLabelData { x= "United Kingdom", y= 44.6 },
                new AxisLabelData { x= "Saudi Arabia", y= 9.7 },
                new AxisLabelData { x= "Russia", y= 40.8 },
                new AxisLabelData { x= "Mexico", y= 31 },
                new AxisLabelData { x= "Brazil", y= 75.9 },
                new AxisLabelData { x= "China", y= 51.4 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class AxisLabelData
        {
            public string x;
            public double y;
        }

Binding data with series

You can bind data to the chart using the DataSource property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series XName and YName properties.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
         .IsIndexed(true)
   ).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<AxisLabelData> chartData = new List<AxisLabelData>
            {
                new AxisLabelData { x= "South Korea", y= 39.4 },
                new AxisLabelData { x= "India", y= 61.3 }, 
                new AxisLabelData { x= "Pakistan", y= 20.4 },
                new AxisLabelData { x= "Germany", y= 65.1 }, 
                new AxisLabelData { x= "Australia", y= 15.8 },
                new AxisLabelData { x= "Italy", y= 29.2 },
                new AxisLabelData { x= "United Kingdom", y= 44.6 },
                new AxisLabelData { x= "Saudi Arabia", y= 9.7 },
                new AxisLabelData { x= "Russia", y= 40.8 },
                new AxisLabelData { x= "Mexico", y= 31 },
                new AxisLabelData { x= "Brazil", y= 75.9 },
                new AxisLabelData { x= "China", y= 51.4 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class AxisLabelData
        {
            public string x;
            public double y;
        }

Series customization

The following properties can be used to customize the bar series.

Fill

The Fill property determines the color applied to the series.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").Fill("blue").
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
         .IsIndexed(true)
   ).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<AxisLabelData> chartData = new List<AxisLabelData>
            {
                new AxisLabelData { x= "South Korea", y= 39.4 },
                new AxisLabelData { x= "India", y= 61.3 }, 
                new AxisLabelData { x= "Pakistan", y= 20.4 },
                new AxisLabelData { x= "Germany", y= 65.1 }, 
                new AxisLabelData { x= "Australia", y= 15.8 },
                new AxisLabelData { x= "Italy", y= 29.2 },
                new AxisLabelData { x= "United Kingdom", y= 44.6 },
                new AxisLabelData { x= "Saudi Arabia", y= 9.7 },
                new AxisLabelData { x= "Russia", y= 40.8 },
                new AxisLabelData { x= "Mexico", y= 31 },
                new AxisLabelData { x= "Brazil", y= 75.9 },
                new AxisLabelData { x= "China", y= 51.4 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class AxisLabelData
        {
            public string x;
            public double y;
        }

The Fill property can be used to apply a gradient color to the bar series. By configuring this property with gradient values, you can create a visually appealing effect in which the color transitions smoothly from one shade to another.

<svg style="width:1px; height:1px">
    <defs>
        <linearGradient id="gradient">
            <stop offset="0%" style="stop-color:blue;stop-opacity:5" />
            <stop offset="50%" style="stop-color:violet;stop-opacity:5" />
        </linearGradient>
    </defs>
</svg>

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").Fill("url(#gradient)").
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
         .IsIndexed(true)
   ).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<AxisLabelData> chartData = new List<AxisLabelData>
            {
                new AxisLabelData { x= "South Korea", y= 39.4 },
                new AxisLabelData { x= "India", y= 61.3 }, 
                new AxisLabelData { x= "Pakistan", y= 20.4 },
                new AxisLabelData { x= "Germany", y= 65.1 }, 
                new AxisLabelData { x= "Australia", y= 15.8 },
                new AxisLabelData { x= "Italy", y= 29.2 },
                new AxisLabelData { x= "United Kingdom", y= 44.6 },
                new AxisLabelData { x= "Saudi Arabia", y= 9.7 },
                new AxisLabelData { x= "Russia", y= 40.8 },
                new AxisLabelData { x= "Mexico", y= 31 },
                new AxisLabelData { x= "Brazil", y= 75.9 },
                new AxisLabelData { x= "China", y= 51.4 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class AxisLabelData
        {
            public string x;
            public double y;
        }

Opacity

The Opacity property specifies the transparency level of the fill. Adjusting this property allows you to control how opaque or transparent the fill color of the series appears.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).  
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Opacity(0.5).
      Add();
   }).PrimaryXAxis(px => 
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
         .IsIndexed(true)
   ).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
        {
            List<AxisLabelData> chartData = new List<AxisLabelData>
            {
                new AxisLabelData { x= "South Korea", y= 39.4 },
                new AxisLabelData { x= "India", y= 61.3 }, 
                new AxisLabelData { x= "Pakistan", y= 20.4 },
                new AxisLabelData { x= "Germany", y= 65.1 }, 
                new AxisLabelData { x= "Australia", y= 15.8 },
                new AxisLabelData { x= "Italy", y= 29.2 },
                new AxisLabelData { x= "United Kingdom", y= 44.6 },
                new AxisLabelData { x= "Saudi Arabia", y= 9.7 },
                new AxisLabelData { x= "Russia", y= 40.8 },
                new AxisLabelData { x= "Mexico", y= 31 },
                new AxisLabelData { x= "Brazil", y= 75.9 },
                new AxisLabelData { x= "China", y= 51.4 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class AxisLabelData
        {
            public string x;
            public double y;
        }

Dash array

The DashArray property determines the pattern of dashes and gaps in the series.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Border(ViewBag.border).
      DashArray("5,5").
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).Render()
public ActionResult Index()
        {
            List<AxisLabelData> chartData = new List<AxisLabelData>
            {
                new AxisLabelData { x= "South Korea", y= 39.4 },
                new AxisLabelData { x= "India", y= 61.3 }, 
                new AxisLabelData { x= "Pakistan", y= 20.4 },
                new AxisLabelData { x= "Germany", y= 65.1 }, 
                new AxisLabelData { x= "Australia", y= 15.8 },
                new AxisLabelData { x= "Italy", y= 29.2 },
                new AxisLabelData { x= "United Kingdom", y= 44.6 },
                new AxisLabelData { x= "Saudi Arabia", y= 9.7 },
                new AxisLabelData { x= "Russia", y= 40.8 },
                new AxisLabelData { x= "Mexico", y= 31 },
                new AxisLabelData { x= "Brazil", y= 75.9 },
                new AxisLabelData { x= "China", y= 51.4 }
            };
            ViewBag.dataSource = chartData;
            ChartBorder border = new ChartBorder();
            border.Width = 2;
            border.Color = "#FFA500";
            ViewBag.border = border;
            return View();
        }
        public class AxisLabelData
        {
            public string x;
            public double y;
        }

Border

Use the Border property to customize the width and color of the series border.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Border(ViewBag.border).
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).Render()
public ActionResult Index()
        {
            List<AxisLabelData> chartData = new List<AxisLabelData>
            {
                new AxisLabelData { x= "South Korea", y= 39.4 },
                new AxisLabelData { x= "India", y= 61.3 }, 
                new AxisLabelData { x= "Pakistan", y= 20.4 },
                new AxisLabelData { x= "Germany", y= 65.1 }, 
                new AxisLabelData { x= "Australia", y= 15.8 },
                new AxisLabelData { x= "Italy", y= 29.2 },
                new AxisLabelData { x= "United Kingdom", y= 44.6 },
                new AxisLabelData { x= "Saudi Arabia", y= 9.7 },
                new AxisLabelData { x= "Russia", y= 40.8 },
                new AxisLabelData { x= "Mexico", y= 31 },
                new AxisLabelData { x= "Brazil", y= 75.9 },
                new AxisLabelData { x= "China", y= 51.4 }
            };
            ViewBag.dataSource = chartData;
            ChartBorder border = new ChartBorder();
            border.Width = 2;
            border.Color = "#FFA500";
            ViewBag.border = border;
            return View();
        }
        public class AxisLabelData
        {
            public string x;
            public double y;
        }

Bar space and width

Bar space

Use the ColumnSpacing property in the series to adjust the space between bars.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).  
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      ColumnSpacing(0.5).
      Add();
   }).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Render()
public ActionResult Index()
        {
            List<AxisLabelData> chartData = new List<AxisLabelData>
            {
                new AxisLabelData { x= "South Korea", y= 39.4 },
                new AxisLabelData { x= "India", y= 61.3 }, 
                new AxisLabelData { x= "Pakistan", y= 20.4 },
                new AxisLabelData { x= "Germany", y= 65.1 }, 
                new AxisLabelData { x= "Australia", y= 15.8 },
                new AxisLabelData { x= "Italy", y= 29.2 },
                new AxisLabelData { x= "United Kingdom", y= 44.6 },
                new AxisLabelData { x= "Saudi Arabia", y= 9.7 },
                new AxisLabelData { x= "Russia", y= 40.8 },
                new AxisLabelData { x= "Mexico", y= 31 },
                new AxisLabelData { x= "Brazil", y= 75.9 },
                new AxisLabelData { x= "China", y= 51.4 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class AxisLabelData
        {
            public string x;
            public double y;
        }

Bar width

Use the ColumnWidth property in the series to adjust the width of the bars.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).  
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      ColumnWidth(0.75).
      Add();
   }).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Render()
public ActionResult Index()
        {
            List<AxisLabelData> chartData = new List<AxisLabelData>
            {
                new AxisLabelData { x= "South Korea", y= 39.4 },
                new AxisLabelData { x= "India", y= 61.3 }, 
                new AxisLabelData { x= "Pakistan", y= 20.4 },
                new AxisLabelData { x= "Germany", y= 65.1 }, 
                new AxisLabelData { x= "Australia", y= 15.8 },
                new AxisLabelData { x= "Italy", y= 29.2 },
                new AxisLabelData { x= "United Kingdom", y= 44.6 },
                new AxisLabelData { x= "Saudi Arabia", y= 9.7 },
                new AxisLabelData { x= "Russia", y= 40.8 },
                new AxisLabelData { x= "Mexico", y= 31 },
                new AxisLabelData { x= "Brazil", y= 75.9 },
                new AxisLabelData { x= "China", y= 51.4 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class AxisLabelData
        {
            public string x;
            public double y;
        }

Bar width in pixel

Use the ColumnWidthInPixel property in the series to define the exact width of the bars in pixels. This property ensures that each bar maintains the specified width, providing a uniform appearance throughout the chart.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).  
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      ColumnWidthInPixel(10).
      Add();
   }).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Render()
public ActionResult Index()
        {
            List<AxisLabelData> chartData = new List<AxisLabelData>
            {
                new AxisLabelData { x= "South Korea", y= 39.4 },
                new AxisLabelData { x= "India", y= 61.3 }, 
                new AxisLabelData { x= "Pakistan", y= 20.4 },
                new AxisLabelData { x= "Germany", y= 65.1 }, 
                new AxisLabelData { x= "Australia", y= 15.8 },
                new AxisLabelData { x= "Italy", y= 29.2 },
                new AxisLabelData { x= "United Kingdom", y= 44.6 },
                new AxisLabelData { x= "Saudi Arabia", y= 9.7 },
                new AxisLabelData { x= "Russia", y= 40.8 },
                new AxisLabelData { x= "Mexico", y= 31 },
                new AxisLabelData { x= "Brazil", y= 75.9 },
                new AxisLabelData { x= "China", y= 51.4 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class AxisLabelData
        {
            public string x;
            public double y;
        }

Grouped bar

Use the GroupName property to group the data points in bar type charts. Data points with the same group name will be grouped together in the chart, making it easy to compare different sets of data.

@Html.EJS().Chart("container")
        .PrimaryXAxis(px => 
            px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
                .MajorGridLines(mg => mg.Width(0))
                .Interval(1))
        .PrimaryYAxis(py => 
            py.LabelStyle(ls => ls.Color("transparent"))
                .LineStyle(ls => ls.Width(0))
                .MajorTickLines(mt => mt.Width(0))
                .MajorGridLines(mg => mg.Width(0))
                .MinorGridLines(mg => mg.Width(0)))
        .ChartArea(area => area.Border(br => br.Width(0)))
        .Series(series =>
        {
            series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).XName("Year").YName("USA_Total")
            .Width(2).ColumnWidth(0.7).ColumnSpacing(0.1).Name("USA Total").GroupName("USA")
            .Marker(marker => marker.DataLabel(label => label.Visible(true).Position(Syncfusion.EJ2.Charts.LabelPosition.Top)
            .Font(font => font.FontWeight("600").Color("#FFFFFF")))).DataSource(ViewBag.data).Add();

            series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).XName("Year").YName("USA_Gold")
            .Width(2).ColumnWidth(0.5).Opacity(0.4).ColumnSpacing(0.1).Name("USA Gold").GroupName("USA")
            .Marker(marker => marker.DataLabel(label => label.Visible(true).Position(Syncfusion.EJ2.Charts.LabelPosition.Top)
            .Font(font => font.FontWeight("600").Color("#FFFFFF")))).DataSource(ViewBag.data).Add();

            series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).XName("Year").YName("UK_Total")
            .Width(2).ColumnWidth(0.7).ColumnSpacing(0.1).Name("UK Total").GroupName("UK")
            .Marker(marker => marker.DataLabel(label => label.Visible(true).Position(Syncfusion.EJ2.Charts.LabelPosition.Top)
            .Font(font => font.FontWeight("600").Color("#FFFFFF")))).DataSource(ViewBag.data).Add();

            series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).XName("Year").YName("UK_Gold")
            .Width(2).ColumnWidth(0.5).ColumnSpacing(0.1).Name("UK Gold").GroupName("UK")
            .Marker(marker => marker.DataLabel(label => label.Visible(true).Position(Syncfusion.EJ2.Charts.LabelPosition.Top)
            .Font(font => font.FontWeight("600").Color("#FFFFFF")))).DataSource(ViewBag.data).Add();

            series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).XName("Year").YName("China_Total")
            .Width(2).ColumnWidth(0.7).ColumnSpacing(0.1).Name("China Total").GroupName("China")
            .Marker(marker => marker.DataLabel(label => label.Visible(true).Position(Syncfusion.EJ2.Charts.LabelPosition.Top)
            .Font(font => font.FontWeight("600").Color("#FFFFFF")))).DataSource(ViewBag.data).Add();

            series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).XName("Year").YName("China_Gold")
            .Width(2).ColumnWidth(0.5).ColumnSpacing(0.1).Name("China Gold").GroupName("China")
            .Marker(marker => marker.DataLabel(label => label.Visible(true).Position(Syncfusion.EJ2.Charts.LabelPosition.Top)
            .Font(font => font.FontWeight("600").Color("#FFFFFF")))).DataSource(ViewBag.data).Add();
        }).Title("Olympics Medal Tally").Tooltip(tooltip => tooltip.Enable(true)).Render()
public ActionResult Index()
        {
            List<ColumnData> chartData = new List<ColumnData>
            {
                new ColumnData { Year = "2012", USA_Total = 104, USA_Gold = 46, UK_Total = 65, UK_Gold = 29, China_Total = 91, China_Gold = 38},
                new ColumnData { Year = "2016", USA_Total = 121, USA_Gold = 46, UK_Total = 67, UK_Gold = 27, China_Total = 70, China_Gold = 26},
                new ColumnData { Year = "2020", USA_Total = 113, USA_Gold = 39, UK_Total = 65, UK_Gold = 22, China_Total = 88, China_Gold = 38},
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class ColumnData
        {
            public string Year;
            public double USA_Total;
            public double USA_Gold;
            public double UK_Total;
            public double UK_Gold;
            public double China_Total;
            public double China_Gold;
        }

Cylindrical bar chart

To render a cylindrical bar chart, set the ColumnFacet property to Cylinder in the chart series. This property transforms the regular bars into cylindrical shapes, enhancing the visual representation of the data.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).  
      XName("country").
      YName("gold").
      ColumnFacet(Syncfusion.EJ2.Charts.ShapeType.Cylinder).
      DataSource(ViewBag.dataSource).
      TooltipMappingName("tooltipMappingName").
      Add();
   }).PrimaryXAxis(px => 
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py => 
      py.Title("Medal Count")
         .Interval(10).Minimum(0).Maximum(80)
       ).Title("Olympic Gold Medal Counts - RIO").Render()
public ActionResult Index()
{
    List<CylindricalChartData> chartData = new List<CylindricalChartData>
    {
        new CylindricalChartData { country= "USA",       gold= 50, tooltipMappingName= "USA"       },
        new CylindricalChartData { country= "Japan",     gold= 70, tooltipMappingName= "Japan"     }, 
        new CylindricalChartData { country= "Australia", gold= 60, tooltipMappingName= "Australia" },
        new CylindricalChartData { country= "France",    gold= 50, tooltipMappingName= "France"    }, 
        new CylindricalChartData { country= "Italy",     gold= 40, tooltipMappingName= "Italy"     },
        new CylindricalChartData { country= "Sweden",    gold= 55, tooltipMappingName= "Sweden"    }
    };
    ViewBag.dataSource = chartData;
    return View();
}
public class CylindricalChartData
{
    public string country;
    public double gold;
    public string tooltipMappingName;
}

Empty points

Data points with null or undefined values are considered empty. Empty data points are ignored and not plotted on the chart.

Mode

Use the Mode property to define how empty or missing data points are handled in the series. The default mode for empty points is Gap.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("month").
      YName("sales").
      DataSource(ViewBag.dataSource).
      Name("Gold").EmptyPointSettings(ViewBag.emptyPoint).
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
         .IsIndexed(true)
   ).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
{
    List<AxisLabelData> chartData = new List<AxisLabelData>
        {
            new AxisLabelData { month = "Jan", sales = 35 },
            new AxisLabelData { month = "Feb", sales = 28 },
            new AxisLabelData { month = "Mar", sales = 34 },
            new AxisLabelData { month = "Apr", sales = null },
            new AxisLabelData { month = "May", sales = 40 },
            new AxisLabelData { month = "Jun", sales = 32 },
            new AxisLabelData { month = "Jul", sales = 35 },
            new AxisLabelData { month = "Aug" },
            new AxisLabelData { month = "Sep", sales = 38 },
            new AxisLabelData { month = "Oct", sales = 30 },
            new AxisLabelData { month = "Nov", sales = 25 },
            new AxisLabelData { month = "Dec", sales = 32 },
        };
        ViewBag.dataSource = chartData;
        ChartEmptyPointSettings chartEmptyPointSettings = new ChartEmptyPointSettings();
        chartEmptyPointSettings.Mode = EmptyPointMode.Zero;
        ViewBag.emptyPoint = chartEmptyPointSettings;
        return View();
}


public class AxisLabelData
{
    public string month;
    public double? sales;
}

Fill

Use the Fill property to customize the fill color of empty points in the series.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("month").
      YName("sales").
      DataSource(ViewBag.dataSource).
      Name("Gold").EmptyPointSettings(ViewBag.emptyPoint).
      Marker(ViewBag.marker).
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
         .IsIndexed(true)
   ).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
{
    List<AxisLabelData> chartData = new List<AxisLabelData>
        {
            new AxisLabelData { month = "Jan", sales = 35 },
            new AxisLabelData { month = "Feb", sales = 28 },
            new AxisLabelData { month = "Mar", sales = 34 },
            new AxisLabelData { month = "Apr", sales = null },
            new AxisLabelData { month = "May", sales = 40 },
            new AxisLabelData { month = "Jun", sales = 32 },
            new AxisLabelData { month = "Jul", sales = 35 },
            new AxisLabelData { month = "Aug" },
            new AxisLabelData { month = "Sep", sales = 38 },
            new AxisLabelData { month = "Oct", sales = 30 },
            new AxisLabelData { month = "Nov", sales = 25 },
            new AxisLabelData { month = "Dec", sales = 32 },
        };
        ViewBag.dataSource = chartData;
        ChartEmptyPointSettings chartEmptyPointSettings = new ChartEmptyPointSettings();
        chartEmptyPointSettings.Mode = EmptyPointMode.Zero;
        chartEmptyPointSettings.Fill = "red";
        ViewBag.emptyPoint = chartEmptyPointSettings;
        ChartMarkerSettings marker = new ChartMarkerSettings();
        marker.Visible = true;
        marker.Width = 7;
        marker.Height = 7;
        marker.IsFilled = true;
        ViewBag.marker = marker;
        return View();
}


public class AxisLabelData
{
    public string month;
    public double? sales;
}

Border

Use the Border property to customize the width and color of the border for empty points.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("month").
      YName("sales").
      DataSource(ViewBag.dataSource).
      Name("Gold").EmptyPointSettings(ViewBag.emptyPoint).
      Marker(ViewBag.marker).
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
         .IsIndexed(true)
   ).Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
{
    List<AxisLabelData> chartData = new List<AxisLabelData>
        {
            new AxisLabelData { month = "Jan", sales = 35 },
            new AxisLabelData { month = "Feb", sales = 28 },
            new AxisLabelData { month = "Mar", sales = 34 },
            new AxisLabelData { month = "Apr", sales = null },
            new AxisLabelData { month = "May", sales = 40 },
            new AxisLabelData { month = "Jun", sales = 32 },
            new AxisLabelData { month = "Jul", sales = 35 },
            new AxisLabelData { month = "Aug" },
            new AxisLabelData { month = "Sep", sales = 38 },
            new AxisLabelData { month = "Oct", sales = 30 },
            new AxisLabelData { month = "Nov", sales = 25 },
            new AxisLabelData { month = "Dec", sales = 32 },
        };
        ViewBag.dataSource = chartData;
        ChartEmptyPointSettings chartEmptyPointSettings = new ChartEmptyPointSettings();
        chartEmptyPointSettings.Mode = EmptyPointMode.Zero;
        chartEmptyPointSettings.Fill = "red";
        chartEmptyPointSettings.Border.Width = 2;
        chartEmptyPointSettings.Border.Color = "green";
        ViewBag.emptyPoint = chartEmptyPointSettings;
        ChartMarkerSettings marker = new ChartMarkerSettings();
        marker.Visible = true;
        marker.Width = 7;
        marker.Height = 7;
        marker.IsFilled = true;
        ViewBag.marker = marker;
        return View();
}


public class AxisLabelData
{
    public string month;
    public double? sales;
}

Events

Series render

The SeriesRender event allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart.

@Html.EJS().Chart("container").SeriesRender("changeColor").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("month").
      YName("sales").
      DataSource(ViewBag.dataSource).
      Name("Gold").Width(2).
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
         .IsIndexed(true)
   ).Title("Olympic Medal Counts - RIO").Render()

<script>
    function changeColor(args) {
        args.fill = '#ff6347';
    }
</script>
public ActionResult Index()
{
    List<AxisLabelData> chartData = new List<AxisLabelData>
    {
        new AxisLabelData { month = "Jan", sales = 35 },
        new AxisLabelData { month = "Feb", sales = 28 },
        new AxisLabelData { month = "Mar", sales = 34 },
        new AxisLabelData { month = "Apr", sales = 30 },
        new AxisLabelData { month = "May", sales = 40 },
        new AxisLabelData { month = "Jun", sales = 32 },
        new AxisLabelData { month = "Jul", sales = 35 },
        new AxisLabelData { month = "Aug", sales = 43 },
        new AxisLabelData { month = "Sep", sales = 38 },
        new AxisLabelData { month = "Oct", sales = 30 },
        new AxisLabelData { month = "Nov", sales = 25 },
        new AxisLabelData { month = "Dec", sales = 32 },
    };
    ViewBag.dataSource = chartData;
    return View();
}
public class AxisLabelData
{
    public string month;
    public double? sales;
}

Point render

The PointRender event allows you to customize each data point before it is rendered on the chart.

@Html.EJS().Chart("container").PointRender("changeColor").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Bar).
      XName("month").
      YName("sales").
      DataSource(ViewBag.dataSource).
      Name("Gold").Width(2).
      Marker(ViewBag.marker).
      Add();
   }).PrimaryXAxis(px =>
      px.Interval(1)
         .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
         .IsIndexed(true)
   ).Title("Olympic Medal Counts - RIO").Render()

<script>
    function changeColor(args) {
        if (args.point.index % 2 !== 0) {
            args.fill = '#ff6347';
        }
        else {
            args.fill = '#009cb8';
        }
    }
</script>
public ActionResult Index()
{
    List<AxisLabelData> chartData = new List<AxisLabelData>
    {
        new AxisLabelData { month = "Jan", sales = 35 },
        new AxisLabelData { month = "Feb", sales = 28 },
        new AxisLabelData { month = "Mar", sales = 34 },
        new AxisLabelData { month = "Apr", sales = 30 },
        new AxisLabelData { month = "May", sales = 40 },
        new AxisLabelData { month = "Jun", sales = 32 },
        new AxisLabelData { month = "Jul", sales = 35 },
        new AxisLabelData { month = "Aug", sales = 43 },
        new AxisLabelData { month = "Sep", sales = 38 },
        new AxisLabelData { month = "Oct", sales = 30 },
        new AxisLabelData { month = "Nov", sales = 25 },
        new AxisLabelData { month = "Dec", sales = 32 },
    };
    ViewBag.dataSource = chartData;
    ChartMarkerSettings chartMarkerSettings = new ChartMarkerSettings();
    chartMarkerSettings.Visible = true;
    chartMarkerSettings.IsFilled = true;
    chartMarkerSettings.Height = 7;
    chartMarkerSettings.Width = 7;
    ViewBag.marker = chartMarkerSettings;
    return View();
}
public class AxisLabelData
{
    public string month;
    public double? sales;
}

See also