storybook updates
This commit is contained in:
@@ -50,6 +50,7 @@ const meta: Meta<StoryProps> = {
|
|||||||
thresholdsBar: false,
|
thresholdsBar: false,
|
||||||
colorScheme: FieldColorModeId.Thresholds,
|
colorScheme: FieldColorModeId.Thresholds,
|
||||||
decimals: 0,
|
decimals: 0,
|
||||||
|
neutral: undefined,
|
||||||
},
|
},
|
||||||
argTypes: {
|
argTypes: {
|
||||||
barWidthFactor: { control: { type: 'range', min: 0.1, max: 1, step: 0.01 } },
|
barWidthFactor: { control: { type: 'range', min: 0.1, max: 1, step: 0.01 } },
|
||||||
@@ -75,6 +76,7 @@ const meta: Meta<StoryProps> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
decimals: { control: { type: 'range', min: 0, max: 7 } },
|
decimals: { control: { type: 'range', min: 0, max: 7 } },
|
||||||
|
neutral: { control: { type: 'number' } },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -270,6 +272,23 @@ export const Examples: StoryFn<StoryProps> = (args) => {
|
|||||||
barWidthFactor={0.7}
|
barWidthFactor={0.7}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
<div>
|
||||||
|
Neutral <em>(range -50 to 50, neutral = 0)</em>
|
||||||
|
</div>
|
||||||
|
<Stack direction={'row'} gap={3}>
|
||||||
|
<RadialGaugeExample
|
||||||
|
min={-50}
|
||||||
|
max={50}
|
||||||
|
value={-20}
|
||||||
|
colorScheme={FieldColorModeId.Thresholds}
|
||||||
|
gradient
|
||||||
|
shape="gauge"
|
||||||
|
glowCenter={true}
|
||||||
|
roundedBars={false}
|
||||||
|
barWidthFactor={0.7}
|
||||||
|
neutral={0}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -330,6 +349,7 @@ interface ExampleProps {
|
|||||||
endpointMarker?: RadialGaugeProps['endpointMarker'];
|
endpointMarker?: RadialGaugeProps['endpointMarker'];
|
||||||
decimals?: number;
|
decimals?: number;
|
||||||
showScaleLabels?: boolean;
|
showScaleLabels?: boolean;
|
||||||
|
neutral?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RadialGaugeExample({
|
export function RadialGaugeExample({
|
||||||
@@ -357,6 +377,7 @@ export function RadialGaugeExample({
|
|||||||
endpointMarker = 'glow',
|
endpointMarker = 'glow',
|
||||||
decimals = 0,
|
decimals = 0,
|
||||||
showScaleLabels,
|
showScaleLabels,
|
||||||
|
neutral,
|
||||||
}: ExampleProps) {
|
}: ExampleProps) {
|
||||||
const theme = useTheme2();
|
const theme = useTheme2();
|
||||||
|
|
||||||
@@ -442,6 +463,7 @@ export function RadialGaugeExample({
|
|||||||
thresholdsBar={thresholdsBar}
|
thresholdsBar={thresholdsBar}
|
||||||
showScaleLabels={showScaleLabels}
|
showScaleLabels={showScaleLabels}
|
||||||
endpointMarker={endpointMarker}
|
endpointMarker={endpointMarker}
|
||||||
|
neutral={neutral}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ describe('RadialGauge', () => {
|
|||||||
{ description: 'with endpoint marker point', props: { roundedBars: true, endpointMarker: 'point' } },
|
{ description: 'with endpoint marker point', props: { roundedBars: true, endpointMarker: 'point' } },
|
||||||
{ description: 'with thresholds bar', props: { thresholdsBar: true } },
|
{ description: 'with thresholds bar', props: { thresholdsBar: true } },
|
||||||
{ description: 'with sparkline', props: { sparkline: true } },
|
{ description: 'with sparkline', props: { sparkline: true } },
|
||||||
|
{ description: 'with neutral value', props: { neutral: 50 } },
|
||||||
] satisfies Array<{ description: string; props?: ComponentProps<typeof RadialGaugeExample> }>)(
|
] satisfies Array<{ description: string; props?: ComponentProps<typeof RadialGaugeExample> }>)(
|
||||||
'should render $description without throwing',
|
'should render $description without throwing',
|
||||||
({ props }) => {
|
({ props }) => {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { ThresholdsBar } from './ThresholdsBar';
|
|||||||
import { buildGradientColors } from './colors';
|
import { buildGradientColors } from './colors';
|
||||||
import { GlowGradient, MiddleCircleGlow, SpotlightGradient } from './effects';
|
import { GlowGradient, MiddleCircleGlow, SpotlightGradient } from './effects';
|
||||||
import { RadialShape, RadialTextMode } from './types';
|
import { RadialShape, RadialTextMode } from './types';
|
||||||
import { calculateDimensions, getFieldConfigMinMax, getValueAngleForValue } from './utils';
|
import { calculateDimensions, getValueAngleForValue } from './utils';
|
||||||
|
|
||||||
export interface RadialGaugeProps {
|
export interface RadialGaugeProps {
|
||||||
values: FieldDisplay[];
|
values: FieldDisplay[];
|
||||||
|
|||||||
Reference in New Issue
Block a user