diff --git a/src/vs/workbench/services/positronDataExplorer/browser/components/columnNullPercent.tsx b/src/vs/workbench/services/positronDataExplorer/browser/components/columnNullPercent.tsx index 73265f2804b..1b4c7a2e77f 100644 --- a/src/vs/workbench/services/positronDataExplorer/browser/components/columnNullPercent.tsx +++ b/src/vs/workbench/services/positronDataExplorer/browser/components/columnNullPercent.tsx @@ -10,6 +10,11 @@ import 'vs/css!./columnNullPercent'; import * as React from 'react'; import { positronClassNames } from 'vs/base/common/positronUtilities'; +/** + * Constants. + */ +const SVG_WIDTH = 50; + /** * ColumnNullPercentProps interface. */ @@ -23,13 +28,17 @@ interface ColumnNullPercentProps { * @returns The rendered component. */ export const ColumnNullPercent = (props: ColumnNullPercentProps) => { - // Render. - let svgWidth = 50; - if (props.columnNullPercent !== undefined) { - svgWidth = props.columnNullPercent === 0.0 ? - 50 : - Math.max(50 * ((100 - props.columnNullPercent) / 100), 3); + // Calculate the column null percent (and guard against values that are out of range). + let columnNullPercent; + if (!props.columnNullPercent || props.columnNullPercent < 0) { + columnNullPercent = 0; + } else if (props.columnNullPercent >= 100) { + columnNullPercent = 100; + } else { + columnNullPercent = Math.min(Math.max(props.columnNullPercent, 5), 95); } + + // Render. return (