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.
@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;
}
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
.
@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;
}
Using the valueBorder
property of the bullet chart, you can customize the border color
and width
of the feature bar.
@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;
}
You can customize the fill color and height of the feature bar using the valueFill
and valueHeight
properties of the bullet chart.
@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;
}