Search results

Title and Subtitle in ASP.NET MVC Bullet Chart control

17 Sep 2021 / 2 minutes to read

Title

The title of the Bullet Chart displays the information about the data plotted by specifying it in the title property.

razor
title.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .TargetField("target")
                        .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()
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 Title

Subtitle

To show additional information about the data plotted, the Bullet Chart can also be given a subtitle using the subtitle property.

razor
sub-title.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .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()
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 Subtitle

Title and SubTitle Position

The title and the subtitle positions can be customized using the titlePosition property. Possible positions are Left, Right, Top, and Bottom.

Position as Left

By setting the titlePosition to Left, you can display the title and subtitle at the left side of the Bullet Chart.

razor
left.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .ValueField("value")
                        .TitlePosition(Syncfusion.EJ2.Charts.TextPosition.Left)
                        .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;
        }

Position as Right

By setting the titlePosition to Right, you can display the title and subtitle at the right side of the Bullet Chart.

razor
right.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .ValueField("value")
                        .TitlePosition(Syncfusion.EJ2.Charts.TextPosition.Right)
                        .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;
        }

Position as Top

By setting the titlePosition to Top, you can display the title and subtitle at the top of the Bullet Chart. The default title and subtitle positions of the Bullet Chart is Top.

razor
top.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .ValueField("value")
                        .TitlePosition(Syncfusion.EJ2.Charts.TextPosition.Top)
                        .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;
        }

Position as Bottom

By setting the titlePosition to Bottom, you can display the title and subtitle at the bottom of the Bullet Chart.

razor
bottom.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .ValueField("value")
                        .TitlePosition(Syncfusion.EJ2.Charts.TextPosition.Bottom)
                        .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;
        }

Title and Subtitle Position in Bullet Chart

Title Customization

The title color, opacity, font size, font family, font weight, and font style can be customized using the titleStyle property.

razor
title-custom.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .ValueField("value")
                        .TitleStyle(ts =>
                        {
                            ts.Size("22px").Color("red").FontFamily("cursive").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()
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;
        }

SubTitle Customization

The sub-title color, opacity, font size, font family, font weight, and font style can be customized using the subtitleStyle property.

razor
sub-title-custom.cs
Copied to clipboard
@Html.EJS().BulletChart("container")
                        .Title("Sales Rate in dollars")
                        .Subtitle("(in dollars $)")
                        .LabelFormat("${value}")
                        .TargetField("target")
                        .ValueField("value")
                        .SubTitleStyle(ts =>
                        {
                            ts.Size("22px").Color("red").FontFamily("cursive").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()
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;
        }

Customizing Title and Subtitle in Bullet Chart