diff --git a/playground/entries/Chart/Donut.tsx b/playground/entries/Chart/Donut.tsx index 1a879fd6c4..ac65859910 100644 --- a/playground/entries/Chart/Donut.tsx +++ b/playground/entries/Chart/Donut.tsx @@ -13,7 +13,6 @@ type DonutChartProps = { legendProps: Omit; donutProps: { halfsize: boolean; - innerRadius: number; innerLabel: string; }; }; @@ -72,11 +71,6 @@ const entry: PlaygroundEntry = { value: false, displayName: 'Half size', }, - innerRadius: { - type: 'text-number', - value: 60, - displayName: 'Inner Radius', - }, innerLabel: { type: 'text', value: 'Example', diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx index d41f7ce500..71e7ef39ce 100644 --- a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx +++ b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx @@ -1,4 +1,4 @@ -import type { Page } from '@semcore/testing-utils/playwright'; +import type { Locator, Page } from '@semcore/testing-utils/playwright'; import { expect, test } from '@semcore/testing-utils/playwright'; import { expectEachToHaveAttribute, loadPage } from '@semcore/testing-utils/shared/helpers'; import { TAG } from '@semcore/testing-utils/shared/tags'; @@ -18,6 +18,32 @@ export const locators = { text ? page.getByText(text) : page.locator('[data-ui-name="Legend.Item"], [data-ui-name="LegendTable.LegendItem"], [data-ui-name="LegendFlex.LegendItem"]'), }; +/** +The center of a donut pie is empty, so .hover() misses the segment and times out. +Hover over the middle of the ring instead. +*/ +const hoverPie = async (pie: Locator) => { + const box = await pie.boundingBox(); + + if (!box) throw new Error('Donut.Pie is not rendered'); + + const point = await pie.evaluate((path: SVGPathElement) => { + const totalLength = path.getTotalLength(); + const onOuterArc = path.getPointAtLength(totalLength * 0.25); + const onInnerArc = path.getPointAtLength(totalLength * 0.75); + const svgPoint = path.ownerSVGElement!.createSVGPoint(); + + svgPoint.x = (onOuterArc.x + onInnerArc.x) / 2; + svgPoint.y = (onOuterArc.y + onInnerArc.y) / 2; + + const { x, y } = svgPoint.matrixTransform(path.getScreenCTM()!); + + return { x, y }; + }); + + await pie.hover({ position: { x: point.x - box.x, y: point.y - box.y } }); +}; + /* ===================================================== @visual Visual states, hover and focus styles, paddings, margins, and snapshots. @@ -68,7 +94,7 @@ test.describe(`${TAG.VISUAL}`, () => { await test.step('Verify pie highlights on hover', async () => { const pies = locators.pie(page); - await pies.nth(1).hover(); + await hoverPie(pies.nth(1)); if (item.showTooltip) { const tooltip = page.locator('[data-ui-name="Donut.Tooltip"]'); @@ -126,7 +152,7 @@ test.describe(`${TAG.VISUAL}`, () => { await test.step('Verify pie highlights on hover', async () => { const pies = locators.pie(page); - await pies.nth(1).hover(); + await hoverPie(pies.nth(1)); if (item.showTooltip) { const tooltip = page.locator('[data-ui-name="Donut.Tooltip"]'); diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-chromium-linux.png index e072453ca3..9e0348492a 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-firefox-linux.png index 5899fa61d9..1640fca549 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-webkit-linux.png index 80944bc23a..03d90f0940 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Custom-radius-inner-and-outer-radius-variations-2-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-chromium-linux.png index bf06de7a6c..3e085a072c 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-firefox-linux.png index 11843d73c1..32063f70f0 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-webkit-linux.png index 60927c1957..8247816087 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-1-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-chromium-linux.png index bf06de7a6c..3e085a072c 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-firefox-linux.png index 11843d73c1..32063f70f0 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-webkit-linux.png index 60927c1957..f2238beaad 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Patterns-patterns-enabled-no-tooltip-2-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-chromium-linux.png index 8832caece3..0d94a27d8f 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-firefox-linux.png index df7546748c..974f7339b6 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-webkit-linux.png index effc0604b8..18667dd651 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-1-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-chromium-linux.png index 45fc34555c..bfef8727b4 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-firefox-linux.png index 2487c7bb00..9e1fec9578 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-webkit-linux.png index 3c3736fa2e..9f8a5c1313 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-chart-Standard-default-with-tooltip-and-label-2-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-chromium-linux.png index 136525dce4..1ab694bee2 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-firefox-linux.png index 45231e18cb..52d72bc13e 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-webkit-linux.png index a2fd7e451e..f94a1b5b49 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-1-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-chromium-linux.png index 262a0b1f43..f8a2922576 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-firefox-linux.png index 11b944e59d..7aaf0e7931 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-webkit-linux.png index 7e769f9764..c67ad664f8 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-controlled-highlight-interactions-2-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-chromium-linux.png index ce64e8c9e4..8e512c9a34 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-firefox-linux.png index 0d37038520..4637974faf 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-webkit-linux.png index e2f16b0303..049c9f8bc5 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-1-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-chromium-linux.png index dcdea875ac..87772a96c4 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-firefox-linux.png index e6b9480a1f..db2b6d1441 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-webkit-linux.png index a067ba12a0..1806fc979f 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-2-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-chromium-linux.png index 30f2a103f7..e7004d1821 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-firefox-linux.png index 8d12d3a413..1f18ecde70 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-webkit-linux.png index d20a5b222b..fe17ad4e83 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-3-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-chromium-linux.png index c20ee9a48a..cdaf3350f8 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-firefox-linux.png index 48c49e0979..f489bef225 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-webkit-linux.png index b1dcb9b07c..a55647f294 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-donut-legend-and-pattern-fill-interactions-4-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-chromium-linux.png index b82c9a481b..e99a3c548f 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-firefox-linux.png index 0a8fee5a7f..1d3ccdb534 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-webkit-linux.png index 5c398dcc84..6aca98580e 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Custom-radius-innerRadius-and-paddingAngle-2-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-chromium-linux.png index 556fc00b39..101f80afec 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-firefox-linux.png index edcb25dbd0..cf5bb40649 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-webkit-linux.png index 6e9797ed73..39588b6422 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-1-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-chromium-linux.png index 556fc00b39..101f80afec 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-firefox-linux.png index edcb25dbd0..cf5bb40649 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-webkit-linux.png index 6e9797ed73..39588b6422 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Patterns-patterns-enabled-no-tooltip-2-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-chromium-linux.png index 97dd34231a..e6fdad15bf 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-firefox-linux.png index 4a9369a4bb..2899eb655a 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-webkit-linux.png index 4012873b64..2fb7e8a6c2 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-1-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-chromium-linux.png index d40c03580e..9cd218e5bd 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-firefox-linux.png index 1d3c08ce54..2f6b1316c4 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-webkit-linux.png index 46f1013c0b..06ab92cb78 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-Standard-halfsize-with-tooltip-and-label-2-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-chromium-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-chromium-linux.png index 9aeb48c28d..40fb9aaf9b 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-chromium-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-chromium-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-firefox-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-firefox-linux.png index 169ba0eb77..3564ddda27 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-firefox-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-firefox-linux.png differ diff --git a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-webkit-linux.png b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-webkit-linux.png index 81ab368a20..aff545dceb 100644 Binary files a/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-webkit-linux.png and b/semcore/d3-chart/__tests__/donut-chart.browser-test.tsx-snapshots/-visual-Verify-semi-donut-with-labels-1-webkit-linux.png differ diff --git a/semcore/d3-chart/__tests__/index.test.tsx b/semcore/d3-chart/__tests__/index.test.tsx index 5e56c14da9..12e26dd970 100644 --- a/semcore/d3-chart/__tests__/index.test.tsx +++ b/semcore/d3-chart/__tests__/index.test.tsx @@ -23,6 +23,7 @@ import { Chart, ChartLegend, HoverLine, + Donut, // @ts-ignore } from '../src'; import { PlotA11yView } from '../src/a11y/PlotA11yView'; @@ -748,6 +749,106 @@ describe('Chart.Donut', () => { }); }); +const DONUT_THICKNESS = 12; +const DONUT_INCREASE_FACTOR = 8; + +const getPieGeometry = (pie: Element) => { + const d = pie.getAttribute('d') ?? ''; + const radii = [...new Set([...d.matchAll(/A([\d.]+),/g)].map((match) => Number(match[1])))]; + const outerRadius = Math.max(...radii); + const innerRadius = radii.length > 1 ? Math.min(...radii) : 0; + + return { outerRadius, innerRadius, thickness: outerRadius - innerRadius }; +}; + +const renderDonut = ( + donutProps: Record = {}, + [plotWidth, plotHeight]: [number, number] = [300, 300], +) => { + const { container } = render( + + + + + + + , + ); + + return queryAllByAttribute('data-ui-name', container, 'Donut.Pie').map(getPieGeometry); +}; + +describe('Donut geometry', () => { + beforeEach(cleanup); + + test.concurrent('should render a 12px thick ring by default', async () => { + const [pie] = renderDonut(); + + // outerRadius = (300 - DONUT_INCREASE_FACTOR * 2) / 2 = 142 + expect(pie.outerRadius).toBe(142); + expect(pie.innerRadius).toBe(142 - DONUT_THICKNESS); + expect(pie.thickness).toBe(DONUT_THICKNESS); + }); + + test.concurrent('should keep the 12px thickness regardless of the plot size', async () => { + const sizes: [number, number][] = [ + [300, 300], + [120, 120], + [60, 60], + [40, 40], // the smallest plot where a 12px ring still fits + ]; + + for (const size of sizes) { + const [pie] = renderDonut({}, size); + + expect(pie.thickness, `plot ${size[0]}x${size[1]}`).toBe(DONUT_THICKNESS); + } + }); + + test.concurrent('should keep the 12px thickness for a semi donut', async () => { + const [pie] = renderDonut({ halfsize: true }, [300, 150]); + + expect(pie.thickness).toBe(DONUT_THICKNESS); + }); + + test.concurrent('should let an explicit innerRadius override the default', async () => { + const [pie] = renderDonut({ innerRadius: 50 }); + + expect(pie.innerRadius).toBe(50); + expect(pie.outerRadius).toBe(142); + }); + + test.concurrent('should render a full pie when innerRadius is explicitly 0', async () => { + const [pie] = renderDonut({ innerRadius: 0 }); + + expect(pie.innerRadius).toBe(0); + expect(pie.thickness).toBe(142); + }); + + test.concurrent('should clamp the inner radius to 0 instead of going negative', async () => { + const [pie] = renderDonut({}, [30, 30]); + + expect(pie.outerRadius).toBe(7); + expect(pie.innerRadius).toBe(0); + }); + + test.concurrent('should expand an active pie outwards keeping its inner edge', async () => { + const { container } = render( + + + + + + , + ); + const [activePie, idlePie] = queryAllByAttribute('data-ui-name', container, 'Donut.Pie').map(getPieGeometry); + + expect(activePie.innerRadius).toBe(idlePie.innerRadius); + expect(activePie.outerRadius).toBe(idlePie.outerRadius + DONUT_INCREASE_FACTOR); + expect(activePie.thickness).toBe(DONUT_THICKNESS + DONUT_INCREASE_FACTOR); + }); +}); + describe('Chart.Line', () => { beforeEach(cleanup); diff --git a/semcore/d3-chart/src/Donut.jsx b/semcore/d3-chart/src/Donut.jsx index 99a5b5bd5d..2c0f406bfd 100644 --- a/semcore/d3-chart/src/Donut.jsx +++ b/semcore/d3-chart/src/Donut.jsx @@ -84,6 +84,7 @@ function transitionRadiusPie({ } const increaseFactor = 8; +const donutThickness = 12; function getOuterRadius({ size, halfsize }) { const [width, height] = size; @@ -97,19 +98,19 @@ class DonutRoot extends Component { static enhance = [uniqueIDEnhancement()]; static defaultProps = ({ - innerRadius = 0, + innerRadius: innerRadiusProp, paddingAngle = 0, outerRadius, halfsize = false, $rootProps: { size }, }) => { - const d3Arc = arc() - .outerRadius(outerRadius || getOuterRadius({ size, halfsize, outerRadius })) - .innerRadius(innerRadius) - .padAngle(paddingAngle); + const radius = outerRadius || getOuterRadius({ size, halfsize }); + const innerRadius = innerRadiusProp ?? Math.max(radius - donutThickness, 0); + + const d3Arc = arc().outerRadius(radius).innerRadius(innerRadius).padAngle(paddingAngle); const d3ArcOut = arc() - .outerRadius((outerRadius || getOuterRadius({ size, halfsize })) + increaseFactor) + .outerRadius(radius + increaseFactor) .innerRadius(innerRadius) .padAngle(paddingAngle); @@ -180,8 +181,9 @@ class DonutRoot extends Component { }; animationActivePie = ({ data, active, selector, element }) => { - const { duration, innerRadius, d3Arc, paddingAngle } = this.asProps; + const { duration, d3Arc, paddingAngle } = this.asProps; const outerRadius = d3Arc.outerRadius()(); + const innerRadius = d3Arc.innerRadius()(); const outerRadiusStartEnd = active ? [+element.dataset['currentRadius'] || outerRadius, outerRadius + increaseFactor] : [+element.dataset['currentRadius'] || outerRadius, outerRadius]; diff --git a/semcore/d3-chart/src/component/Chart/DonutChart.tsx b/semcore/d3-chart/src/component/Chart/DonutChart.tsx index b4772608cc..b2f079c966 100644 --- a/semcore/d3-chart/src/component/Chart/DonutChart.tsx +++ b/semcore/d3-chart/src/component/Chart/DonutChart.tsx @@ -24,7 +24,6 @@ class DonutChartComponent extends AbstractChart< static defaultProps = { direction: 'row-reverse', alignItems: 'flex-start', - innerRadius: 100, marginX: 0, marginY: 0, locale: 'en', diff --git a/semcore/d3-chart/src/component/Chart/DonutChart.type.ts b/semcore/d3-chart/src/component/Chart/DonutChart.type.ts index d8ae2d48d6..d7ea7055ce 100644 --- a/semcore/d3-chart/src/component/Chart/DonutChart.type.ts +++ b/semcore/d3-chart/src/component/Chart/DonutChart.type.ts @@ -32,7 +32,6 @@ export type DonutChartProps = Intergalactic.InternalTypings.EfficientOmit< export type DonutChartDefaultProps = { direction: 'row-reverse'; alignItems: 'flex-start'; - innerRadius: 100; marginX: 0; marginY: 0; locale: 'en'; diff --git a/semcore/d3-chart/src/types/Donut.d.ts b/semcore/d3-chart/src/types/Donut.d.ts index e12d1ce3bc..8ed5663bb1 100644 --- a/semcore/d3-chart/src/types/Donut.d.ts +++ b/semcore/d3-chart/src/types/Donut.d.ts @@ -10,7 +10,7 @@ export interface IDonutProps extends DonutProps, UnknownProperties {} export type DonutProps = Context & { /** Inner radius * @default 0 - * */ + */ innerRadius?: number; /** Outer radius * @default calculated by the formula from width, height diff --git a/stories/components/d3-chart/docs/examples/donut-chart/donut-controlled-highlight.tsx b/stories/components/d3-chart/docs/examples/donut-chart/donut-controlled-highlight.tsx index 5dd17e603e..1e6b92c04b 100644 --- a/stories/components/d3-chart/docs/examples/donut-chart/donut-controlled-highlight.tsx +++ b/stories/components/d3-chart/docs/examples/donut-chart/donut-controlled-highlight.tsx @@ -23,7 +23,7 @@ const Demo = () => { return ( - + {Object.keys(data).map((name, index) => ( { return ( - + diff --git a/stories/components/d3-chart/docs/examples/donut-chart/edge-cases.tsx b/stories/components/d3-chart/docs/examples/donut-chart/edge-cases.tsx index 348bc38b5e..cb282a06f3 100644 --- a/stories/components/d3-chart/docs/examples/donut-chart/edge-cases.tsx +++ b/stories/components/d3-chart/docs/examples/donut-chart/edge-cases.tsx @@ -6,7 +6,7 @@ import DonutMockData from '../../../__mocks__/donut'; const Demo = () => { return ( - + diff --git a/stories/components/d3-chart/docs/examples/donut-chart/legend-and-pattern-fill.tsx b/stories/components/d3-chart/docs/examples/donut-chart/legend-and-pattern-fill.tsx index 6a4ea5cf67..af7e6a0aae 100644 --- a/stories/components/d3-chart/docs/examples/donut-chart/legend-and-pattern-fill.tsx +++ b/stories/components/d3-chart/docs/examples/donut-chart/legend-and-pattern-fill.tsx @@ -45,7 +45,7 @@ const Demo = () => { return ( - + {legendItems.filter((item) => item.checked).length === 0 && } {legendItems.map((item, index) => { return ( diff --git a/stories/components/d3-chart/docs/examples/donut-chart/semi-donut.tsx b/stories/components/d3-chart/docs/examples/donut-chart/semi-donut.tsx index 04c133a034..a7baab3048 100644 --- a/stories/components/d3-chart/docs/examples/donut-chart/semi-donut.tsx +++ b/stories/components/d3-chart/docs/examples/donut-chart/semi-donut.tsx @@ -8,7 +8,7 @@ import DonutMockData from '../../../__mocks__/donut'; const Demo = () => { return ( - + diff --git a/stories/components/d3-chart/tests/examples/donut-chart/donut-props.tsx b/stories/components/d3-chart/tests/examples/donut-chart/donut-props.tsx index 0b38e36dd3..d4d9962c44 100644 --- a/stories/components/d3-chart/tests/examples/donut-chart/donut-props.tsx +++ b/stories/components/d3-chart/tests/examples/donut-chart/donut-props.tsx @@ -26,7 +26,7 @@ const Demo = (props: DonutPropsWithLabel) => { return (