Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bullet): new design style and implementation #2156

Merged
merged 91 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
6c9856e
WIP
markov00 May 11, 2023
31d1e37
WIP
markov00 May 11, 2023
413c5da
Add examples
markov00 May 11, 2023
ff43ac7
small refactoring
markov00 May 12, 2023
d62885d
wip
markov00 May 12, 2023
0c65470
WIP
markov00 May 15, 2023
fc86ed0
WIP
markov00 May 15, 2023
f874a4c
fix: remove erroneous render code
nickofthyme Aug 4, 2023
34ac5ff
feat: improve end/top label positioning
nickofthyme Aug 4, 2023
7b829fa
feat(bullet): add global title and description
nickofthyme Aug 7, 2023
2c3cf1d
feat(bullet): angular implementation with fixes
nickofthyme Aug 31, 2023
21f591a
rename story files
nickofthyme Aug 31, 2023
f414884
minor tweaks
nickofthyme Aug 31, 2023
b9dae6f
refactor: lift panel scales to top selector
nickofthyme Sep 22, 2023
d61cde6
feat: active value sync with tooltip
nickofthyme Sep 25, 2023
216b819
Merge branch 'main' into bullet-redesign
nickofthyme Sep 25, 2023
e1d5e94
chore: update active panel value logic
nickofthyme Sep 27, 2023
8b30007
Merge branch 'main' into bullet-redesign
nickofthyme Sep 27, 2023
4e4d3af
fix: add locale to bullet chart
nickofthyme Sep 27, 2023
f956bc4
feat: add target tick to metric fallback
nickofthyme Sep 28, 2023
1b13e86
chore: improve target styles
nickofthyme Sep 28, 2023
ef441ac
feat: discretize color band lookup
nickofthyme Sep 28, 2023
92c0809
chore: improve api
nickofthyme Sep 28, 2023
4aed2d4
fix: tick zIndex and debug renders
nickofthyme Sep 29, 2023
0196476
chore: improve active value logic
nickofthyme Sep 30, 2023
968f8e3
chore: update chart api changes
nickofthyme Sep 30, 2023
3e58ad3
fix: prettier formatting
nickofthyme Sep 30, 2023
4956d4b
fix: active value logic constraints
nickofthyme Oct 1, 2023
b182119
chore: add default tick/value formatting
nickofthyme Oct 2, 2023
679af77
test: vrt diffs test
nickofthyme Oct 2, 2023
4ae4b01
fix: target alignment on vertical metric
nickofthyme Oct 2, 2023
b1c6a43
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Oct 2, 2023
23d315e
chore: deprecate Goal chart type
nickofthyme Oct 4, 2023
0169cc8
refactor: merge angular size into subtypes
nickofthyme Oct 4, 2023
8700054
chore: add BulletGraphStyle export and update api
nickofthyme Oct 4, 2023
e3be8cb
chore: rm unused files
nickofthyme Oct 4, 2023
0cc4e63
Merge remote-tracking branch 'origin/bullet-redesign' into bullet-red…
nickofthyme Oct 4, 2023
0f55d12
Merge branch 'main' into bullet-redesign
nickofthyme Oct 17, 2023
09bb493
chore: configure tooltip value labels from spec
nickofthyme Oct 17, 2023
8458ff4
chore: fix errors with metric and subtype changes
nickofthyme Oct 17, 2023
c187ea9
fix: logical errors with measureText util
nickofthyme Oct 17, 2023
0a3db83
chore: update api changes
nickofthyme Oct 17, 2023
04c46c5
chore: remove package font family assignment
nickofthyme Oct 17, 2023
30de52f
chore: remove default letterSpacing
nickofthyme Oct 17, 2023
3b989ad
chore: restore debounce timer
nickofthyme Oct 17, 2023
189d244
chore: add back font-family
nickofthyme Oct 17, 2023
9217803
chore: minor tweaks and fixes
nickofthyme Oct 18, 2023
0131671
fix: add border on angular variants
nickofthyme Oct 18, 2023
cdea1ac
fix: render value bar from 0 for angular subtype
nickofthyme Oct 18, 2023
77ba793
fix: render value bar from 0 for horizontal subtype
nickofthyme Oct 18, 2023
9cf2668
fix: render value bar from 0 for vertical subtype
nickofthyme Oct 18, 2023
19358ac
fix: overflow issue with min domain > 0
nickofthyme Oct 18, 2023
0b95b0f
chore: reset vrt screenshots
nickofthyme Oct 18, 2023
248756a
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Oct 18, 2023
ddf7310
test: skip bullet tests in all.test and add manual tests
nickofthyme Oct 18, 2023
b64f4e4
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Oct 18, 2023
9027138
Merge branch 'main' into bullet-redesign
nickofthyme Oct 26, 2023
acbdea9
chore: revert tick render order over value bar
nickofthyme Oct 26, 2023
0504bb4
Merge remote-tracking branch 'origin/bullet-redesign' into bullet-red…
nickofthyme Oct 26, 2023
eb7b8ef
refactor: domain to be generic unordered
nickofthyme Oct 29, 2023
2ade1e4
refactor: color scale logic
nickofthyme Nov 5, 2023
cb35afe
feat: add domain nicing and desired ticks options
nickofthyme Nov 5, 2023
3c096ea
feat: allow custom tick placements
nickofthyme Nov 5, 2023
242e4e8
fix: prevent 0 tick count from user
nickofthyme Nov 5, 2023
e97ba5d
fix: type errors in legacy domain
nickofthyme Nov 6, 2023
af89acf
fix: tooltip color selection
nickofthyme Nov 6, 2023
0481f8e
chore: remove bullet bgColor in favor of theme bgColor
nickofthyme Nov 6, 2023
f32a7bc
chore: add zero baseline tick baseline
nickofthyme Nov 6, 2023
98e260f
chore: add fallback color for values outside of color domain
nickofthyme Nov 6, 2023
96ff84e
feat: add logic to match metric to bullet
nickofthyme Nov 6, 2023
2507dd7
Merge branch 'main' into bullet-redesign
nickofthyme Nov 6, 2023
d8dec1f
fix: last tick placement with negative polarity domains
nickofthyme Nov 6, 2023
d48615b
fix: zero tick showing on end of domain
nickofthyme Nov 6, 2023
759a088
chore: use valueLabels in metric titles
nickofthyme Nov 7, 2023
f10ca1b
test: add vrt, fix optionsKnob e2e mock
nickofthyme Nov 7, 2023
a0f3e43
Merge branch 'main' into bullet-redesign
nickofthyme Nov 7, 2023
4804d09
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Nov 7, 2023
6830e0c
chore: remove stale vrt, revet goal chart changes
nickofthyme Nov 7, 2023
14ab450
test: color band story and add vrt
nickofthyme Nov 8, 2023
f342969
fix: vrt error
nickofthyme Nov 8, 2023
fae1abe
chore: update bullet api exports
nickofthyme Nov 8, 2023
784c7b7
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Nov 8, 2023
d4bea27
Merge branch 'main' into bullet-redesign
nickofthyme Nov 8, 2023
1a237a7
chore: add resize parameter to bullet stories
nickofthyme Nov 8, 2023
65cf0ef
test: add tests for bullet as metric
nickofthyme Nov 8, 2023
b65657a
Merge remote-tracking branch 'origin/bullet-redesign' into bullet-red…
nickofthyme Nov 8, 2023
6f3f509
test: remove only [update-vrt]
nickofthyme Nov 8, 2023
b285521
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Nov 8, 2023
0d1328a
fix: object mock type bad arguments
nickofthyme Nov 8, 2023
e345ebf
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Nov 8, 2023
6bbfcd2
Merge branch 'main' into bullet-redesign
nickofthyme Nov 8, 2023
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
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module.exports = {
'@typescript-eslint/no-unsafe-call': 0, // seems to have issues with default import types
'@typescript-eslint/unbound-method': 1,
'@typescript-eslint/no-redeclare': 0, // we use to declare enum type and object with the same name
'@typescript-eslint/no-shadow': 0, // we use shadow mostly within the canvas renderer function when we need a new context
'@typescript-eslint/no-shadow': 0,
'@typescript-eslint/quotes': 0,
'@typescript-eslint/no-unsafe-argument': 1,
'unicorn/consistent-function-scoping': 1,
Expand All @@ -89,7 +89,7 @@ module.exports = {
'unicorn/number-literal-case': 0, // use prettier lower case preference
'global-require': 1,
'import/no-dynamic-require': 1,
'no-shadow': 1,
'no-shadow': ['warn', { allow: ['ctx'] }], // allow replacing ctx in canvas renderer functions, too tedious to rename at each level
'react/no-array-index-key': 1,
'react/prefer-stateless-function': 1,
'react/require-default-props': 0,
Expand Down
2 changes: 1 addition & 1 deletion e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface StoryGroupInfo {
/**
* Groups to skip in all vrt.
*/
const groupsToSkip: Set<string> = new Set(['Components/Tooltip']);
const groupsToSkip: Set<string> = new Set(['Components/Tooltip', 'Bullet Graph']);

/**
* Stories to skip in all vrt based by group.
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.
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.
141 changes: 141 additions & 0 deletions e2e/tests/bullet_stories.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { test } from '@playwright/test';

import { pwEach } from '../helpers';
import { common } from '../page_objects/common';

export const BulletGraphSubtype = ['vertical', 'horizontal', 'circle', 'half-circle', 'two-thirds-circle'];
const testCases: [string, { start: number; end: number; value: number; target: number }][] = [
['positive values', { start: 4, end: 167, value: 50, target: 100 }],
['positive values - reversed', { start: 167, end: 4, value: 50, target: 100 }],
['positive/negative values', { start: -57, end: 97, value: -12, target: 50 }],
['positive/negative values - reversed', { start: 97, end: -57, value: -12, target: 50 }],
['negative values', { start: -194, end: -5, value: -50, target: -150 }],
['negative values - reversed', { start: -5, end: -194, value: -50, target: -150 }],
];

test.describe('Bullet stories', () => {
test('renders single bullet', async ({ page }) => {
await common.expectChartAtUrlToMatchScreenshot(page)('http://localhost:9001/?path=/story/bullet-graph--single');
});

test('renders angular bullet', async ({ page }) => {
await page.setViewportSize({ width: 785, height: 800 });
await common.expectChartAtUrlToMatchScreenshot(page)('http://localhost:9001/?path=/story/bullet-graph--angular');
});

test('renders single row bullet', async ({ page }) => {
await page.setViewportSize({ width: 850, height: 800 });
await common.expectChartAtUrlToMatchScreenshot(page)('http://localhost:9001/?path=/story/bullet-graph--single-row');
});

test('renders single column bullet', async ({ page }) => {
await common.expectChartAtUrlToMatchScreenshot(page)(
'http://localhost:9001/?path=/story/bullet-graph--single-column',
);
});

test('renders grid bullet', async ({ page }) => {
await page.setViewportSize({ width: 785, height: 1000 });
await common.expectChartAtUrlToMatchScreenshot(page)('http://localhost:9001/?path=/story/bullet-graph--grid');
});

pwEach.describe(BulletGraphSubtype)(
(subtype) => `subtype - ${subtype}`,
(subtype) => {
test('should render in dark theme', async ({ page }) => {
await page.setViewportSize({ width: 785, height: 800 });
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/bullet-graph--single&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:dark&knob-Config 1 - Color_Color Bands=RGBA(70, 130, 96, 1)&knob-Config 2 - Steps_Color Bands=5&knob-Config 3 - json_Color Bands={"classes":[0,20,40,100],"colors":["&knob-debug=&knob-title_General=Error rate title&knob-subtitle_General=Here is the subtitle&knob-value_General=56&knob-target_General=75&knob-start_General=0&knob-end_General=100&knob-format (numeraljs)_General=0.[0]&knob-subtype_General=${subtype}&knob-niceDomain_Ticks=&knob-tick strategy_Ticks=auto&knob-ticks(approx. count)_Ticks=5&knob-ticks(placements)_Ticks[0]=-200&knob-ticks(placements)_Ticks[1]=-100&knob-ticks(placements)_Ticks[2]=0&knob-ticks(placements)_Ticks[3]=5&knob-ticks(placements)_Ticks[4]=10&knob-ticks(placements)_Ticks[5]=15&knob-ticks(placements)_Ticks[6]=20&knob-ticks(placements)_Ticks[7]=25&knob-ticks(placements)_Ticks[8]=50&knob-ticks(placements)_Ticks[9]=100&knob-ticks(placements)_Ticks[10]=200`,
);
});

test.describe('Ticks', () => {
test('should render with auto ticks', async ({ page }) => {
await page.setViewportSize({ width: 785, height: 800 });
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/bullet-graph--single&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-end_General=100&knob-format (numeraljs)_General=0.[0]&knob-niceDomain_Ticks=true&knob-start_General=0&knob-subtype_General=${subtype}&knob-target_General=81&knob-tick strategy_Ticks=auto&knob-ticks(approx. count)_Ticks=10&knob-ticks(placements)_Ticks[0]=-200&knob-ticks(placements)_Ticks[1]=-100&knob-ticks(placements)_Ticks[2]=0&knob-ticks(placements)_Ticks[3]=5&knob-ticks(placements)_Ticks[4]=10&knob-ticks(placements)_Ticks[5]=15&knob-ticks(placements)_Ticks[6]=20&knob-ticks(placements)_Ticks[7]=25&knob-ticks(placements)_Ticks[8]=50&knob-ticks(placements)_Ticks[9]=100&knob-ticks(placements)_Ticks[10]=200&knob-title_General=Error rate&knob-value_General=57&knob-debug=&knob-subtitle_General=`,
);
});

test('should render with explicit tick count', async ({ page }) => {
await page.setViewportSize({ width: 785, height: 800 });
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9002/?path=/story/bullet-graph--single&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-end_General=100&knob-format%20(numeraljs)_General=0.[0]&knob-niceDomain_Ticks=true&knob-start_General=0&knob-subtype_General=${subtype}&knob-target_General=81&knob-tick%20strategy_Ticks[0]=count&knob-tick%20strategy_Ticks[1]=auto&knob-ticks(approx.%20count)_Ticks=14&knob-ticks(placements)_Ticks[0]=-200&knob-ticks(placements)_Ticks[1]=-100&knob-ticks(placements)_Ticks[2]=0&knob-ticks(placements)_Ticks[3]=5&knob-ticks(placements)_Ticks[4]=10&knob-ticks(placements)_Ticks[5]=15&knob-ticks(placements)_Ticks[6]=20&knob-ticks(placements)_Ticks[7]=25&knob-ticks(placements)_Ticks[8]=50&knob-ticks(placements)_Ticks[9]=100&knob-ticks(placements)_Ticks[10]=200&knob-title_General=Error%20rate&knob-value_General=57&knob-debug=&knob-subtitle_General=`,
);
});

test('should render with explicit tick placements', async ({ page }) => {
await page.setViewportSize({ width: 785, height: 800 });
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/bullet-graph--single&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-end_General=100&knob-format (numeraljs)_General=0.[0]&knob-niceDomain_Ticks=true&knob-start_General=0&knob-subtype_General=${subtype}&knob-target_General=81&knob-tick strategy_Ticks=placements&knob-ticks(approx. count)_Ticks=16&knob-ticks(placements)_Ticks[0]=-200&knob-ticks(placements)_Ticks[1]=-100&knob-ticks(placements)_Ticks[2]=0&knob-ticks(placements)_Ticks[3]=5&knob-ticks(placements)_Ticks[4]=10&knob-ticks(placements)_Ticks[5]=15&knob-ticks(placements)_Ticks[6]=20&knob-ticks(placements)_Ticks[7]=25&knob-ticks(placements)_Ticks[8]=50&knob-ticks(placements)_Ticks[9]=100&knob-ticks(placements)_Ticks[10]=200&knob-title_General=Error rate&knob-value_General=57&knob-debug=&knob-subtitle_General=`,
);
});
});

// Each color config type
pwEach.test([1, 2, 3, 4])(
(v) => `should render colors with config - ${v}`,
async (page, configIndex) => {
await page.setViewportSize({ width: 785, height: 800 });
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/bullet-graph--color-bands&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-color config_Color Bands=${configIndex}&knob-Config 1 - Color_Color Bands=RGBA(70, 130, 96, 1)&knob-Config 2 - Palette_Color Bands=0&knob-Config 2 - Steps_Color Bands=5&knob-Config 2 - Reverse_Color Bands=&knob-Config 3 - json_Color Bands={"classes":5,"colors":["pink","yellow","blue"]}&knob-Config 4 - json_Color Bands=[{"color":"red","gte":0,"lt":20},{"color":"green","gte":20,"lte":40},{"color":"blue","gt":40,"lte":{"type":"percentage","value":100}}]&knob-start_Domain=0&knob-end_Domain=100&knob-value_Domain=56&knob-target_Domain=75&knob-niceDomain_Ticks=&knob-tick strategy_Ticks=auto&knob-ticks(approx. count)_Ticks=5&knob-ticks(placements)_Ticks[0]=-200&knob-ticks(placements)_Ticks[1]=-100&knob-ticks(placements)_Ticks[2]=0&knob-ticks(placements)_Ticks[3]=5&knob-ticks(placements)_Ticks[4]=10&knob-ticks(placements)_Ticks[5]=15&knob-ticks(placements)_Ticks[6]=20&knob-ticks(placements)_Ticks[7]=25&knob-ticks(placements)_Ticks[8]=50&knob-ticks(placements)_Ticks[9]=100&knob-ticks(placements)_Ticks[10]=200&knob-debug=&knob-subtype=${subtype}`,
);
},
);

test('should render colors with discrete classes', async ({ page }) => {
await page.setViewportSize({ width: 785, height: 800 });
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/bullet-graph--color-bands&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-Config 1 - Color_Color Bands=RGBA(70, 130, 96, 1)&knob-Config 2 - Steps_Color Bands=5&knob-Config 3 - json_Color Bands={"classes":[0,20,40,100],"colors":["pink","yellow","blue"]}&knob-Config 4 - json_Color Bands=[]&knob-color config_Color Bands=3&knob-end_Domain=100&knob-start_Domain=0&knob-subtype=${subtype}&knob-target_Domain=75&knob-tick strategy_Ticks=auto&knob-ticks(approx. count)_Ticks=5&knob-ticks(placements)_Ticks[0]=-200&knob-ticks(placements)_Ticks[1]=-100&knob-ticks(placements)_Ticks[2]=0&knob-ticks(placements)_Ticks[3]=5&knob-ticks(placements)_Ticks[4]=10&knob-ticks(placements)_Ticks[5]=15&knob-ticks(placements)_Ticks[6]=20&knob-ticks(placements)_Ticks[7]=25&knob-ticks(placements)_Ticks[8]=50&knob-ticks(placements)_Ticks[9]=100&knob-ticks(placements)_Ticks[10]=200&knob-value_Domain=56&knob-Config 2 - Palette_Color Bands=0&knob-Config 2 - Reverse_Color Bands=&knob-niceDomain_Ticks=&knob-debug=`,
);
});

pwEach.describe([true, false])(
(d) => `Nice domain - ${d}`,
(niceDomain) => {
pwEach.test(testCases)(
([v]) => `should render with ${v}`,
async (page, [, { start, end, target, value }]) => {
await page.setViewportSize({ width: 785, height: 800 });
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/bullet-graph--single&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-debug=&knob-title_General=Error rate&knob-subtitle_General=&knob-value_General=${value}&knob-target_General=${target}&knob-start_General=${start}&knob-end_General=${end}&knob-format (numeraljs)_General=0.[0]&knob-subtype_General=${subtype}&knob-niceDomain_Ticks=${niceDomain}&knob-tick strategy_Ticks=auto&knob-ticks(approx. count)_Ticks=10&knob-ticks(placements)_Ticks[0]=-200&knob-ticks(placements)_Ticks[1]=-100&knob-ticks(placements)_Ticks[2]=0&knob-ticks(placements)_Ticks[3]=5&knob-ticks(placements)_Ticks[4]=10&knob-ticks(placements)_Ticks[5]=15&knob-ticks(placements)_Ticks[6]=20&knob-ticks(placements)_Ticks[7]=25&knob-ticks(placements)_Ticks[8]=50&knob-ticks(placements)_Ticks[9]=100&knob-ticks(placements)_Ticks[10]=200`,
);
},
);
},
);
},
);

pwEach.describe([
{ subtype: 'vertical', width: '140px' },
{ subtype: 'horizontal', height: '85px' },
{ subtype: 'two-thirds-circle', height: '195px' },
])(
({ subtype }) => `Bullet as Metric - ${subtype}`,
({ subtype, height, width }) => {
test.describe('Bullet as Metric', () => {
pwEach.test(testCases)(
([v]) => `should render with ${v}`,
async (page, [, { start, end, target, value }]) => {
await page.setViewportSize({ width: 785, height: 800 });
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/bullet-graph--single&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-debug=&knob-title_General=Error rate&knob-subtitle_General=&knob-value_General=${value}&knob-target_General=${target}&knob-start_General=${start}&knob-end_General=${end}&knob-format (numeraljs)_General=0.[0]&knob-subtype_General=${subtype}&knob-niceDomain_Ticks=false&knob-tick strategy_Ticks=auto&knob-ticks(approx. count)_Ticks=10&knob-ticks(placements)_Ticks[0]=-200&knob-ticks(placements)_Ticks[1]=-100&knob-ticks(placements)_Ticks[2]=0&knob-ticks(placements)_Ticks[3]=5&knob-ticks(placements)_Ticks[4]=10&knob-ticks(placements)_Ticks[5]=15&knob-ticks(placements)_Ticks[6]=20&knob-ticks(placements)_Ticks[7]=25&knob-ticks(placements)_Ticks[8]=50&knob-ticks(placements)_Ticks[9]=100&knob-ticks(placements)_Ticks[10]=200`,
{
action: async () => await common.setResizeDimensions(page)({ height, width }),
},
);
},
);
});
},
);
});
10 changes: 9 additions & 1 deletion e2e_server/server/mocks/@storybook/addon-knobs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,22 @@ export function array(name: string, dftValues: unknown[], options: any, groupId?
return values;
}

export function object(name: string, dftValue: unknown, options: any, groupId?: string) {
export function object(name: string, dftValue: unknown, groupId?: string) {
const params = getParams();
const key = getKnobKey(name, groupId);
const value = params.get(key);
return value ? JSON.parse(value) : dftValue;
}

export function optionsKnob(name: string, values: unknown, dftValues: unknown[], options: any, groupId?: string) {
const params = getParams();
const knobName = getKnobKey(name, groupId);

// Check for single values first
const paramValues = params.getAll(knobName);

if (paramValues.length > 0) return paramValues;

return array(name, dftValues, options, groupId);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@semantic-release/npm": "^9.0.1",
"@semantic-release/release-notes-generator": "^10.0.3",
"@storybook/react": "^6.3.7",
"@types/chroma-js": "^2.0.0",
"@types/chroma-js": "^2.4.2",
"@types/classnames": "^2.2.7",
"@types/color": "^3.0.1",
"@types/core-js": "^2.5.2",
Expand Down
Loading