Back to column formats
Column formattingSharePoint Online

Number Gradation

This sample demonstrates a gradual background color change between the minimum and maximum values.

Number Gradation formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

3 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",
  "style": {
    "background-color": "=if(@currentField == '' , '' , if(@currentField < (((90) + (-30)) / 2) , 'rgba(0,' + if(@currentField < (-30) , 0 , (255 * (abs((@currentField) - (-30)) / (((90) - (-30)) / 2)))) + ', 255 , 0.35)' , 'rgba(0,255,' + if(@currentField > (90) , 0 , (255 * (abs((90) - (@currentField)) / (((90) - (-30))/2)))) + ', 0.35)'))"
  },
  "children": [
    {
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "font-size": "20px",
        "font-weight": "bold",
        "margin-left": "10px"
      }
    }
  ]
}

From the contributor

How to use this sample

Summary

This sample demonstrates a gradual background color change between the minimum and maximum values. In this sample, the minimum value is -30 and the maximum value is 90.

screenshot of the sample

View requirements

This format can be applied to a Number column. It is expected that the values will be from -30 to 90.

Sample

Solution Author(s)
number-gradation.json Tetsuya Kawahara
number-gradation-green-blue.json Tetsuya Kawahara
number-gradation-red-blue.json Tetsuya Kawahara

Version history

Version Date Comments
1.0 April 8, 2022 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.