Available in the Full Version

Bullet Graph - Using ASP.NET MVC

This sample demonstrates how to use the ASP.NET MVC helper for the bullet graph.

Healthy Eating


Total calories intake ratio between fat, carbohydrates and protein, where middle ranges are healthy ratios and the target values - ideally set goals.


Fat
Carbohydrates
Protein

This sample is designed for a larger screen size.

On mobile, try rotating your screen, view full size, or email to another device.

This sample demonstrates how to use the ASP.NET MVC helper for the bullet graph.

Code View

Copy to Clipboard
@using Infragistics.Web.Mvc

<!DOCTYPE html>

<html>
<head>
    <title></title>

    <!-- Ignite UI for jQuery Required Combined CSS Files -->
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/structure/infragistics.css" rel="stylesheet" />

    <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

    <!-- Ignite UI for jQuery Required Combined JavaScript Files -->
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.core.js"></script>
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.dv.js"></script>
</head>
<body>
    <h3>Healthy Eating</h3>     
    <br />
    <h4>Total calories intake ratio between fat, carbohydrates and protein, where middle ranges are healthy ratios and the target values - ideally set goals.</h4>
    <br />

    Fat
    @(Html.Infragistics().BulletGraph()
        .Width("100%")
        .Height("80px")  
        .Ranges(range =>
        {
            range.Range("unhealthyRange").StartValue(0).EndValue(20).Brush("#FDB881"); 
            range.Range("healthyRange").StartValue(20).EndValue(35).Brush("#F18B36");
            range.Range("veryUnhealthyRange").StartValue(35).EndValue(100).Brush("#D2660D");
        })
        .Value(30)
        .TargetValue(20)
        .ValueBrush("white") 
        .TargetValueBrush("white") 
        .FontBrush("#D2660D")
        .TickBrush("#E2661D")
        .ClientEvents(new Dictionary<string, string>() { { "formatLabel", "function(evt, ui) { ui.label += '%' }" } })
        .TransitionDuration(500)
        .HtmlAttributes(new Dictionary<string, object> { { "style", "margin-bottom:40px" } })
        .Render())

    Carbohydrates
    @(Html.Infragistics().BulletGraph()
        .Width("100%")
        .Height("80px")  
        .Ranges(range =>
        {
            range.Range("unhealthyRange").StartValue(0).EndValue(45).Brush("#ABD652");
            range.Range("healthyRange").StartValue(45).EndValue(65).Brush("#739F19");
            range.Range("veryUnhealthyRange").StartValue(65).EndValue(100).Brush("#527211");
        })
        .Value(48)
        .TargetValue(50)
        .ValueBrush("white") 
        .TargetValueBrush("white") 
        .FontBrush("#527211")
        .TickBrush("#628221")
        .HtmlAttributes(new Dictionary<string, object> { { "style", "margin-bottom:40px" } })
        .ClientEvents(new Dictionary<string, string>() { { "formatLabel", "function(evt, ui) { ui.label += '%' }" } })
        .TransitionDuration(500)
        .Render())

    Protein
    @(Html.Infragistics().BulletGraph()
        .Width("100%")
        .Height("80px")         
        .Ranges(range =>
        {
            range.Range("unhealthyRange").StartValue(0).EndValue(10);
            range.Range("healthyRange").StartValue(10).EndValue(35);
            range.Range("veryUnhealthyRange").StartValue(35).EndValue(100);
        })
        .Value(22)
        .TargetValue(30)        
        .ValueBrush("white") 
        .TargetValueBrush("white") 
        .FontBrush("#216E99")
        .TickBrush("#115E89")
        .ClientEvents(new Dictionary<string, string>() { { "formatLabel", "function(evt, ui) { ui.label += '%' }" } })
        .TransitionDuration(500)
        .Render())
</body>
</html>