2024-01-15 18:40:24 -07:00
|
|
|
import { ScaleBand, ScaleLinear } from 'd3-scale'
|
2024-01-10 13:30:46 -07:00
|
|
|
|
2024-01-15 18:40:24 -07:00
|
|
|
export type ScaleLinearType = ScaleLinear<number, number>;
|
|
|
|
export type ScaleBandType = ScaleBand<number | string>;
|
2024-01-12 14:04:45 -07:00
|
|
|
|
|
|
|
export interface YAxisData {
|
2024-01-12 17:21:40 -07:00
|
|
|
key: string; // string value for ChartLabel and useGraphData
|
|
|
|
values: Array<number>;
|
2024-01-12 14:04:45 -07:00
|
|
|
// including this code only for review --
|
|
|
|
// do we prefer the idea of passing label formatting from the data or in the component?
|
|
|
|
// generic function type, specific usage of value varies
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
formatLabel?: (value: number) => string;
|
|
|
|
}
|
|
|
|
|
2024-01-12 17:21:40 -07:00
|
|
|
export type XValue = string | number
|
|
|
|
|
2024-01-12 14:04:45 -07:00
|
|
|
export interface GraphData {
|
2024-01-12 17:21:40 -07:00
|
|
|
xValues: Array<XValue>;
|
|
|
|
yValues: Array<YAxisData>;
|
2024-01-12 14:04:45 -07:00
|
|
|
}
|
|
|
|
|
2024-01-15 13:33:08 -07:00
|
|
|
export interface YAxisProps {
|
2024-01-12 14:04:45 -07:00
|
|
|
maxLeftYAxisValue?: number;
|
|
|
|
maxRightYAxisValue?: number;
|
|
|
|
selectedLeftYAxisLabel?: string;
|
|
|
|
selectedRightYAxisLabel?: string;
|
|
|
|
// generic function type, specific usage of value varies
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
formatRightYAxisLabel?: (value: string) => string;
|
|
|
|
// generic function type, specific usage of value varies
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
formatLeftYAxisLabel?: (value: string) => string;
|
|
|
|
}
|
2024-01-12 17:21:40 -07:00
|
|
|
export interface GraphProps {
|
2024-01-12 14:04:45 -07:00
|
|
|
data: GraphData;
|
|
|
|
height?: number;
|
|
|
|
spacingInner?: number;
|
|
|
|
spacingOuter?: number;
|
|
|
|
contentInset?: { top: number; bottom: number };
|
|
|
|
min?: number;
|
|
|
|
numberOfTicks?: number;
|
|
|
|
barColors?: Array<string>;
|
2024-01-15 18:40:24 -07:00
|
|
|
useCommonScale?: boolean;
|
2024-01-12 14:04:45 -07:00
|
|
|
yAxisProps?: YAxisProps;
|
|
|
|
}
|