Back to column formats
Column formattingSharePoint Online

Number Gauge

This sample demonstrates combining a fixed SVG (gauge background) with a dynamic SVG (needle). It makes understanding number columns (percent) very intuitive.

Number Gauge formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

2 definitions

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "title": "@currentField.displayValue"
  },
  "children": [
    {
      "elmType": "svg",
      "style": {
        "width": "60px",
        "height": "30px"
      },
      "children": [
        {
          "elmType": "path",
          "style": {
            "fill": "#d83b01"
          },
          "attributes": {
            "d": "M 51.198558,8.7668 37.946109,22.01479 a 11.251965,11.248175 0 0 1 3.300487,7.9486 H 60.000001 A 30.005242,29.995135 0 0 0 51.198558,8.7668 Z"
          }
        },
        {
          "elmType": "path",
          "style": {
            "fill": "#af3001"
          },
          "attributes": {
            "d": "m 37.946109,22.01479 -2.650577,2.64967 a 7.5013101,7.4987835 0 0 1 2.200471,5.29893 h 3.750593 a 11.251965,11.248175 0 0 0 -3.300487,-7.9486 z"
          }
        },
        {
          "elmType": "path",
          "style": {
            "fill": "#ffb900"
          },
          "attributes": {
            "d": "m 29.981693,1e-5 3e-6,18.73548 a 11.251965,11.248175 0 0 1 7.956202,3.2875 L 51.198558,8.7668 A 30.005241,29.995135 0 0 0 29.981693,1e-5 Z"
          }
        },
        {
          "elmType": "path",
          "style": {
            "fill": "#d89d00"
          },
          "attributes": {
            "d": "m 29.981696,18.73549 -7e-6,3.74721 a 7.5013098,7.4987833 0 0 1 5.30414,2.19147 l 2.652069,-2.65118 a 11.251965,11.248175 0 0 0 -7.956202,-3.2875 z"
          }
        },
        {
          "elmType": "path",
          "style": {
            "fill": "#bad80a"
          },
          "attributes": {
            "d": "M 8.7779576,8.79849 22.030411,22.04647 A 11.251965,11.248175 0 0 1 29.981693,18.7471 V 1e-5 A 30.005241,29.995135 0 0 0 8.7779576,8.79849 Z"
          }
        },
        {
          "elmType": "path",
          "style": {
            "fill": "#99b208"
          },
          "attributes": {
            "d": "m 22.030411,22.04647 2.650566,2.64969 a 7.5013098,7.4987833 0 0 1 5.300716,-2.19974 V 18.7471 a 11.251965,11.248175 0 0 0 -7.951282,3.29937 z"
          }
        },
        {
          "elmType": "path",
          "style": {
            "fill": "#107c10"
          },
          "attributes": {
            "d": "M 5.7294317e-6,29.99999 H 18.741802 a 11.251965,11.248175 0 0 1 3.288609,-7.95352 L 8.769752,8.79028 A 30.005241,29.995135 0 0 0 5.7294317e-6,29.99999 Z"
          }
        },
        {
          "elmType": "path",
          "style": {
            "fill": "#0b590b"
          },
          "attributes": {
            "d": "M 18.741802,29.99999 22.490276,30 a 7.5013098,7.4987833 0 0 1 2.192203,-5.30235 l -2.652068,-2.65118 a 11.251965,11.248175 0 0 0 -3.288609,7.95352 z"
          }
        },
        {
          "elmType": "path",
          "style": {
            "fill": "#000000"
          },
          "attributes": {
            "d": "m 29.994597,26.96385 a 3.0005242,2.9995135 0 0 0 -3.000562,2.99954 h 6.001125 a 3.0005242,2.9995135 0 0 0 -3.000563,-2.99954 z"
          }
        },
        {
          "elmType": "path",
          "style": {
            "fill": "#000000"
          },
          "attributes": {
            "d": "='M 28 29 L ' + toString(30+26*cos(3.14159265+3.14159265*if(@currentField>0.95,.95,if(@currentField<.05,.05,@currentField)))+if(@currentField < .5,-1,0)) + ' ' + toString(30+26*sin(3.14159265+3.14159265*if(@currentField>0.95,.95,if(@currentField<.05,.05,@currentField)))+if(@currentField < .25,2,0)) + ' L ' + toString(30+26*cos(3.14159265+3.14159265*if(@currentField>0.95,.95,if(@currentField<.05,.05,@currentField)))+if(@currentField > .5,1,0)) + ' ' + toString(30+26*sin(3.14159265+3.14159265*if(@currentField>0.95,.95,if(@currentField<.05,.05,@currentField)))+if(@currentField > .75,2,0)) +' L 32 29 Z'"
          }
        }
      ]
    }
  ]
}

From the contributor

How to use this sample

Summary

This sample demonstrates combining a fixed SVG (gauge background) with a dynamic SVG (needle). It makes understanding number columns (percent) very intuitive.

screenshot of the sample

An alternate version (number-gauge-reversed) has been provided for scenarios where the gauge background should be reversed (green to red).

screenshot reversed

View requirements

  • This format can be applied to a Number column. It is expected that the values will be from 0 to 1 (percent)

Sample

Solution Author(s)
number-gauge.json Chris Kent
number-gauge-reversed.json Chris Kent

Version history

Version Date Comments
1.0 July 10, 2019 Initial release

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.


Additional notes