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> <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); }) .Tooltips(tooltips => { tooltips.Disabled(false).Highlighting(true); }) .Animation(new TimeSpan(0,0,1)) .Scales(scales => { scales.LinearScale() .Minimum(0) .Maximum(100) .Interval(10) .Labels(labels => { labels.Offset(0.14) .HorizontalAlignment(HorizontalAlignment.Right); }) .MajorTickMarks(majorTickMarks => { majorTickMarks.Offset(0.18).LineWidth(2); }) .MinorTickMarks(minorTickMarks => { minorTickMarks.Offset(0.24) .Visible(true) .LineWidth(2) .Interval(2); }) .BarMarkers(barMarkers => { barMarkers.LinearBarMarker() .Value(70) .InnerOffset(0.4) .OuterOffset(0.65) .FillStyle(gradient => { gradient.LinearGradient(0, 0, 1, 0) .ColorStops(colorStops => { colorStops.Add(0, "#65c2e8"); colorStops.Add(0.49, "#55b3e1"); colorStops.Add(0.5, "#3ba6dc"); colorStops.Add(1, "#2794d4"); }); }); barMarkers.LinearBarMarker() .Value(90) .InnerOffset(0.7) .OuterOffset(0.95) .FillStyle(gradient => { gradient.LinearGradient(0, 0, 1, 0) .ColorStops(colorStops => { colorStops.Add(0, "#eea151"); colorStops.Add(0.49, "#ea8f44"); colorStops.Add(0.5, "#e67e28"); colorStops.Add(1, "#e06818"); }); }); }); }) .Render()%> </div> </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> <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); }) .Tooltips(tooltips => { tooltips.Disabled(false).Highlighting(true); }) .Animation(new TimeSpan(0,0,1)) .Scales(scales => { scales.LinearScale() .Minimum(0) .Maximum(100) .Interval(10) .Labels(labels => { labels.Offset(0.14) .HorizontalAlignment(HorizontalAlignment.Right); }) .MajorTickMarks(majorTickMarks => { majorTickMarks.Offset(0.18).LineWidth(2); }) .MinorTickMarks(minorTickMarks => { minorTickMarks.Offset(0.24) .Visible(true) .LineWidth(2) .Interval(2); }) .BarMarkers(barMarkers => { barMarkers.LinearBarMarker() .Value(70) .InnerOffset(0.4) .OuterOffset(0.65) .FillStyle(gradient => { gradient.LinearGradient(0, 0, 1, 0) .ColorStops(colorStops => { colorStops.Add(0, "#65c2e8"); colorStops.Add(0.49, "#55b3e1"); colorStops.Add(0.5, "#3ba6dc"); colorStops.Add(1, "#2794d4"); }); }); barMarkers.LinearBarMarker() .Value(90) .InnerOffset(0.7) .OuterOffset(0.95) .FillStyle(gradient => { gradient.LinearGradient(0, 0, 1, 0) .ColorStops(colorStops => { colorStops.Add(0, "#eea151"); colorStops.Add(0.49, "#ea8f44"); colorStops.Add(0.5, "#e67e28"); colorStops.Add(1, "#e06818"); }); }); }); }) .Render() ) </div> </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 Gradients() { return View(); } } } |