Bookmark this: tool.io/diagram/measurement-axis-values/source-code
Height and Weight Axis Values Source Code
Browse the implementation files for Height and Weight Axis Values.tool.ts typescript
const finite = (value: unknown): number | undefined => {
if (value === '') return undefined;
const parsed =
typeof value === 'number' ? value : Number(value);
return Number.isFinite(parsed) ? parsed : undefined;
};
export const measurementAxisValues = (
weightKg: unknown,
heightM: unknown
): { heightM: number; weightKg: number } | '' => {
const weight = finite(weightKg);
const height = finite(heightM);
return weight === undefined || height === undefined
? ''
: { heightM: height, weightKg: weight };
};
export const Tool: TypeTool = {
i: [
{
example: '70',
id: 'weightKg',
label: 'Weight',
placeholder: 'Weight in kilograms',
type: 'number',
valueType: { format: 'mass', type: 'number', unit: 'kg' }
},
{
example: '1.8',
id: 'heightM',
label: 'Height',
placeholder: 'Height in meters',
type: 'number',
valueType: { format: 'length', type: 'number', unit: 'm' }
}
],
intro:
'Provide height and weight values to a measurement diagram chain.',
name: 'Height and Weight Axis Values',
o: [
{
id: 'weightKg',
label: 'Weight',
placeholder: 'Weight in kilograms',
type: 'number',
valueType: { format: 'mass', type: 'number', unit: 'kg' }
},
{
id: 'heightM',
label: 'Height',
placeholder: 'Height in meters',
type: 'number',
valueType: { format: 'length', type: 'number', unit: 'm' }
}
],
slug: 'diagram/measurement-axis-values',
tool: measurementAxisValues
};
export default Tool;
Description
Browse the implementation files for Height and Weight Axis Values.