Search results

Customization in ASP.NET MVC Bullet Chart control

26 Oct 2021 / 1 minute to read

Orientation

The Bullet Chart can be rendered in different orientations such as Horizontal or Vertical via the orientation property. By default, the Bullet Chart is rendered in the Horizontal orientation.

razor
orientation.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .ValueField("value")
                        .Width("20%")
                        .Orientation(Syncfusion.EJ2.Charts.OrientationType.Vertical)
                        .Ranges(rn =>
                        {
                            rn.End(35).Add();
                            rn.End(50).Add();
                            rn.End(100).Add();
                        })
                        .Minimum(0).Maximum(100).Interval(20)
                        .DataSource(ViewBag.dataSource)
                        .Render()
Copied to clipboard
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;
        }

Bullet Chart with Orientation

Right-to-left (RTL)

The Bullet Chart supports the right-to-left rendering that can be enabled by setting the enableRtl property to true.

razor
right-to-left.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .ValueField("value")
                        .EnableRtl(true)
                        .Ranges(rn =>
                        {
                            rn.End(35).Add();
                            rn.End(50).Add();
                            rn.End(100).Add();
                        })
                        .Minimum(0).Maximum(100).Interval(20)
                        .DataSource(ViewBag.dataSource)
                        .Render()
Copied to clipboard
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;
        }

Right to Left Flow Direction in Bullet Chart

Animation

The actual and the target bar supports the linear animation via the animation setting. The speed and the delay are controlled using the duration and delay properties respectively.

razor
animation.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .ValueField("value")
                        .Animation(an => an.Enable(true))
                        .Ranges(rn =>
                        {
                            rn.End(35).Add();
                            rn.End(50).Add();
                            rn.End(100).Add();
                        })
                        .Minimum(0).Maximum(100).Interval(20)
                        .DataSource(ViewBag.dataSource)
                        .Render()
Copied to clipboard
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;
        }

Theme

The Bullet Chart supports different type of themes via the theme property.

razor
theme.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .ValueField("value")
                        .Theme("HighContrast")
                        .Ranges(rn =>
                        {
                            rn.End(35).Add();
                            rn.End(50).Add();
                            rn.End(100).Add();
                        })
                        .Minimum(0).Maximum(100).Interval(20)
                        .DataSource(ViewBag.dataSource)
                        .Render()
Copied to clipboard
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;
        }

Applying Theme to Bullet Chart