Axis customization

20 Dec 202324 minutes to read

MajorTickLines and MinorTickLines customization

You can customize the Width, Color, and Height of minor and major tick lines using the MajorTickLines and MinorTickLines properties of the bullet chart.

The following properties can be used to customize MajorTicklines and MinorTicklines.

  • Width - Specifies the width of ticklines.
  • Height - Specifies the height of ticklines.
  • Color - Specifies the color of ticklines.
  • UseRangeColor - Specifies the color of ticklines and represents the color from corresponding range colors.
@(Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .Tooltip(tp => tp.Enable(true))
                        .MajorTickLines(ml => ml.Color("red").Width(5))
                        .MinorTickLines(mi => mi.Width(4).Color("blue"))
                        .ValueField("value")
                        .TargetField("target")
                        .Ranges(rn =>
                        {
                            rn.End(500).Add();
                            rn.End(1500).Add();
                            rn.End(2500).Add();
                        })
                        .Minimum(0).Maximum(2500).Interval(250)
                        .DataSource(ViewBag.dataSource)
                        .Render()
)
public ActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                new DefaultBulletData { value = 1500, target = 1300}
            };
            ViewBag.dataSource = bulletData;
            return View();
        }

        public class DefaultBulletData
        {
            public double value;
            public double target;
        }

Customizing Major and Minor TickLines in Bullet Chart

Tick placement

The major and the minor ticks can be placed Inside or Outside the ranges using the TickPosition property.

@(Html.EJS().BulletChart("container")
                        .Tooltip(tp => tp.Enable(true))
                        .TickPosition(Syncfusion.EJ2.Charts.TickPosition.Inside)
                        .ValueField("value")
                        .TargetField("target")
                        .Ranges(rn =>
                        {
                            rn.End(500).Add();
                            rn.End(1500).Add();
                            rn.End(2500).Add();
                        })
                        .Minimum(0).Maximum(2500).Interval(250)
                        .DataSource(ViewBag.dataSource)
                        .Render()
)
public ActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                new DefaultBulletData { value = 1500, target = 1300}
            };
            ViewBag.dataSource = bulletData;
            return View();
        }

        public class DefaultBulletData
        {
            public double value;
            public double target;
        }

Label format

Axis numeric labels can be formatted by using the LabelFormat property. Axis labels support all globalize formats.

@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .Tooltip(tp => tp.Enable(true))
                        .ValueField("value")
                        .TargetField("target")
                        .Ranges(rn =>
                        {
                            rn.End(500).Add();
                            rn.End(1500).Add();
                            rn.End(2500).Add();
                        })
                        .Minimum(0).Maximum(2500).Interval(250)
                        .DataSource(ViewBag.dataSource)
                        .Render()
public IActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                new DefaultBulletData { value = 1500, target = 1300}     
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
        }

Changing Label Format in Bullet Chart

The following table describes the result of applying some commonly used formats to numeric axis labels.

Label Value Label Format property value Result Description
1000 n1 1000.0 The Number is rounded to 1 decimal place
1000 n2 1000.00 The Number is rounded to 2 decimal places
1000 n3 1000.000 The Number is rounded to 3 decimal places
0.01 p1 1.0% The Number is converted to percentage with 1 decimal place
0.01 p2 1.00% The Number is converted to percentage with 2 decimal places
0.01 p3 1.000% The Number is converted to percentage with 3 decimal places
1000 c1 $1000.0 The Currency symbol is appended to number and number is rounded to 1 decimal place
1000 c2 $1000.00 The Currency symbol is appended to number and number is rounded to 2 decimal places

Grouping separator

To separate groups of thousands, use the EnableGroupSeparator property of bullet-chart. To separate the groups of thousands, set the EnableGroupSeparator property to true.

@(Html.EJS().BulletChart("container")
                        .ValueField("value")
                        .TargetField("target")
                        .Ranges(rn =>
                        {
                            rn.End(500).Add();
                            rn.End(1500).Add();
                            rn.End(2500).Add();
                        })
                        .Minimum(0).Maximum(2500).Interval(250)
                        .DataSource(ViewBag.dataSource)
                        .Render()
            )
public IActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                new DefaultBulletData { value = 1500, target = 1300}     
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
        }

Custom label format

Using the LabelFormat property, axis labels can be specified with a custom defined format in addition to the axis value. The label format uses a placeholder such as ${value}K, which represents the axis label.

@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .Tooltip(tp => tp.Enable(true))
                        .ValueField("value")
                        .TargetField("target")
                        .LabelFormat("${value}K")
                        .Ranges(rn =>
                        {
                            rn.End(500).Add();
                            rn.End(1500).Add();
                            rn.End(2500).Add();
                        })
                        .Minimum(0).Maximum(2500).Interval(250)
                        .DataSource(ViewBag.dataSource)
                        .Render()
public IActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                new DefaultBulletData { value = 1500, target = 1300}     
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
        }

Bullet Chart with Custom Label Format

Label placement

You can customize the axis labels Inside or Outside the bullet-chart using the LabelPosition property.

@(Html.EJS().BulletChart("container")
                        .LabelPosition(Syncfusion.EJ2.Charts.LabelsPlacement.Inside)
                        .ValueField("value")
                        .TargetField("target")
                        .Ranges(rn =>
                        {
                            rn.End(20).Add();
                            rn.End(25).Add();
                            rn.End(30).Add();
                        })
                        .Minimum(0).Maximum(30).Interval(5)
                        .DataSource(ViewBag.dataSource)
                        .Render()
            )
public IActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                new DefaultBulletData { value = 1500, target = 1300}
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
        }

Opposed position

To place an axis opposite to its original position, set the OpposedPosition property to true.

@(Html.EJS().BulletChart("container")
                        .OpposedPosition(true)
                        .ValueField("value")
                        .TargetField("target")
                        .Ranges(rn =>
                        {
                            rn.End(500).Add();
                            rn.End(1500).Add();
                            rn.End(2500).Add();
                        })
                        .Minimum(0).Maximum(2500).Interval(250)
                        .DataSource(ViewBag.dataSource)
                        .Render()

            )
public IActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                 new DefaultBulletData { value = 1500, target = 1300}
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
        }

Category label

The Bullet Chart supports X-axis label by specifying the property from the data source to the CategoryField. It helps to understand the input data in a more efficient way.

@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .Tooltip(tp => tp.Enable(true))
                        .ValueField("value")
                        .TargetField("target")
                        .CategoryField("category")
                        .Ranges(rn =>
                        {
                            rn.End(500).Add();
                            rn.End(1500).Add();
                            rn.End(2500).Add();
                        })
                        .Minimum(0).Maximum(2500).Interval(250)
                        .DataSource(ViewBag.dataSource)
                        .Render()
public IActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                new DefaultBulletData { value = 1500, target = 1300, category = "Product A" }     
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
            public string category;
        }

Bullet Chart with Category Label

Category label customization

The label color, opacity, font size, font family, font weight, and font style can be customized by using the CategoryLabelStyle setting for category and the LabelStyle setting for axis label. The UseRangeColor property specifies the color of the axis label and represents the color from the corresponding range colors.

@Html.EJS().BulletChart("container")
                        .Title("Sales Rate")
                        .Tooltip(tp => tp.Enable(true))
                        .ValueField("value")
                        .TargetField("target")
                        .CategoryField("category")
                        .Ranges(rn =>
                        {
                            rn.End(500).Add();
                            rn.End(1500).Add();
                            rn.End(2500).Add();
                        })
                        .Minimum(0).Maximum(2500).Interval(250)
                        .DataSource(ViewBag.dataSource)
                        .Render()
public IActionResult Index()
        {
            List<DefaultBulletData> bulletData = new List<DefaultBulletData>
            {
                new DefaultBulletData { value = 1500, target = 1300, category = "Product A" }     
            };
            ViewBag.dataSource = bulletData;
            return View();
        }
        public class DefaultBulletData
        {           
            public double value;
            public double target;
            public string category;
        }

Customizing Axis and Category Label in Bullet Chart