Radial Gauge

Linear Gauge

Bullet Graph

Segmented Display


This sample demonstrates how to specify linear gradients.

For detailed implementation, please take a look at the Aspx, Razor and Controller code tabs.
 
<%@ Page  Language="C#"  Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="JQChart.Web.Mvc" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>    
    <link rel="stylesheet" type="text/css" href="~/Content/jquery.jqGauges.css" />
    <script src="<%: Url.Content("~/Scripts/jquery-1.11.1.min.js") %>" type="text/javascript"></script>
    <script src="<%: Url.Content("~/Scripts/jquery.jqGauges.min.js") %>" type="text/javascript"></script>
    <!--[if IE]><script lang="javascript" type="text/javascript" src="<%: Url.Content("~/Scripts/excanvas.js") %>"></script><![endif]-->
</head>
<body>
    <div>
        <%=Html.JQLinearGauge().LinearGauge()
            .ID("jqLinearGauge")
            .Orientation(GaugeOrientation.Vertical)
            .Background("#F7F7F7")
            .Width(110)
            .Height(400)
            .Border(border =>
                       {
                           border.LineWidth(4)
                                 .StrokeStyle("#76786A")
                                 .Padding(8);
                       })
           .Shadows(true)
           .Tooltips(tooltips =>
                         {
                             tooltips.Disabled(true).Highlighting(true);
                         })
           .Animation(new TimeSpan(0,0,1))
           .Scales(scales =>
                      {
                          scales.LinearScale()
                                .Minimum(0)
                                .Maximum(100)
                                .Interval(10)
                                .Labels(labels =>
                                    {
                                        labels.Offset(0.03);
                                    })
                                .MajorTickMarks(majorTickMarks =>
                                    {
                                        majorTickMarks.Offset(0.20).LineWidth(2);
                                    })
                                .MinorTickMarks(minorTickMarks =>
                                    {
                                        minorTickMarks.Offset(0.24)
                                                      .Visible(true)
                                                      .LineWidth(2)
                                                      .Interval(2);
                                    })
                                 .BarMarkers(barMarkers =>
                                     {
                                         barMarkers.LinearBarMarker()
                                                   .Value(80)
                                                   .InnerOffset(0.4)
                                                   .OuterOffset(0.56)
                                                   .FillStyle(gradient =>
                                                        {
                                                            gradient.LinearGradient(0, 0.5, 1, 0.5)
                                                                    .ColorStops(colorStops =>
                                                                    {
                                                                        colorStops.Add(0, "#C5F80B");
                                                                        colorStops.Add(1, "#6B8901");
                                                                    });
                                                        });
                     
                                         barMarkers.LinearBarMarker()
                                                   .Value(70)
                                                   .InnerOffset(0.6)
                                                   .OuterOffset(0.76)
                                                   .FillStyle(gradient =>
                                                        {
                                                            gradient.LinearGradient(0, 0.5, 1, 0.5)
                                                                    .ColorStops(colorStops =>
                                                                    {
                                                                        colorStops.Add(0, "#FF3366");
                                                                        colorStops.Add(1, "#B2183E");
                                                                    });
                                                        });
                     
                                         barMarkers.LinearBarMarker()
                                                   .Value(90)
                                                   .InnerOffset(0.8)
                                                   .OuterOffset(0.96)
                                                   .FillStyle(gradient =>
                                                        {
                                                            gradient.LinearGradient(0, 0.5, 1, 0.5)
                                                                    .ColorStops(colorStops =>
                                                                    {
                                                                        colorStops.Add(0, "#339CFF");
                                                                        colorStops.Add(1, "#1F66A8");
                                                                    });
                                                        });
                                     });                                     
                      })
        .Render()%>
    </div>
    <script lang="javascript" type="text/javascript">
        var values = { v1: 80, v2: 70, v3: 90 };

        function updateGauge() {

            $(values).animate({
                v1: Math.round(Math.random() * 100),
                v2: Math.round(Math.random() * 100),
                v3: Math.round(Math.random() * 100)
            },
            {
                duration: 600,
                step: function () {
                    var scales = $('#jqLinearGauge').jqLinearGauge('option', 'scales');

                    scales[0].barMarkers[0].value = this.v1;
                    scales[0].barMarkers[1].value = this.v2;
                    scales[0].barMarkers[2].value = this.v3;

                    $('#jqLinearGauge').jqLinearGauge('update');
                },
                complete: function () {
                    setTimeout('updateGauge()', 400);
                }
            });
        }

        $(document).ready(function () {
            updateGauge();
        });
    </script>
