Search results

Ranges in ASP.NET MVC Bullet Chart control

Ranges are represents the quality of a specific range in bullet-chart scale like good, bad and satisfactory. The end property specifies the ending point of the qualitative range. Minimum value of quantitative scale is considered as the starting point of first range and previous end points are considered as starting point for other ranges.

razor
ranges.cs
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .ValueField("value")
                        .TargetField("target")
                        .CategoryField("category")
                        .CategoryLabelStyle(cl =>
                        {
                            cl.Color("red).Size("13").FontWeight("Bold").Add();
                        })
                        .Ranges(rn =>
                        {
                            rn.End(35).Add();
                            rn.End(50).Add();
                            rn.End(100).Add();
                        })
                        .Minimum(0).Maximum(100).Interval(20)
                        .DataSource(ViewBag.dataSource)
                        .Render()
public IActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                new DefaultBulletData { value = 55, target = 75, category = "Year 1"},
                new DefaultBulletData { value = 70, target = 70, category = "Year 2"},
                new DefaultBulletData { value = 85, target = 75, category = "Year 3"}
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
            public string category;
        }

Color Customization

Color for each qualitative range is customized using color property based on end values. Also you can customize the opacity of the each range color.

razor
ranges-custom.cs
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .ValueField("value")
                        .TargetField("target")
                        .CategoryField("category")
                        .CategoryLabelStyle(cl =>
                        {
                            cl.Color("red).Size("13").FontWeight("Bold").Add();
                        })
                        .Ranges(rn =>
                        {
                            rn.End(35).Opacity(0.5).Color("darkred").Add();
                            rn.End(50).Opacity(1).Color("red").Add();
                            rn.End(75).Opacity(0.7).Color("blue").Add();
                            rn.End(90).Opacity(1).Color("lightgreen").Add();
                            rn.End(100).Opacity(0.8).Color("green").Add();
                        })
                        .Minimum(0).Maximum(100).Interval(20)
                        .DataSource(ViewBag.dataSource)
                        .Render()
public IActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                new DefaultBulletData { value = 55, target = 75, category = "Year 1"},
                new DefaultBulletData { value = 70, target = 70, category = "Year 2"},
                new DefaultBulletData { value = 85, target = 75, category = "Year 3"}
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
            public string category;
        }