Pyramid Chart

24 Feb 202220 minutes to read

To render a pyramid series, use the series Type as Pyramid.

@Html.EJS().AccumulationChart("container").Series(series =>
            {
                series.DataSource(ViewBag.dataSource)
                      .XName("xValue")
                      .YName("yValue")
                      .Name("Browser")
                      .Type(Syncfusion.EJ2.Charts.AccumulationType.Pyramid).Add();
            })
            .EnableSmartLabels(true)
            .Title("Mobile Browser Statistics")
            .LegendSettings(ls => ls.Visible(false)).Render()
public ActionResult Index()
        {
            List<PyramidChartData> chartData = new List<PyramidChartData>
            {

                new PyramidChartData { xValue = "Chrome", yValue = 37 },
                new PyramidChartData { xValue = "UC Browser", yValue = 17 },
                new PyramidChartData { xValue = "iPhone", yValue = 19 },
                new PyramidChartData { xValue = "Others", yValue = 14  },
                new PyramidChartData { xValue = "Opera", yValue = 11 },
                new PyramidChartData { xValue = "Android", yValue = 12 },
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class PyramidChartData
        {
            public string xValue;
            public double yValue;
        }

Mode

The Pyramid chart supports linear and surface modes of rendering. The default type of the PyramidMode is Linear.

@Html.EJS().AccumulationChart("container").Series(series =>
            {
                series.DataSource(ViewBag.dataSource)
                      .XName("xValue")
                      .YName("yValue")
                      .Name("Browser")
                      .PyramidMode("Surface")
                      .Type(Syncfusion.EJ2.Charts.AccumulationType.Pyramid).Add();
            })
            .EnableSmartLabels(true)
            .Title("Mobile Browser Statistics")
            .LegendSettings(ls => ls.Visible(false)).Render()
public ActionResult Index()
        {
            List<PyramidChartData> chartData = new List<PyramidChartData>
            {

                new PyramidChartData { xValue = "Chrome", yValue = 37 },
                new PyramidChartData { xValue = "UC Browser", yValue = 17 },
                new PyramidChartData { xValue = "iPhone", yValue = 19 },
                new PyramidChartData { xValue = "Others", yValue = 4  },
                new PyramidChartData { xValue = "Opera", yValue = 11 },
                new PyramidChartData { xValue = "Android", yValue = 12 },
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class PyramidChartData
        {
            public string xValue;
            public double yValue;
        }

Size

The size of the pyramid chart can be customized by using the Width and Height properties.

@Html.EJS().AccumulationChart("container").Series(series =>
            {
                series.DataSource(ViewBag.dataSource)
                      .XName("xValue")
                      .YName("yValue")
                      .Name("Browser")
                      .Width("60%")
                      .Height("80%")
                      .Type(Syncfusion.EJ2.Charts.AccumulationType.Pyramid).Add();
            })
            .EnableSmartLabels(true)
            .Title("Mobile Browser Statistics")
            .LegendSettings(ls => ls.Visible(false)).Render()
public ActionResult Index()
        {
            List<PyramidChartData> chartData = new List<PyramidChartData>
            {

                new PyramidChartData { xValue = "Chrome", yValue = 37 },
                new PyramidChartData { xValue = "UC Browser", yValue = 17 },
                new PyramidChartData { xValue = "iPhone", yValue = 19 },
                new PyramidChartData { xValue = "Others", yValue = 4  },
                new PyramidChartData { xValue = "Opera", yValue = 11 },
                new PyramidChartData { xValue = "Android", yValue = 12 },
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class PyramidChartData
        {
            public string xValue;
            public double yValue;
        }

Gap Between the Segments

Pyramid chart provides options to customize the space between the segments by using the GapRatio property of the series. It ranges from 0 to 1.

@Html.EJS().AccumulationChart("container").Series(series =>
            {
                series.DataSource(ViewBag.dataSource)
                      .XName("xValue")
                      .YName("yValue")
                      .Name("Browser")
                      .GapRatio(0.2)
                      .Type(Syncfusion.EJ2.Charts.AccumulationType.Pyramid).Add();
            })
            .EnableSmartLabels(true)
            .Title("Mobile Browser Statistics")
            .LegendSettings(ls => ls.Visible(false)).Render()
public ActionResult Index()
        {
            List<PyramidChartData> chartData = new List<PyramidChartData>
            {

                new PyramidChartData { xValue = "Chrome", yValue = 37 },
                new PyramidChartData { xValue = "UC Browser", yValue = 17 },
                new PyramidChartData { xValue = "iPhone", yValue = 19 },
                new PyramidChartData { xValue = "Others", yValue = 4  },
                new PyramidChartData { xValue = "Opera", yValue = 11 },
                new PyramidChartData { xValue = "Android", yValue = 12 },
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class PyramidChartData
        {
            public string xValue;
            public double yValue;
        }

Explode

Points can be exploded on mouse click by setting the Explode property to true. You can also explode the point on load using ExplodeIndex. Explode distance can be set by using ExplodeOffset property.

@Html.EJS().AccumulationChart("container").Series(series =>
            {
                series.DataSource(ViewBag.dataSource)
                      .XName("xValue")
                      .YName("yValue")
                      .Name("Browser")
                      .Explode(true)
                      .ExplodeOffset("10%")
                      .ExplodeIndex(0)
                      .ExplodeAll(false)
                      .Type(Syncfusion.EJ2.Charts.AccumulationType.Pyramid).Add();
            })
            .EnableSmartLabels(true)
            .Title("Mobile Browser Statistics")
            .LegendSettings(ls => ls.Visible(false)).Render()
public ActionResult Index()
        {
            List<PyramidChartData> chartData = new List<PyramidChartData>
            {

                new PyramidChartData { xValue = "Chrome", yValue = 37 },
                new PyramidChartData { xValue = "UC Browser", yValue = 17 },
                new PyramidChartData { xValue = "iPhone", yValue = 19 },
                new PyramidChartData { xValue = "Others", yValue = 4  },
                new PyramidChartData { xValue = "Opera", yValue = 11 },
                new PyramidChartData { xValue = "Android", yValue = 12 },
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class PyramidChartData
        {
            public string xValue;
            public double yValue;
        }

Customization

Individual points can be customized using the PointRender event.

@Html.EJS().AccumulationChart("container").Series(series =>
            {
                series.DataSource(ViewBag.dataSource)
                      .XName("xValue")
                      .YName("yValue")
                      .Name("Browser")
                      .Type(Syncfusion.EJ2.Charts.AccumulationType.Pyramid).Add();
            })
            .EnableSmartLabels(true)
            .PointRender("pointRender")
            .Title("Mobile Browser Statistics")
            .LegendSettings(ls => ls.Visible(false)).Render()

<script>
            var pointRender = function (args) {
                if ((args.point.xValue as string).indexOf('iPhone') > -1) {
                    args.fill = '#f4bc42';
                     }
                       else {
                     args.fill = '#597cf9';
                     }
            };
</script>
public ActionResult Index()
        {
            List<PyramidChartData> chartData = new List<PyramidChartData>
            {

                new PyramidChartData { xValue = "Chrome", yValue = 37 },
                new PyramidChartData { xValue = "UC Browser", yValue = 17 },
                new PyramidChartData { xValue = "iPhone", yValue = 19 },
                new PyramidChartData { xValue = "Others", yValue = 4  },
                new PyramidChartData { xValue = "Opera", yValue = 11 },
                new PyramidChartData { xValue = "Android", yValue = 12 },
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class PyramidChartData
        {
            public string xValue;
            public double yValue;
        }

See Also