Percent Bar

Summary

  • The Percent Bar Style renders a coloured bar in each cell in a numeric column
  • The width of the bar is calculated as percentage of cell value compared to a provided Min and Max value
  • These Min and Max numbers can be set for the whole Column or in Ranges
  • Each set of Min and Max numbers can be hardcoded or based on the values in another Column

The Percent Bar Style enables numeric columns to display a coloured bar in each cell.

Each cell bar's width is calculated as a percentage of the cell's value compared to a maximum value.

As with the Gradient style, a Percent Bar can use one of 2 objects when evaluating:

  • one or more Ranges
  • a Column Comparison

Caution

Percent Bar Styles can only be applied on Styled Columns which have a Scope of a single, numeric Column

Ranges

A Range is used to define a set of cells. It has 3 properties:

  • a minimum value
  • a maxium value
  • an associated colour

When the cell value falls inside the range, the bar displays the appropriate colour.

Hint

This is useful when wanting a traffic light effect - e.g. 0-30: Red; 31-70: Orange; 71-100: Green

There are 2 types of Ranges which can be provided in a Percent Bar:

  • Numeric - Range contains all Column cells which fall between the top and bottom values
  • Percentage - Range contains all Column cells whose value falls in that percentage of all values

Note

  • There is no limit on how many ranges can be created
  • But all Ranges must be of the same type (numeric or percentage) - you cannot mix and match

Numeric Range

In a Numeric Range the top and bottom values are, as the name implies, numeric values.

The top and bottom values in the Range can be provided in 2 ways:

  • Hardcoded Values - the user provides the actual numeric values for the range

  • Dynamic Values - the user selects Col-Min or Col-Max. AdapTable will then automatically evaluate the Column's Minimum or Maximum values and use those

    Note

    • Col-Min or Col-Max values are re-evaluated in real time in response to data changes
    • e.g. if a cell ticks and now becomes the Column's highest value, all the cells will re-render

    Caution

    The Format Column Wizard only permits the automatic Min in the first Range and automatic Max in the last Range

Percent Bar: Numeric Ranges
Fork
  • This example has 2 Columns provided with a Percent Bar Style that uses Numeric Ranges:
    • Github Stars has 3 ranges, rendered in red, amber and green, each using a 'hard-coded' value
    • Closed Prs 1 range using 'Col-Min' and 'Col-Max'

Expand to see the Styled Column Definitions

Percentage Range

A Percentage Range allows users to provide ranges where each cell is calculated as a percentage of the whole column.

For example, a user can create 2 ranges - one containing the top 50% of cell values in the column, and the other containing the bottom 50% of cell values.

Caution

  • The percentage calculation is based on the cell value as a percentage of all the values in the column
  • It is not calculated using the number of cells in the column - that is not part of the evaluation
Percent Bar: Percentage Ranges
Fork
  • In this example the Github Stars Column contains a Percent Bar Style that uses 3 Percentage-based Ranges:
    • 0-33% - rendered in red
    • 33-66% - rendered in amber
    • 66-100% - rendered in green
  • Note: Because most of the column's cell values are in the lowest range, most are red (i.e. it is not evenly distributed)

Expand to see the Styled Column Definitions

Column Comparison

Alternatively, the Percent Bar Style can render by comparing each Cell Value against another column in the row.

Percent Bar: Column Comparisons
Fork
  • This example has a Percent Bar Style on the Open Issues Column using a Column Comparison against Closed Issues
  • We amended the usual row data for the first rows to illustrate different use cases more easily

Decorating Percent Bars

A few additional properties can be added to a Percent Bar to provide the fully required visual effect.

Back Colour

A Back Colour can be added to each cell in a Percent Bar.

This will display in the remainder of the cell which is not rendered with the Percent Bar.

Caution

This takes precedence over any BackColour which has been added to the Cell's Style in Column Formatting

Cell Value

The Percent Bar can be configured to display the underlying cell value.

This can be the actual Cell Value, or the Cell Value calculated as a percentage, or both.

Note

  • The Style of the Cell Value will use whatever Column Formatting has been provided for the Column
  • This includes Alignment, but many other Adaptable Style properties as well (e.g. Colour)

The CellTextPosition property in the Percent Bar Definition allows you configure how the Text is placed relative to the Percent Bar; there are 3 values:

  • Above
  • Below (the default)
  • Merged (the text is placed on top of the Percent Bar)

Tool Tip

The Percent Bar can be provided with a Tool Tip which shows the cell value when hovering over it.

The Tool Tip can display the actual value in the cell, or its value as a percentage, or both.

Percent Bar: Cell Properties
Fork
  • This example has 5 Percent Bars all with extra cell style properties:
    • Github Stars has a Back Colour of Gray
    • Closed PRs renders a Tool Tip when hovering on the Cell which includes both the Cell Value and its Percentage Value
    • Open Issues displays the Cell Value and its Percentage Value below the Percent Bar
    • Open PRs displays the Cell Value merged with the Percent Bar, and it uses the Column Formatting Style of white font and right alignment
    • Github Watchers displays the Cell Value above the Percent Bar

Expand to see the Styled Column Definitions

Defining Percent Bars

Percent Bar Styles can be created at design-time using Styled Column Initial State.

Developer Guide

Defining Percent Bars in Initial Adaptable State

Creating Percent Bars

Percent Bar Styles can be created at run-time using the UI wizard.

UI Step by Step Guide

Creating a Percent Bar Style

Videos

Styled Column Min/Max Values

(Recorded with AdapTable v13.0)

Comparison Percent Bars

(Recorded with AdapTable v14.0)

Formatting Percent Bar text

(Recorded with AdapTable v15.0)

FAQ

Can we see the underlying value in a Percent Bar Style cell? Yes - via the CellText property which you set either at Design Time or at Run Time

Can we right align the cell value in a Percent Bar Style cell? Yes, that is done using standard Column Formatting which will decide how the text in the Percent Bar is rendered