Axis customization
20 Dec 202318 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.
<ejs-bulletchart id="bulletgraph" minimum="0" maximum="2500" interval="250" valueField="value" targetField="target" dataSource="ViewBag.dataSource">
<e-bullet-range-collection>
<e-bullet-range end="500"></e-bullet-range>
<e-bullet-range end="1500"></e-bullet-range>
<e-bullet-range end="2500"></e-bullet-range>
</e-bullet-range-collection>
<e-bulletchart-majorticklines color="red" width="4"></e-bulletchart-majorticklines>
<e-bulletchart-minorticklines color="blue" width="5"></e-bulletchart-minorticklines>
</ejs-bulletchart>
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;
}
Tick placement
The major and the minor ticks can be placed Inside or Outside the ranges using the TickPosition
property.
<ejs-bulletchart id="bulletgraph" tickPosition="@Syncfusion.EJ2.Charts.TickPosition.Inside" minimum="0" maximum="30" interval="5" valueField="value" targetField="target" dataSource="ViewBag.dataSource">
<e-bullet-range-collection>
<e-bullet-range end="20"></e-bullet-range>
<e-bullet-range end="25"></e-bullet-range>
<e-bullet-range end="30"></e-bullet-range>
</e-bullet-range-collection>
</ejs-bulletchart>
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.
<ejs-bulletchart id="bulletgraph" labelFormat="c" minimum="0" maximum="2500" interval="250" valueField="value" targetField="target" dataSource="ViewBag.dataSource">
<e-bullet-range-collection>
<e-bullet-range end="500"></e-bullet-range>
<e-bullet-range end="1500"></e-bullet-range>
<e-bullet-range end="2500"></e-bullet-range>
</e-bullet-range-collection>
</ejs-bulletchart>
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;
}
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.
<ejs-bulletchart id="bulletgraph" enableGroupSeparator="true" minimum="0" maximum="2500" interval="250" valueField="value" targetField="target" dataSource="ViewBag.dataSource">
<e-bullet-range-collection>
<e-bullet-range end="500"></e-bullet-range>
<e-bullet-range end="1500"></e-bullet-range>
<e-bullet-range end="2500"></e-bullet-range>
</e-bullet-range-collection>
</ejs-bulletchart>
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.
<ejs-bulletchart id="bulletgraph" labelFormat="${value}K" minimum="0" maximum="2500" interval="250" valueField="value" targetField="target" dataSource="ViewBag.dataSource">
<e-bullet-range-collection>
<e-bullet-range end="500"></e-bullet-range>
<e-bullet-range end="1500"></e-bullet-range>
<e-bullet-range end="2500"></e-bullet-range>
</e-bullet-range-collection>
</ejs-bulletchart>
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;
}
Label placement
You can customize the axis labels Inside or Outside the bullet chart using the LabelPosition
property.
<ejs-bulletchart id="bulletgraph" labelPosition="@Syncfusion.EJ2.Charts.LabelsPlacement.Inside" minimum="0" maximum="30" interval="5" valueField="value" targetField="target" dataSource="ViewBag.dataSource">
<e-bullet-range-collection>
<e-bullet-range end="20"></e-bullet-range>
<e-bullet-range end="25"></e-bullet-range>
<e-bullet-range end="30"></e-bullet-range>
</e-bullet-range-collection>
</ejs-bulletchart>
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.
<ejs-bulletchart id="bulletgraph" opposedPosition="true" minimum="0" maximum="30" interval="5" valueField="value" targetField="target" dataSource="ViewBag.dataSource">
<e-bullet-range-collection>
<e-bullet-range end="20"></e-bullet-range>
<e-bullet-range end="25"></e-bullet-range>
<e-bullet-range end="30"></e-bullet-range>
</e-bullet-range-collection>
</ejs-bulletchart>
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.
<ejs-bulletchart id="bulletgraph" minimum="0" maximum="2500" interval="250" categoryField="category" valueField="value" targetField="target" dataSource="ViewBag.dataSource">
<e-bullet-range-collection>
<e-bullet-range end="500"></e-bullet-range>
<e-bullet-range end="1500"></e-bullet-range>
<e-bullet-range end="2500"></e-bullet-range>
</e-bullet-range-collection>
</ejs-bulletchart>
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;
}
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.
<ejs-bulletchart id="bulletgraph" minimum="0" maximum="2500" interval="250" categoryField="category" valueField="value" targetField="target" dataSource="ViewBag.dataSource">
<e-bullet-range-collection>
<e-bullet-range end="500"></e-bullet-range>
<e-bullet-range end="1500"></e-bullet-range>
<e-bullet-range end="2500"></e-bullet-range>
</e-bullet-range-collection>
<e-bulletchart-categorylabelstyle color="Orange"></e-bulletchart-categorylabelstyle>
</ejs-bulletchart>
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;
}