@opendatasoft/visualizations-react
Version:
Opendatasoft's React wrapper for visualization components.
26 lines (25 loc) • 1.45 kB
TypeScript
import React from 'react';
import type { ChartOptions, DataFrame } from '@opendatasoft/visualizations';
import { Meta, StoryObj } from '@storybook/react';
import type { Props } from 'reactify';
/**
* By default the chart keeps a fixed `aspectRatio` (a numeric width/height ratio) and derives its
* height from its width. Setting `aspectRatio: 'auto'` drops that constraint and lets ChartJS size
* the canvas from the parent's box instead, which requires the parent to have an explicit height.
*
* Drag the bottom-right corner of either box below: the `'auto'` chart follows both dimensions,
* while the fixed one keeps its ratio and letterboxes inside the leftover space.
*/
declare const meta: Meta;
export default meta;
/**
* Resizable host with an explicit height, which `aspectRatio: 'auto'` needs to fill. The shared
* ChartTemplate can't be reused here: it sets a width but leaves the height to the content.
*
* The box starts tall enough for the fixed-ratio chart to fit, so what you see when resizing is the
* ratio behaviour rather than a scrollbar. `overflow: hidden` (still resizable) also absorbs the
* couple of pixels a content-box card overflows its container by.
*/
declare const ResizableChartTemplate: (args: Props<DataFrame, ChartOptions>) => React.JSX.Element;
export declare const AutoAspectRatio: StoryObj<typeof ResizableChartTemplate>;
export declare const FixedAspectRatio: StoryObj<typeof ResizableChartTemplate>;