@@ -44,7 +44,11 @@ export function format_cell(
4444 const plugin : ColumnConfig = plugins [ title ] || { } ;
4545 const is_numeric = type === "integer" || type === "float" ;
4646
47- if ( is_numeric && plugin ?. number_fg_mode === "bar" ) {
47+ if (
48+ is_numeric &&
49+ ( plugin ?. number_fg_mode === "bar" ||
50+ plugin ?. number_fg_mode === "label-bar" )
51+ ) {
4852 const a = Math . max (
4953 0 ,
5054 Math . min (
@@ -54,15 +58,41 @@ export function format_cell(
5458 ) ,
5559 ) ;
5660
57- const div = this . _div_factory . get ( ) ;
5861 const anchor = ( val as number ) >= 0 ? "left" : "right" ;
5962 const pct = ( a * 100 ) . toFixed ( 2 ) ;
60- div . setAttribute (
61- "style" ,
62- `width:calc(${ pct } % - 4px);position:absolute;${ anchor } :2px;height:80%;top:10%;pointer-events:none;` ,
63- ) ;
6463
65- return div ;
64+ if ( plugin . number_fg_mode === "bar" ) {
65+ const div = this . _div_factory . get ( ) ;
66+ div . className = "psp-bar" ;
67+ div . setAttribute (
68+ "style" ,
69+ `width:calc(${ pct } % - 4px);position:absolute;${ anchor } :2px;height:80%;top:10%;pointer-events:none;` ,
70+ ) ;
71+
72+ return div ;
73+ } else {
74+ const wrapper = this . _div_factory . get ( ) ;
75+ wrapper . setAttribute ( "style" , "" ) ;
76+ wrapper . className = "psp-label-bar" ;
77+ while ( wrapper . firstChild ) {
78+ wrapper . removeChild ( wrapper . firstChild ) ;
79+ }
80+ const bar = document . createElement ( "div" ) ;
81+ bar . className = "psp-label-bar-fill" ;
82+ bar . setAttribute (
83+ "style" ,
84+ `width:calc(${ pct } % - 4px);${ anchor } :2px;` ,
85+ ) ;
86+ const label = document . createElement ( "span" ) ;
87+ label . className = "psp-label-bar-text" ;
88+ const formatter = FORMAT_CACHE . get ( type , plugin ) ;
89+ label . textContent = formatter
90+ ? formatter . format ( val )
91+ : ( val as string ) ;
92+ wrapper . appendChild ( bar ) ;
93+ wrapper . appendChild ( label ) ;
94+ return wrapper ;
95+ }
6696 } else if ( plugin ?. format === "link" && type === "string" ) {
6797 const anchor = document . createElement ( "a" ) ;
6898 anchor . setAttribute ( "href" , val as string ) ;
0 commit comments