Skip to content
Merged
Show file tree
Hide file tree
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions semcore/d3-chart/__tests__/chart-legend.browser-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ export const locators = {
* modifier name rather than a `transparent` attribute.
*/
dimmed: (page: Page) => page.locator('[class*="_transparent_"]'),
metric: (page: Page, index?: number) => {
const base = page.locator('[data-ui-name="Metric"]');
return typeof index === 'number' ? base.nth(index) : base;
},
};

const FLEX_EXAMPLE = 'stories/components/d3-chart/tests/examples/chart-legend/customizable_legend.tsx';
const TABLE_EXAMPLE = 'stories/components/d3-chart/tests/examples/chart-legend/legend-table-data.tsx';
const METRICS_EXAMPLE = 'stories/components/d3-chart/tests/examples/chart-legend/legend-with-metrics.tsx';

/**
* Pairwise set for LegendFlex.
Expand Down Expand Up @@ -119,6 +124,35 @@ const tablePairwiseCases = [
},
];

/**
* Pairwise set for LegendTable with metrics.
*
* Factors: diffIcon (none|up|down|mixed), diffUse (good|bad|neutral|mixed),
* metricLink (none|single|all), metricsPerItem (1|2), size (m|l).
* The two 4-value factors put the lower bound at 16 cases.
*/
const metricsPairwiseCases = [
['none', 'good', 'none', 1, 'm'],
['none', 'bad', 'single', 2, 'l'],
['none', 'neutral', 'all', 1, 'm'],
['none', 'mixed', 'none', 2, 'l'],
['up', 'good', 'single', 2, 'm'],
['up', 'bad', 'all', 1, 'l'],
['up', 'neutral', 'none', 2, 'm'],
['up', 'mixed', 'single', 1, 'l'],
['down', 'good', 'all', 1, 'l'],
['down', 'bad', 'none', 2, 'm'],
['down', 'neutral', 'single', 1, 'l'],
['down', 'mixed', 'all', 2, 'm'],
['mixed', 'good', 'none', 2, 'l'],
['mixed', 'bad', 'single', 1, 'm'],
['mixed', 'neutral', 'all', 2, 'l'],
['mixed', 'mixed', 'none', 1, 'm'],
].map(([diffIcon, diffUse, metricLink, metricsPerItem, size], i) => ({
name: `#${i + 1} icon-${diffIcon}, ${diffUse}, link-${metricLink}, ${metricsPerItem}-per-item, ${size}`,
props: { diffIcon, diffUse, metricLink, metricsPerItem, legendProps: { size } },
}));

