Search results

Value Bar in ASP.NET MVC Bullet Chart control

The main data value is encoded by a length of the main bar in the middle of the chart, known as the Feature Measure. This is also called as value Bar. Also, if you want to display the target bar you should map the valueField name from the dataSource.

razor
value-bar.cs
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .ValueField("value")
                        .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}     
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
        }

Feature Bar Types

You can customize the shape of the feature bar or value bar using the type property of the bullet chart. Feature bar contains Rect and Dot shapes. The default type of feature bar is Rect.

razor
types.cs
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .ValueField("value")
                        .Type("Dot")
                        .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}     
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
        }

Customization

Border Customization

Using the valueBorder property of the bullet chart, you can customize the border color and width of the feature bar.

razor
value-border.cs
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .ValueField("value")
                        .ValueBorder(vb =>
                        {
                            vb.Color("red").Width(3).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}     
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
        }

Fill color and height Customization

You can customize the fill color and height of the feature bar using the valueFill and valueHeight properties of the bullet chart.

razor
value-fill.cs
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .ValueField("value")
                        .ValueFill("blue")
                        .ValueHeight(15)
                        .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}     
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
        }