From ec27abc0a865ff686adba6f789ada73ce78a2618 Mon Sep 17 00:00:00 2001 From: nickofthyme Date: Thu, 19 Aug 2021 10:13:03 -0500 Subject: [PATCH] fix(legend): no truncation with single value --- ...e-series-visually-looks-correct-1-snap.png | Bin 0 -> 11897 bytes .../src/components/legend/style_utils.ts | 2 +- storybook/stories/legend/14_single_series.tsx | 66 ++++++++++++++++++ storybook/stories/legend/legend.stories.tsx | 1 + 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-legend-single-series-visually-looks-correct-1-snap.png create mode 100644 storybook/stories/legend/14_single_series.tsx diff --git a/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-legend-single-series-visually-looks-correct-1-snap.png b/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-legend-single-series-visually-looks-correct-1-snap.png new file mode 100644 index 0000000000000000000000000000000000000000..601afd94e0f5b547852eb1551bb66e87d6f71d2a GIT binary patch literal 11897 zcmeHtX*8Q_8?OEJ>$Y1}-EFaH(P68is-VmZmbeH9_ahi28?B5WJrB3<~2m0rN6H^k)l-YTIKrM}J z*ZO4YgQ=G?k_hYxF%*mNJhC>MYeL+#aHo0;iYwJO57T;9eX1E(rVWiZUu)42bEt0A z+N6-?VEVwa)|>wK0ky4>Nj4c;v&`uc;-1C6uwYvH6*CC7AS0bIuyej{Nj!|nMDjz; zj8|}2yC|CGc=EV6SpqqZeXP?xG|uY2T*!QpKO z4)=edjog!`fBi6Ajp|a5 zmPGn`B;U=|Y~2_Rp6&LcD}^2w7A~^$CYIwmR#IqND_q~ONMqxTLM?)SZTHKk66@Hy z9Y36jsr#o_2Qw5&KdtNPf^922vm`OWlh+|hT45PV)PLn9vy)8ey6g}<@D=;-Ev@AGn+i(=S6xi^&>GP$)jjzM!o8=>$vUX6d zccr9uVck$QFBv{K0iw~AfW??{mYuBdk06C zZ{f=wHd<)w&Q+9Z516e0^hc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ht zKFhl7afbu=;(vJV>u(9(rC1}5_`2d1^EByIC@%#S*JFvZvx}^8o)`x`f_EzFp zYT;wL1};zxQr=l^2wfUo{X>*t^M{wdr4!4>=q w8owNjZ0Z})1F!kEj$m{5fHC6ae>rSx37l4{^%dRp { + const rng = getRandomNumberGenerator(); + const maxLines = number('max label lines', 0, { min: 0, step: 1 }); + const seriesCount = number('series count', 1, { min: 1, step: 1 }); + const data = [ + { x: 0, y: 2 }, + { x: 1, y: 7 }, + { x: 2, y: 3 }, + { x: 3, y: 6 }, + ]; + const renderMoreSeries = () => { + const series: JSX.Element[] = []; + + for (let i = 1; i < seriesCount; i++) { + series.push( + ({ x, y: y + rng(0, 5) }))} + />, + ); + } + + return series; + }; + return ( + + + + {renderMoreSeries()} + + ); +}; diff --git a/storybook/stories/legend/legend.stories.tsx b/storybook/stories/legend/legend.stories.tsx index 130dd353b0..3fda44fb7c 100644 --- a/storybook/stories/legend/legend.stories.tsx +++ b/storybook/stories/legend/legend.stories.tsx @@ -29,3 +29,4 @@ export { Example as piechart } from './10_sunburst'; export { Example as piechartRepeatedLabels } from './10_sunburst_repeated_label'; export { Example as actions } from './11_legend_actions'; export { Example as margins } from './12_legend_margins'; +export { Example as singleSeries } from './14_single_series';