Tutorial 45: Gauges with range colors
« on: February 05, 2016, 01:24:40 AM »
Steps:

1. Create a new Windows application project (VB.NET)
2. Add Crossing Charts Library to the toolbox pallete and drag it to Form1.
3. Copy and paste de following code:

Note: the code in the Form1_Load event could be used in ASP.NET applications as well.

Code: [Select]
Imports CrossingChartsLibrary
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  Dim sf As New SeriesFactory
  sf.AddValue(75)   ' value of gauge's needle
  With CrossingCharts1
    .Title = "Gauge example with range colors"
    .Style = STYLE2D3D.STYLE2D_GAUGE
    .BackStyle = STYLEBACKGROUND.STYLEBACKGROUND_GRADIENT_TUBULAR
    .Series = sf.Series
    ' Datatable setup
    .ShowDataTable = False
    .ShowLegend = False
    ' Scale setup
    .YAxisScaleMaximum = 100
    .YAxisScaleMinimum = 0
    .YAxisScaleMode = SCALEMODE.SCALEMODE_FIXED
    .YAxisNumericFormat = 0
    ' Gauge setup
    .GaugeBackStyle = New SolidBrush() {New SolidBrush(Color.White)}
    .GaugeBorderStyle = New Pen() {New Pen(Color.Black, 3)}
    .GaugeBigTickStyle = New Pen() {New Pen(Color.Black, 2)}
    .GaugeSmallTickStyle = New Pen() {New Pen(Color.Black, 1)}
    .GaugeCentralCircleBackStyle = New SolidBrush() {New SolidBrush(Color.Gray)}
    ' Needle style
    Dim p As Pen = New Pen(Color.Black, 6)
    p.EndCap = Drawing2D.LineCap.ArrowAnchor
    .GaugeNeedleStyle = New Pen() {p}
    ' Range colors
    Dim rangeColors(0) As ArrayList
    rangeColors(0) = New ArrayList
    rangeColors(0).Add(New Object() {0, 30, Color.FromArgb(200, Color.Red)})
    rangeColors(0).Add(New Object() {30, 50, Color.FromArgb(200, Color.Green)})
    rangeColors(0).Add(New Object() {50, 100, Color.FromArgb(200, Color.Yellow)})
    .GaugeRangeColors = rangeColors
    .RefreshChart()
  End With
End Sub
End Class

Results:

« Last Edit: February 16, 2016, 11:15:52 AM by CrossingCharts »