-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Explore Vis]Feat/add bar gauge #10697
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10697 +/- ##
==========================================
+ Coverage 60.49% 60.52% +0.03%
==========================================
Files 4506 4511 +5
Lines 121106 121296 +190
Branches 20174 20234 +60
==========================================
+ Hits 73262 73420 +158
- Misses 42722 42732 +10
- Partials 5122 5144 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| availableMappings: [ | ||
| { | ||
| [AxisRole.Y]: { type: VisFieldType.Numerical, index: 0 }, | ||
| [AxisRole.X]: { type: VisFieldType.Categorical, index: 0 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we support numerical field as x axis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, updated:
Here is a case where x axis is numerical
2025-10-16.12.53.35.mov
| export const getUnfilledArea = () => { | ||
| if (darkMode) return '#27252C'; | ||
| return '#f1f1f1ff'; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to default_colors.ts? we can have a shade color code based on dark/light, also we can use this shade at where DEFAULT_GREY is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function isn't suitable for DEFAULT_GREY as it returns as almost black in dark mode. I will introduce a new function getGrey to return the appropriate grey depending on light or dark mode.
390a291 to
61f45c2
Compare
| }; | ||
| const nullStyle = { axis: null }; | ||
|
|
||
| const shouldSwapAxes = (isXNumerical && isHorizontal) || (!isXNumerical && isHorizontal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this simplified as const shouldSwapAxes = isHorizontal;?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes!thanks for pointing out.
| defaultMessage: 'Horizontal', | ||
| }), | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can make it clear to read like this
const getOrientationOptions = (isXaxisNumerical: boolean) => {
const isVerticalLabel = isXaxisNumerical ? 'Horizontal' : 'Vertical';
const isHorizontalLabel = isXaxisNumerical ? 'Vertical' : 'Horizontal';
return [
{ id: 'vertical', label: isVerticalLabel },
{ id: 'horizontal', label: isHorizontalLabel }
];
};There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated! thanks~
src/plugins/explore/public/components/visualizations/bar_gauge/bar_gauge_utils.ts
Show resolved
Hide resolved
|
|
||
| export const NormalizeData = (data: number, start: number, end: number) => { | ||
| // normalize data value between start and end into 0–1 range | ||
| return (data - start) / (end - start); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we may need add a check for case end == start
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, updated, thanks!
| const result: any[] = []; | ||
|
|
||
| for (let i = 0; i < thresholds.length; i++) { | ||
| const start = thresholds[0].value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is thresholds a sorted array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.we will sort threshold in threshold panel
src/plugins/explore/public/components/visualizations/bar_gauge/bar_gauge_vis_config.ts
Outdated
Show resolved
Hide resolved
.../explore/public/components/visualizations/bar_gauge/bar_gauge_exclusive_vis_options.test.tsx
Outdated
Show resolved
Hide resolved
| hex = '#' + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]; | ||
| } | ||
|
|
||
| let r = parseInt(hex.slice(1, 3), 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would better have a check for hex to make sure it's vaild
| return result; | ||
| }; | ||
|
|
||
| export const NormalizeData = (data: number, start: number, end: number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: normalizeData
f41d42b to
6aa3315
Compare
| ? { | ||
| id: 'horizontal', | ||
| label: i18n.translate( | ||
| 'explore.vis.barGauge.orientation.threshold.horizontal.isXaxisNumerical', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isXaxisNumerical this key seems incorrect
| isXaxisNumerical | ||
| ? { | ||
| id: 'vertical', | ||
| label: i18n.translate('explore.vis.barGauge.orientation.vertical.isXaxisNumerical', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isXaxisNumerical this key seems incorrect, should be orientation.vertical?
| { offset: 0, color: thresholds[0].color }, | ||
| { | ||
| offset: 1, | ||
| color: darkenColor(thresholds[0]?.color, 2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to darken the color, just use thresholds[0].color in this case
32d2f1e to
6fe849c
Compare
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
0433818 to
fea707f
Compare
Description
this pr adds bar gauge
Screenshot
2025-10-14.15.59.38.mov
2025-10-14.17.19.17.mov
Testing the changes
Changelog
Check List
yarn test:jestyarn test:jest_integration