import React from "react"; import { ClassTable } from "./ClassTable.js"; import { defaultReportContext } from "../../context/index.js"; import { CardDecorator, createReportDecorator } from "../storybook/index.js"; import { createMetric } from "../../metrics/index.js"; import { longClassMetrics, simpleClassMetrics, simpleMetricGroup, simpleObjectives, categoricalClassMetrics, categoricalMultiObjective, categoricalSingleObjective, categoricalClassMetricsMixedTarget, categoricalMetricGroup, categoricalMetricGroupMixedTarget, NaNPercMetrics, } from "../../testing/fixtures/metrics.js"; import { valueFormatter } from "../../helpers/valueFormatter.js"; import Translator from "../i18n/TranslatorAsync.js"; export default { component: ClassTable, title: "Components/Table/ClassTable", decorators: [CardDecorator, createReportDecorator(defaultReportContext)], }; export const simple = () => { return ( ); }; export const number1digit = () => { return ( ); }; export const number2digit = () => { return ( ); }; export const numberThousands = () => { return ( ({ ...m, value: m.value * 10_000_000, }))} metricGroup={simpleMetricGroup} objective={simpleObjectives} columnConfig={[ { type: "class", }, { type: "metricValue", metricId: simpleMetricGroup.metricId, valueFormatter: "number1dig", }, ]} /> ); }; export const integer = () => { return ( ({ ...m, value: m.value * 10, }))} metricGroup={simpleMetricGroup} objective={simpleObjectives} columnConfig={[ { type: "class", }, { type: "metricValue", metricId: simpleMetricGroup.metricId, valueFormatter: "integer", }, ]} /> ); }; export const percent = () => { return ( ); }; export const percent1Digit = () => { return ( ); }; export const percent2Digit = () => { return ( ); }; export const percentThousands = () => { return ( ); }; export const simpleLayerToggle = () => { return ( ); }; export const simpleGoal = () => { return ( ); }; export const simpleBoth = () => { return ( ); }; export const categoricalData = () => { return ( ); }; export const tableWithNanValue = () => { return ( ); }; export const valueFormatAndLabel = () => { return ( (typeof val === "string" ? Number.parseFloat(val) : val) * 1000, valueLabel: "ideas", }, ]} /> ); }; export const chartWithSeparateSortableValueColumn = () => { return ( ); }; export const chartWithIntegratedValueAndTargetPass = () => { return ( ); }; export const chartWithNanValue = () => { return (

Bays and Coast data class in this story has a NaN value. This use case happens when no features for a data class overlap with a given geography. In this scenario a NaN metric value is produced by toPercentMetric(), because the denominator value is zero. ClassTable picks up on this and displays more information to the user()

); }; export const chartWithObjective = () => { return ( ); }; export const chartWithMixedTarget = () => { return ( { if (row === 0) { return (value: number) => `${valueFormatter(value / 100, "percent0dig")} Target`; } else { return (value: number) => `${valueFormatter(value / 100, "percent0dig")}`; } }, }, { type: "layerToggle", width: 15, }, ]} /> ); }; export const chartWithSeparateTargetColumn = () => { return ( ); }; export const chartWithWideTitle = () => { return ( ); };