</body>
</html>

                                        
 

@using JQChart.Web.Mvc

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>    
    <link rel="stylesheet" type="text/css" href="~/Content/jquery.jqGauges.css" />
    <script src="@Url.Content("~/Scripts/jquery-1.11.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.jqGauges.min.js")" type="text/javascript"></script>
    <!--[if IE]><script lang="javascript" type="text/javascript" src="@Url.Content("~/Scripts/excanvas.js")"></script><![endif]-->
</head>
<body>
    <div>
          @(Html.JQLinearGauge().LinearGauge()
            .ID("jqLinearGauge")
            .Orientation(GaugeOrientation.Vertical)
            .Background("#F7F7F7")
            .Width(110)
            .Height(400)
            .Border(border =>
                       {
                           border.LineWidth(4)
                                 .StrokeStyle("#76786A")
                                 .Padding(8);
                       })
           .Shadows(true)
           .Tooltips(tooltips =>
                         {
                             tooltips.Disabled(true).Highlighting(true);
                         })
           .Animation(new TimeSpan(0,0,1))
           .Scales(scales =>
                      {
                          scales.LinearScale()
                                .Minimum(0)
                                .Maximum(100)
                                .Interval(10)
                                .Labels(labels =>
                                    {
                                        labels.Offset(0.03);
                                    })
                                .MajorTickMarks(majorTickMarks =>
                                    {
                                        majorTickMarks.Offset(0.20).LineWidth(2);
                                    })
                                .MinorTickMarks(minorTickMarks =>
                                    {
                                        minorTickMarks.Offset(0.24)
                                                      .Visible(true)
                                                      .LineWidth(2)
                                                      .Interval(2);
                                    })
                                 .BarMarkers(barMarkers =>
                                     {
                                         barMarkers.LinearBarMarker()
                                                   .Value(80)
                                                   .InnerOffset(0.4)
                                                   .OuterOffset(0.56)
                                                   .FillStyle(gradient =>
                                                        {
                                                            gradient.LinearGradient(0, 0.5, 1, 0.5)
                                                                    .ColorStops(colorStops =>
                                                                    {
                                                                        colorStops.Add(0, "#C5F80B");
                                                                        colorStops.Add(1, "#6B8901");
                                                                    });
                                                        });
                     
                                         barMarkers.LinearBarMarker()
                                                   .Value(70)
                                                   .InnerOffset(0.6)
                                                   .OuterOffset(0.76)
                                                   .FillStyle(gradient =>
                                                        {
                                                            gradient.LinearGradient(0, 0.5, 1, 0.5)
                                                                    .ColorStops(colorStops =>
                                                                    {
                                                                        colorStops.Add(0, "#FF3366");
                                                                        colorStops.Add(1, "#B2183E");
                                                                    });
                                                        });
                     
                                         barMarkers.LinearBarMarker()
                                                   .Value(90)
                                                   .InnerOffset(0.8)
                                                   .OuterOffset(0.96)
                                                   .FillStyle(gradient =>
                                                        {
                                                            gradient.LinearGradient(0, 0.5, 1, 0.5)
                                                                    .ColorStops(colorStops =>
                                                                    {
                                                                        colorStops.Add(0, "#339CFF");
                                                                        colorStops.Add(1, "#1F66A8");
                                                                    });
                                                        });
                                     });                                     
                      })
        .Render() 
          )
    </div>
    <script lang="javascript" type="text/javascript">
        var values = { v1: 80, v2: 70, v3: 90 };

        function updateGauge() {

            $(values).animate({
                v1: Math.round(Math.random() * 100),
                v2: Math.round(Math.random() * 100),
                v3: Math.round(Math.random() * 100)
            },
            {
                duration: 600,
                step: function () {
                    var scales = $('#jqLinearGauge').jqLinearGauge('option', 'scales');

                    scales[0].barMarkers[0].value = this.v1;
                    scales[0].barMarkers[1].value = this.v2;
                    scales[0].barMarkers[2].value = this.v3;

                    $('#jqLinearGauge').jqLinearGauge('update');
                },
                complete: function () {
                    setTimeout('updateGauge()', 400);
                }
            });
        }

        $(document).ready(function () {
            updateGauge();
        });
    </script>
</body>
</html>

                                        
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SamplesBrowser.Models;

namespace GaugesSamplesBrowser.Controllers
{
    public class GaugeController : Controller
    {

    public ActionResult LiveData()
        {
            return View();
        }

    }
}