Pareto in ASP.NET MVC Charts Component

8 Oct 202424 minutes to read

Pareto

Pareto charts are used to find the cumulative values of data in different categories. It is a combination of Column and Line series, where the initial values are represented by the column chart and the cumulative values are represented by the line chart.

To render a pareto 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 Pareto in your chart configuration. This indicates that the data should be represented as a pareto chart, will use a combination of column and line series.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Pareto).
      Marker(mr => mr.Visible(true).Height(10).Width(10)).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=44.8 },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=19.6},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            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.Pareto).
      Marker(mr => mr.Visible(true).Height(10).Width(10)).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=44.8 },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=19.6},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double y;
        };

Pareto customization

Fill

Use the Fill property to apply a color to the pareto line. By default, a color based on the theme is used.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Pareto).
      ParetoOptions(option => option.Fill("#F7523F")).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=44.8 },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=19.6},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double y;
        };

Width

Use the Width property to control the thickness of the line for the pareto series, which affects its visual weight on the chart.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Pareto).
      ParetoOptions(option => option.Fill("#F7523F").Width(2)).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=44.8 },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=19.6},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double y;
        };

Dash array

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

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Pareto).
      ParetoOptions(option => option.Fill("#F7523F").Width(2).DashArray("3,3")).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=44.8 },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=19.6},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double y;
        };

Marker

Use the Marker property to display and customize markers for individual points in a pareto line.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Pareto).
      ParetoOptions(option => option.Fill("#F7523F").Width(2)
         .Marker(marker => marker.Visible(true).Width(7).Height(7).IsFilled(true))
      ).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=44.8 },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=19.6},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double y;
        };

Show axis

Use the ShowAxis property to show or hide the secondary axis for the pareto series.

@Html.EJS().Chart("container").Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Pareto).
      ParetoOptions(option => option.Fill("#F7523F").Width(2)
         .Marker(marker => marker.Visible(true).Width(7).Height(7).IsFilled(true))
         .ShowAxis(false)
      ).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=44.8 },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=19.6},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double y;
        };

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.Pareto).
      Marker(mr => mr.Visible(true).Height(10).Width(10)).
      EmptyPointSettings(empty => empty.Mode("Average"))
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=null },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=null},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double? y;
        };

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.Pareto).
      Marker(mr => mr.Visible(true).Height(10).Width(10)).
      EmptyPointSettings(empty => empty.Mode("Average").Fill("red"))
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=null },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=null},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double? y;
        };

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.Pareto).
      Marker(mr => mr.Visible(true).Height(10).Width(10)).
      EmptyPointSettings(empty => empty.Mode("Average").Border(border => border.Width(2).Color("red")))
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=null },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=null},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double? y;
        };

##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.Pareto).
      Marker(mr => mr.Visible(true).Height(10).Width(10)).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()


   <script>
      function changeColor(args) {
         args.fill = 'green';
      }
   </script>
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=44.8 },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=19.6},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double y;
        };

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.Pareto).
      Marker(mr => mr.Visible(true).Height(10).Width(10)).
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Name("Gold").
      Width(2).
      Add();
   }).PrimaryXAxis(px =>
         px.Title("Defects")
            .ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
   ).PrimaryYAxis(py =>
      py.Title("Frequency")
         .Minimum(0)
         .Maximum(150)
         .Interval(30)
   ).Render()


   <script>
      function changeColor(args) {
         if (args.point.index % 2 !== 0) {
            args.fill = '#ff6347';
         }
         else {
            args.fill = '#009cb8';
         }
      }
   </script>
public ActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData{ x= "Traffic", y=56  },
                new ColumnChartData{ x="Child care", y=44.8 },
                new ColumnChartData{ x= "Transport", y=27.2 },
                new ColumnChartData{ x= "Weather", y=19.6},
                new ColumnChartData{ x= "Emergency", y=6.6 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }

        public class ColumnChartData
        {
            public string x;
            public double y;
        };

See also