Skip to content

Commit

Permalink
Export SparkFunnelChart
Browse files Browse the repository at this point in the history
  • Loading branch information
envex committed Oct 15, 2024
1 parent 80d5e22 commit d5b36f6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ export function Tooltip({
);

function formatPercentage(value: number) {
return `${yAxisOptions.labelFormatter(value)}%`;
return `${yAxisOptions.labelFormatter(isNaN(value) ? 0 : value)}%`;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type {Story} from '@storybook/react';

import type {FunnelChartNextProps} from '../../FunnelChartNext';

export default {
...META,
title: `${META.title}/Playground`,
};

import {Template} from './data';
import {META} from './meta';

export const ZeroValues: Story<FunnelChartNextProps> = Template.bind({});

const yAxisOptions = {
labelFormatter: (value) => {
return new Intl.NumberFormat('en', {
style: 'decimal',
maximumFractionDigits: 2,
}).format(Number(value));
},
};

ZeroValues.args = {
data: [
{
data: [
{
value: 0,
key: 'Sessions',
},
{
value: 0,
key: 'Sessions with cart addition',
},
{
value: 0,
key: 'Sessions that reached checkout',
},
{
value: 0,
key: 'Sessions that completed checkout',
},
],
name: 'Conversion rates',
},
],
yAxisOptions: yAxisOptions,
tooltipLabels: {
reached: 'Reached this step',
dropped: 'Dropped off',
},
};
2 changes: 2 additions & 0 deletions packages/polaris-viz/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ export type {LineChartPredictiveProps} from './LineChartPredictive';
export type {ComparisonMetricProps} from './ComparisonMetric';
export {FunnelChartNext} from './FunnelChartNext';
export type {FunnelChartNextProps} from './FunnelChartNext';
export {SparkFunnelChart} from './SparkFunnelChart';
export type {SparkFunnelChartProps} from './SparkFunnelChart';
2 changes: 2 additions & 0 deletions packages/polaris-viz/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export {
LineChartPredictive,
MissingDataArea,
FunnelChartNext,
SparkFunnelChart,
} from './components';

export type {
Expand All @@ -37,6 +38,7 @@ export type {
ComparisonMetricProps,
LineChartRelationalProps,
FunnelChartNextProps,
SparkFunnelChartProps,
} from './components';

export {
Expand Down

0 comments on commit d5b36f6

Please sign in to comment.