Skip to content

Commit 6f79820

Browse files
authored
fix(playground): Multiple percent-formatted values by 100 before display, thanks @hank-sq (cube-js#10624)
The Playground was displaying format: percent values with a raw % suffix (e.g. 0.273%) instead of multiplying by 100 first (27.3%). This contradicts the documented behavior where presentation tools should apply the multiplication implicitly. Fixes cube-js#10623 Made-with: Cursor
1 parent 251eac1 commit 6f79820

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

packages/cubejs-playground/src/QueryBuilderV2/QueryBuilderResults.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ export function QueryBuilderResults({ forceMinHeight }: { forceMinHeight?: boole
786786
];
787787
case 'percent':
788788
return [
789-
`${formatNumber(typeof value === 'string' ? parseFloat(value) : value)}%`,
789+
`${formatNumber((typeof value === 'string' ? parseFloat(value) : value) * 100)}%`,
790790
'percent',
791791
];
792792
default:

packages/cubejs-playground/src/QueryBuilderV2/components/ChartRenderer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,10 @@ const TypeToChartComponent = {
466466
return text && text !== '0' ? 'true' : 'false';
467467
}
468468

469+
if (c.format === 'percent' && text != null) {
470+
return `${(parseFloat(text) * 100).toFixed(2)}%`;
471+
}
472+
469473
return text;
470474
}
471475
},

packages/cubejs-playground/src/components/DrilldownModal/TableQueryRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const formatTableData = (columns, data) => {
3636
}
3737

3838
if (type === 'number' && format === 'percent') {
39-
return [parseFloat(value).toFixed(2), '%'].join('');
39+
return [(parseFloat(value) * 100).toFixed(2), '%'].join('');
4040
}
4141

4242
return value.toString();

0 commit comments

Comments
 (0)