Search results

Pyramid in ASP.NET Core Accumulation Chart control

26 Oct 2021 / 1 minute to read

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

tagHelper
default.cs
Copied to clipboard
<ejs-accumulationchart id="container" title="Mobile Browser Statistics">
                    <e-accumulationchart-legendsettings visible="false">
                    </e-accumulationchart-legendsettings>
                    <e-accumulation-series-collection>
                        <e-accumulation-series dataSource="ViewBag.dataSource" xName="xValue" yName="yValue" name="Browser"
                                               type="@Syncfusion.EJ2.Charts.AccumulationType.Pyramid">
                        </e-accumulation-series>
                    </e-accumulation-series-collection>
                </ejs-accumulationchart>
Copied to clipboard
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.

tagHelper
mode.cs
Copied to clipboard
<ejs-accumulationchart id="container" title="Mobile Browser Statistics">
            <e-accumulationchart-legendsettings visible="false">
            </e-accumulationchart-legendsettings>
            <e-accumulation-series-collection>
                <e-accumulation-series dataSource="ViewBag.dataSource" xName="xValue" yName="yValue" name="Browser"
                type="@Syncfusion.EJ2.Charts.AccumulationType.Pyramid"  pyramidMode="Surface">
                </e-accumulation-series>
            </e-accumulation-series-collection>
        </ejs-accumulationchart>
Copied to clipboard
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.

tagHelper
size.cs
Copied to clipboard
<ejs-accumulationchart id="container" title="Mobile Browser Statistics">
            <e-accumulationchart-legendsettings visible="false">
            </e-accumulationchart-legendsettings>
            <e-accumulation-series-collection>
                <e-accumulation-series dataSource="ViewBag.dataSource" xName="xValue" yName="yValue" name="Browser"
                type="@Syncfusion.EJ2.Charts.AccumulationType.Pyramid" width="60%" height="80%">
                </e-accumulation-series>
            </e-accumulation-series-collection>
        </ejs-accumulationchart>
Copied to clipboard
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.

tagHelper
gap.cs
Copied to clipboard
<ejs-accumulationchart id="container" title="Mobile Browser Statistics">
            <e-accumulationchart-legendsettings visible="false">
            </e-accumulationchart-legendsettings>
            <e-accumulation-series-collection>
                <e-accumulation-series dataSource="ViewBag.dataSource" xName="xValue" yName="yValue" name="Browser"
                type="@Syncfusion.EJ2.Charts.AccumulationType.Pyramid" gapRatio="0.2">
                </e-accumulation-series>
            </e-accumulation-series-collection>
        </ejs-accumulationchart>
Copied to clipboard
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.

tagHelper
explode.cs
Copied to clipboard
<ejs-accumulationchart id="container" title="Mobile Browser Statistics">
                    <e-accumulationchart-legendsettings visible="false">
                    </e-accumulationchart-legendsettings>
                    <e-accumulation-series-collection>
                        <e-accumulation-series dataSource="ViewBag.dataSource" xName="xValue" yName="yValue" name="Browser"
                                               type="@Syncfusion.EJ2.Charts.AccumulationType.Pyramid" explodeIndex="2" explode="true" explodeOffset="10">
                        </e-accumulation-series>
                    </e-accumulation-series-collection>
                </ejs-accumulationchart>
Copied to clipboard
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.

tagHelper
custom.cs
Copied to clipboard
<ejs-accumulationchart id="container" title="Mobile Browser Statistics" pointRender="pointRender">
                    <e-accumulationchart-legendsettings visible="false">
                    </e-accumulationchart-legendsettings>
                    <e-accumulation-series-collection>
                        <e-accumulation-series dataSource="ViewBag.dataSource" xName="xValue" yName="yValue" name="Browser"
                                               type="@Syncfusion.EJ2.Charts.AccumulationType.Pyramid" gapRatio="0.04">
                        </e-accumulation-series>
                    </e-accumulation-series-collection>
                </ejs-accumulationchart>

 <script>
            var pointRender = function (args) {
                if ((args.point.x).indexOf("iPhone") > -1) {
                    args.fill = '#f4bc42';
                }
                else {
                    args.fill = '#597cf9';
                }
            };
</script>
Copied to clipboard
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