Skip to content

Commit f954115

Browse files
authored
docs(charts): improve documentation & add tooltipConfig stories (#6410)
Fixes #6335
1 parent 34b573b commit f954115

File tree

23 files changed

+185
-15
lines changed

23 files changed

+185
-15
lines changed

.storybook/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ const config: StorybookConfig = {
4444
titlePrefix: 'Knowledge Base'
4545
},
4646
{
47-
directory: '../packages/charts',
48-
files: '**/*@(.stories.tsx)',
47+
directory: '../packages/charts/src/components',
48+
files: '**/*.@(mdx|stories.@(mdx|tsx))',
4949
titlePrefix: 'Charts'
5050
},
5151
{

cypress.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export default defineConfig({
1313
'**/node_modules/**',
1414
'packages/*/src/index.ts',
1515
'packages/main/src/components/AnalyticalTable/types/*',
16-
'packages/main/src/webComponents/**'
16+
'packages/main/src/webComponents/**',
17+
'packages/charts/src/resources/**'
1718
]
1819
}
1920
},

packages/charts/src/components/BarChart/BarChart.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ControlsWithNote, DocsHeader, Footer } from '@sb/components';
22
import { Canvas, Meta } from '@storybook/addon-docs';
3+
import TooltipStory from '../../resources/TooltipConfig.mdx';
34
import * as ComponentStories from './BarChart.stories';
45

56
<Meta of={ComponentStories} />
@@ -62,4 +63,6 @@ You can set a reference line to any value by using the `referenceLine` `chartCon
6263

6364
<Canvas of={ComponentStories.WithHighlightedMeasure} />
6465

66+
<TooltipStory of={ComponentStories.WithCustomTooltipConfig} />
67+
6568
<Footer />

packages/charts/src/components/BarChart/BarChart.stories.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Meta, StoryObj } from '@storybook/react';
2-
import { complexDataSet, secondaryDimensionDataSet, simpleDataSet } from '../../resources/DemoProps.js';
2+
import { complexDataSet, secondaryDimensionDataSet, simpleDataSet, tooltipConfig } from '../../resources/DemoProps.js';
33
import { BarChart } from './BarChart.js';
44

55
const meta = {
@@ -152,3 +152,7 @@ export const WithHighlightedMeasure: Story = {
152152
]
153153
}
154154
};
155+
156+
export const WithCustomTooltipConfig: Story = {
157+
args: tooltipConfig
158+
};

packages/charts/src/components/BulletChart/BulletChart.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ControlsWithNote, DocsHeader, Footer } from '@sb/components';
22
import { Canvas, Meta } from '@storybook/addon-docs';
3+
import TooltipStory from '../../resources/TooltipConfig.mdx';
34
import * as ComponentStories from './BulletChart.stories';
45

56
<Meta of={ComponentStories} />
@@ -64,4 +65,6 @@ You can do this via the `measures` array:
6465

6566
<Canvas of={ComponentStories.LoadingPlaceholder} />
6667

68+
<TooltipStory of={ComponentStories.WithCustomTooltipConfig} />
69+
6770
<Footer />

packages/charts/src/components/BulletChart/BulletChart.stories.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Meta, StoryObj } from '@storybook/react';
2-
import { complexBulletDataset } from '../../resources/DemoProps.js';
2+
import { complexBulletDataset, tooltipConfig } from '../../resources/DemoProps.js';
33
import { BulletChart } from './BulletChart.js';
44

55
const meta = {
@@ -116,3 +116,7 @@ export const LoadingPlaceholder: Story = {
116116
dataset: []
117117
}
118118
};
119+
120+
export const WithCustomTooltipConfig: Story = {
121+
args: tooltipConfig
122+
};

packages/charts/src/components/ColumnChart/ColumnChart.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ControlsWithNote, DocsHeader, Footer } from '@sb/components';
22
import { Canvas, Meta } from '@storybook/addon-docs';
3+
import TooltipStory from '../../resources/TooltipConfig.mdx';
34
import * as ComponentStories from './ColumnChart.stories';
45

56
<Meta of={ComponentStories} />
@@ -61,4 +62,6 @@ You can set a reference line to any value by using the `referenceLine` `chartCon
6162

6263
<Canvas of={ComponentStories.WithHighlightedMeasure} />
6364

65+
<TooltipStory of={ComponentStories.WithCustomTooltipConfig} />;
66+
6467
<Footer />

packages/charts/src/components/ColumnChart/ColumnChart.stories.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Meta, StoryObj } from '@storybook/react';
2-
import { complexDataSet, secondaryDimensionDataSet, simpleDataSet } from '../../resources/DemoProps.js';
2+
import { complexDataSet, secondaryDimensionDataSet, simpleDataSet, tooltipConfig } from '../../resources/DemoProps.js';
33
import { ColumnChart } from './ColumnChart.js';
44

55
const meta = {
@@ -143,3 +143,7 @@ export const WithHighlightedMeasure: Story = {
143143
]
144144
}
145145
};
146+
147+
export const WithCustomTooltipConfig: Story = {
148+
args: tooltipConfig
149+
};

packages/charts/src/components/ColumnChartWithTrend/ColumnChartWithTrend.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ interface DimensionConfig extends IChartDimension {
4949
}
5050

5151
export interface ColumnChartWithTrendProps
52-
extends Omit<IChartBaseProps<Omit<ICartesianChartConfig, 'secondYAxis' | 'secondYAxisConfig'>>, 'syncId'> {
52+
extends Omit<
53+
IChartBaseProps<Omit<ICartesianChartConfig, 'secondYAxis' | 'secondYAxisConfig'>>,
54+
'syncId' | 'tooltipConfig'
55+
> {
5356
/**
5457
* An array of config objects. Each object will define one dimension of the chart.
5558
*
@@ -59,7 +62,7 @@ export interface ColumnChartWithTrendProps
5962
*
6063
* **Optional Properties**
6164
* - `formatter`: function will be called for each data label and allows you to format it according to your needs
62-
* - `interval`: number that controls how many ticks are rendered on the x axis
65+
* - `interval`: number that controls how many ticks are rendered on the x-axis
6366
*
6467
*/
6568
dimensions: DimensionConfig[];
@@ -160,7 +163,7 @@ const ColumnChartWithTrend = forwardRef<HTMLDivElement, ColumnChartWithTrendProp
160163
}
161164
} as TooltipProps<any, any>;
162165

163-
const { chartConfig: _0, dimensions: _1, measures: _2, tooltipConfig: _3, ...propsWithoutOmitted } = rest;
166+
const { chartConfig: _0, dimensions: _1, measures: _2, ...propsWithoutOmitted } = rest;
164167

165168
return (
166169
<div

packages/charts/src/components/ComposedChart/ComposedChart.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ControlsWithNote, DocsHeader, Footer } from '@sb/components';
22
import { Canvas, Meta } from '@storybook/addon-docs';
3+
import TooltipStory from '../../resources/TooltipConfig.mdx';
34
import * as ComponentStories from './ComposedChart.stories';
45

56
<Meta of={ComponentStories} />
@@ -62,4 +63,6 @@ You can set a reference line to any value by using the `referenceLine` `chartCon
6263

6364
<Canvas of={ComponentStories.LoadingPlaceholder} />
6465

66+
<TooltipStory of={ComponentStories.WithCustomTooltipConfig} />
67+
6568
<Footer />

0 commit comments

Comments
 (0)