/* =====================================================
@visual
Visual states, hover and focus styles, paddings, margins, and snapshots.
Expand Down Expand Up @@ -167,6 +201,65 @@ test.describe(`${TAG.VISUAL}`, () => {
await expect(page).toHaveScreenshot();
});
});

test.describe('Legend with metrics', () => {
metricsPairwiseCases.forEach((c) => {
test(`Verify pairwise ${c.name}`, {
tag: [TAG.PRIORITY_HIGH, '@d3-chart', '@chart-legend', '@line-chart', '@link'],
}, async ({ page }) => {
await loadPage(page, METRICS_EXAMPLE, 'en', c.props);

await locators.legendTable(page).waitFor({ state: 'visible' });
await expect(page).toHaveScreenshot();
});
});

test('Verify boundary empty diffValue', {
tag: [TAG.PRIORITY_MEDIUM, '@d3-chart', '@chart-legend', '@line-chart'],
}, async ({ page }) => {
await loadPage(page, METRICS_EXAMPLE, 'en', { diffValue: '' });

await locators.legendTable(page).waitFor({ state: 'visible' });
await expect(page).toHaveScreenshot();
});

test('Verify boundary long diffValue', {
tag: [TAG.PRIORITY_MEDIUM, '@d3-chart', '@chart-legend', '@line-chart'],
}, async ({ page }) => {
await loadPage(page, METRICS_EXAMPLE, 'en', { diffValue: '1,234,567,890.12', metricsPerItem: 2 });

await locators.legendTable(page).waitFor({ state: 'visible' });
await expect(page).toHaveScreenshot();
});

test('Verify boundary patterns', {
tag: [TAG.PRIORITY_MEDIUM, '@d3-chart', '@chart-legend', '@line-chart'],
}, async ({ page }) => {
await loadPage(page, METRICS_EXAMPLE, 'en', { patterns: true });

await locators.legendTable(page).waitFor({ state: 'visible' });
await expect(page).toHaveScreenshot();
});

test('Verify a hovered metric row keeps the other rows dimmed', {
tag: [TAG.PRIORITY_HIGH, TAG.MOUSE, '@d3-chart', '@chart-legend', '@line-chart', '@link'],
}, async ({ page }) => {
await loadPage(page, METRICS_EXAMPLE, 'en', { metricLink: 'all' });

const items = locators.tableItem(page);
await locators.metric(page, 0).hover();

await test.step('Verify only the hovered row stays opaque', async () => {
await expect(items.nth(0)).not.toHaveClass(/_transparent_/);
const total = await items.count();
for (let i = 1; i < total; i++) {
await expect(items.nth(i)).toHaveClass(/_transparent_/);
}
});

await expect(page).toHaveScreenshot();
});
});
});

/* =====================================================
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ test.describe(`${TAG.FUNCTIONAL}`, () => {
await test.step('Verify the placeholder uses the null palette color', async () => {
await expect(locators.barItem(page, 0)).toHaveAttribute(
'color',
'--intergalactic-chart-palette-order-null',
'--intergalactic-chart-data-null',
);
});

Expand Down
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
2 changes: 1 addition & 1 deletion semcore/d3-chart/src/component/Chart/CigaretteChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class CigaretteChartComponent extends AbstractChart<
hide={false}
duration={duration}
r={r}
color='--intergalactic-chart-palette-order-null'
color='--intergalactic-chart-data-null'
patterns={patterns}
direction={invertAxis ? 'horizontal' : 'vertical'}
hovered={false}
Expand Down
2 changes: 1 addition & 1 deletion semcore/d3-chart/src/style/area.shadow.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ SAreaLine {

SNull {
fill: transparent;
stroke: var(--intergalactic-chart-palette-order-null, oklch(0.9 0.009 234));
stroke: var(--intergalactic-chart-data-null, oklch(0.9 0.009 234));
stroke-dasharray: 4;
}

Expand Down
2 changes: 1 addition & 1 deletion semcore/d3-chart/src/style/donut.shadow.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SPie[transparent] {
}

SEmptyData {
fill: var(--intergalactic-chart-palette-order-null, oklch(0.9 0.009 234));
fill: var(--intergalactic-chart-data-null, oklch(0.9 0.009 234));
}

SEmptyData[color] {
Expand Down
2 changes: 1 addition & 1 deletion semcore/d3-chart/src/style/line.shadow.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SLine[transparent] {

SNull {
fill: transparent;
stroke: var(--intergalactic-chart-palette-order-null, oklch(0.9 0.009 234));
stroke: var(--intergalactic-chart-data-null, oklch(0.9 0.009 234));
stroke-dasharray: 4;
}

Expand Down
2 changes: 1 addition & 1 deletion semcore/mini-chart/src/components/trend/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TrendBarRoot extends Trend<
{...extractedAriaProps}
>
{this.data.map((barItem, index) => {
let color = resolveColor('chart-palette-order-other-data');
let color = resolveColor('chart-data-other-value');

if (barItem.color) {
color = resolveColor(barItem.color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Demo = () => {
<Line
x='category'
y='bar'
color='chart-palette-order-total-amount'
color='chart-data-total-amount'
style={{ strokeWidth: 3, strokeDasharray: '6 6' }}
>
<Line.Dots display />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const rows = [
{ id: 'item-3', label: 'Label', color: 'chart-palette-order-3', value: 27500 },
{ id: 'item-4', label: 'Label', color: 'chart-palette-order-4', value: 11100 },
{ id: 'item-5', label: 'Label', color: 'chart-palette-order-5', value: 2400 },
{ id: 'other-data', label: 'Other data', color: 'chart-palette-order-other-data', value: 22800 },
{ id: 'other-data', label: 'Other data', color: 'chart-data-other-value', value: 22800 },
];

const total = rows.reduce((sum, row) => sum + row.value, 0);
Expand Down
38 changes: 19 additions & 19 deletions tools/theme/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,18 @@ export const theme: Theme = {
value: colors.red['300'].value,
description: 'Color for the "Lost" data on the chart.',
},
chart_data_null: {
value: colors.gray['100'].value,
description: 'Use it to show null value on the chart.',
},
chart_data_other_value: {
value: colors.gray['200'].value,
description: 'Use it to indicate voids, missing or some other data on the chart.',
},
chart_data_total_amount: {
value: colors.gray['400'].value,
description: 'Use it to show total value on the chart.',
},
chart_data_intent_commercial: {
value: colors.violet['300'].value,
description: 'Color for the commercial data intent on the chart.',
Expand Down Expand Up @@ -868,18 +880,6 @@ export const theme: Theme = {
value: colors.yellow['400'].value,
description: '24 color in the default list of colors for charts.',
},
chart_palette_order_null: {
value: colors.gray['100'].value,
description: 'Use it to show null value on the chart.',
},
chart_palette_order_other_data: {
value: colors.gray['200'].value,
description: 'Use it to indicate voids, missing or some other data on the chart.',
},
chart_palette_order_total_amount: {
value: colors.gray['400'].value,
description: 'Use it to show total value on the chart.',
},
chart_x_axis_accent_data_start_tracking: {
value: success.opaqueAt(L_BG_LIGHT),
description: 'Background color for the "Start tracking" date on the X-axis of the chart grid.',
Expand Down Expand Up @@ -3386,6 +3386,13 @@ type SemanticColors = {
critical: Value;
lost: Value;
new: Value;
total: {
amount: Value;
};
other: {
value: Value;
};
null: Value;
intent: {
informational: Value;
navigational: Value;
Expand Down Expand Up @@ -3420,13 +3427,6 @@ type SemanticColors = {
22: Value;
23: Value;
24: Value;
total: {
amount: Value;
};
other: {
data: Value;
};
null: Value;
};
};
grid: {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/data-display/area-chart/area-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ For detailed tooltip information, see [Chart principles](/data-display/d3-chart/

### One value

Display dots by default for charts with a single data point. The line is dashed and colored with `--chart-palette-order-other-data`.
Display dots by default for charts with a single data point. The line is dashed and colored with `--chart-data-other-value`.

![](static/one-dot-area-chart.png)

Expand Down
12 changes: 6 additions & 6 deletions website/docs/data-display/color-palette/color-palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ const App = function (props) {

#### Total amount

Use `--intergalactic-chart-palette-order-total-amount` token to indicate total values.
Use `--intergalactic-chart-data-total-amount` token to indicate total values.

::: react-view

<script lang="tsx">
import React from 'react';
import Color from '@components/Color';

const colors = ['--intergalactic-chart-palette-order-total-amount'] // totalAmount
const colors = ['--intergalactic-chart-data-total-amount'] // totalAmount

const App = function (props) {
return (
Expand All @@ -186,15 +186,15 @@ const App = function (props) {

#### Other data

Use `--intergalactic-chart-palette-order-other-data` token to indicate voids, missing or some other data.
Use `--intergalactic-chart-data-other-value` token to indicate voids, missing or some other data.

::: react-view

<script lang="tsx">
import React from 'react';
import Color from '@components/Color';

const colors = ['--intergalactic-chart-palette-order-other-data'] // otherData
const colors = ['--intergalactic-chart-data-other-value'] // otherData

const App = function (props) {
return (
Expand All @@ -217,15 +217,15 @@ const App = function (props) {

#### Null and n/a data

Use `--intergalactic-chart-palette-order-null` token to indicate null or not available data when applicable (for example, in Donut chart).
Use `--intergalactic-chart-data-null` token to indicate null or not available data when applicable (for example, in Donut chart).

::: react-view

<script lang="tsx">
import React from 'react';
import Color from '@components/Color';

const colors = ['--intergalactic-chart-palette-order-null'] // nullData
const colors = ['--intergalactic-chart-data-null'] // nullData

const App = function (props) {
return (
Expand Down
2 changes: 1 addition & 1 deletion website/docs/data-display/line-chart/line-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ For detailed tooltip information, see [Chart principles](/data-display/d3-chart/

### One value

Display dots by default for charts with a single data point. The line is dashed and colored with `--chart-palette-order-other-data`.
Display dots by default for charts with a single data point. The line is dashed and colored with `--chart-data-other-value`.

![](static/one-dot-line-chart.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ For detailed tooltip information, see [Chart principles](/data-display/d3-chart/

### One value

Display dots by default for charts with a single data point. The line is dashed and colored with `--chart-palette-order-other-data`.
Display dots by default for charts with a single data point. The line is dashed and colored with `--chart-data-other-value`.

![one-dot](static/one-dot-stacked-area-chart.png)

Expand Down
4 changes: 2 additions & 2 deletions website/docs/data-display/venn-chart/venn-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ Zero counts as data. 0 ≠ n/a.

![](static/venn-null.png)

If all data set values are zero, display a circle in `--chart-palette-order-null` color.
If all data set values are zero, display a circle in `--chart-data-null` color.

![](static/venn-null-2.png)

### No data

Exclude unavailable data from the chart, marking it as n/a in the legend. If all dataset values are unknown, show a circle in `--chart-palette-order-null` color.
Exclude unavailable data from the chart, marking it as n/a in the legend. If all dataset values are unknown, show a circle in `--chart-data-null` color.

![](static/venn-na.png)

Expand Down
Loading
Loading