Data Binding in EJ 1 ASP.NET MVC BulletGraph

18 Nov 2017 / 2 minutes to read

Bullet Graph supports binding JSON data from a remote server or data created in client-side. You can use the Fields property to customize the data bound with Bullet Graph.

Local Data

Data available in client-side (local data) can be bound with Bullet Graph using Fields property. This property provides option to specify data source, fields representing progress measure bar value, comparative measure value and category value.

  • c#
  • public class BulletData
    	public double BulletValue
    	{ get; set; }
    	public double ComparisonValue
    	{ get; set; }
    	public string Category
    	{ get; set; }
    List<BulletData> data = new List<BulletData>();
    data.Add(new BulletData() { BulletValue=9.5, ComparisonValue=7.5, Category="2001"  });
    data.Add(new BulletData() { BulletValue = 9.5, ComparisonValue = 5, Category = "2002" });
    ViewBag.DataSource = data;
  • cshtml
  • @(Html.EJ().BulletGraph("Bullets").QualitativeRangeSize(60).QuantitativeScaleSettings( scale=>
    	scale.Location( loc=> loc.x(50).y(20))

    The following screenshot displays Bullet Graph with local data generated using JavaScript


    Bullet Graph bounded to JSON data

    Remote Data

    Bullet Graph provides option to bind data from a remote server using ejDataManager as data source in fields property. A query object should also be passed to query property when using data manager as data source.

  • javascript
  • @(Html.EJ().BulletGraph("Bullets").QualitativeRangeSize(60)
    	.QualitativeRanges( qr=>
    <script type="text/javascript">
    	//Creating data manager instance
    	var dataManger = new ej.DataManager({
    		url: ""
    	// Query creation
    	var query = ej.Query().from("Order_Details").take(3).where("UnitPrice", ej.FilterOperators.greaterThan, 18, false)
    		.where("UnitPrice", ej.FilterOperators.lessThanOrEqual, 40, false)
    		.where("Quantity", ej.FilterOperators.greaterThan, 5, false)
    		.where("Quantity", ej.FilterOperators.lessThanOrEqual, 45, false);
    	dataManger.executeQuery(query).done(function (e) {
    		$("#Bullets").ejBulletGraph("option", "fields", {
    			dataSource: dataManger,
    			query: query,

    The following screenshot displays a Bullet Graph bounded with data from a remote server


    Bullet Graph bounded to data from server