Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions apps/storybook/stories/charts/Tooltip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
spacingVars,
} from '@astryxdesign/core/theme/tokens.stylex';
import {dataVars} from '@astryxdesign/core/theme/dataTokens.stylex';
import {monthlyData} from './_data';
import {monthlyData, monthlyRevenueData} from './_data';

const styles = stylex.create({
modal: {
Expand All @@ -52,7 +52,8 @@ const modalLayeringTheme = defineTheme({
* These examples show the chart's grouped tooltip, which lists the values at
* the x position nearest the pointer: the default card, a custom card body, and
* the hover indicator and hover dot options. Turn it on with the `tooltip` prop
* of `Chart`.
* of `Chart`. See the bare-value card for one primary series and grouped rows
* for comparison.
*/
const meta: Meta<typeof Chart> = {
title: 'Charts/Chrome/Tooltip',
Expand Down Expand Up @@ -428,3 +429,44 @@ export const ModalLayering: StoryObj = {
layer.removeEventListener('beforetoggle', recordToggle);
},
};

/**
* In the default card, one resolved row on a chart with a single primary
* series shows the x value as its heading and a bare value below it, with no
* series label and no color swatch. There is only one value to read, so there
* are no rows to tell apart. A chart with two or more primary series labels
* every row, as in Default, even when only one of its rows resolves at the
* hovered x. Utility marks, such as a reference line, do not count as primary
* series. The series still sets the value format, here `currency('$')`. This
* is a fixed example, so its controls are off.
*
* To check: hover Apr. The card reads "Apr" and "$95.8K", with no "Revenue"
* label and no swatch.
*/
export const SingleSeries: StoryObj = {
name: 'Single series',
render: () => (
<Chart
data={monthlyRevenueData}
xKey="month"
series={[
line('revenue', {
label: 'Revenue',
formatValue: currency('$'),
}),
]}
title="Monthly revenue"
subtitle="US dollars, January to December"
tooltip
grid={<ChartGrid />}
axes={
<>
<ChartAxis position="bottom" />
<ChartAxis position="left" formatTick={currency('$')} />
</>
}
height={320}
/>
),
parameters: {controls: {disable: true}},
};
Loading