Skip to content

PercentCompleteBarColumn

Show the percent complete bar.

Constructor Properties

PropertyDescription
minDefines the minimum value of the bar.
maxDefines the maximum value of the bar.
formatterDefine the value display format.

Style Properties

PropertyDescriptionDefault
barColorDefine color of bar. you can set a function that returns color from the value.--
barBgColorDefine background color of bar.--
barHeightDefine height of bar.--
textAlignDefine the horizontal position of text in cell.'left'
textBaselineDefine the vertical position of text in cell.'middle'
colorDefine the color of cell.Resolve by the theme.
fontDefine the font of cell.--
paddingDefine the padding of cell. If you set 4 values separately, please set the Array.--
textOverflowDefine how to display when text overflows the area of a cell. clip or ellipsis is available.'clip'

In addition to this, the Standard styles is available.

html
<div class="sample1 demo-grid middle"></div>
js
const grid = new cheetahGrid.ListGrid({
  parentElement: document.querySelector(".sample1"),
  header: [
    { field: "percent", caption: "label", width: 100 },
    {
      field: "percent",
      caption: "percent",
      width: 200,
      columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn(),
    },
    {
      field: "value",
      caption: "value(10-20)",
      width: 200,
      columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn({
        min: 10,
        max: 20,
      }),
    },
    {
      field: "value",
      caption: "value(format)",
      width: 200,
      columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn({
        min: 10,
        max: 20,
        formatter: (v) => `${v}pt`,
      }),
    },
    {
      field: "percent",
      caption: "percent2",
      width: 200,
      columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn({
        formatter: (s) => "",
      }),
      style: {
        barHeight: 19,
      },
    },
    {
      field: "percent",
      caption: "percent3",
      width: 200,
      columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn(),
      style: {
        barBgColor: "#aaa",
        barColor: "#444",
      },
    },
    {
      field: "percent",
      caption: "percent4",
      width: 200,
      columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn(),
      style: {
        barBgColor: (per) => (per > 50 ? "#faa" : "#aaa"),
        barColor: (per) => (per > 50 ? "#f44" : "#444"),
      },
    },
  ],
  frozenColCount: 1,
});
grid.records = [
  { percent: "100%", value: 20 },
  { percent: "80%", value: 18 },
  { percent: "60%", value: 16 },
  { percent: "40%", value: 14 },
  { percent: "20%", value: 12 },
  { percent: "0%", value: 10 },
];