-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lens] Workspace panel dimensions by chart type (#168651)
## Summary Close #136993 All charts remain the same except the following ## Metric Each tile gets `200px` if there are multiple and `300px` if it's a single. The default background is EUI empty. <img width="600" alt="Screenshot 2023-10-30 at 3 55 33 PM" src="https://github.com/elastic/kibana/assets/315764/74d7e6dc-c90a-4f60-bf56-94ab1556ad42"> <img width="600" alt="Screenshot 2023-10-30 at 3 56 36 PM" src="https://github.com/elastic/kibana/assets/315764/3254160a-b18a-4c04-b059-f20b8f1f246a"> ## XY Vertical time-series charts have `16:9` ratio but will stretch to any available width and won't shrink below 300px height. https://github.com/elastic/kibana/assets/315764/3e056ae8-bc65-4851-9ad9-6c8a81bdf58a ## Gauge Gauge gets `600px` for the long side, `300px` for the short side. <img width="600" alt="Screenshot 2023-11-28 at 11 22 20 AM" src="https://github.com/elastic/kibana/assets/315764/2b774515-f060-4c26-a0aa-efdeebfff0e5"> <img width="600" alt="Screenshot 2023-11-28 at 11 22 33 AM" src="https://github.com/elastic/kibana/assets/315764/62181021-d88a-4cb6-862b-42768a2df13e"> ## Known issues - [ ] text resizing on the metric elastic/elastic-charts#2238 https://github.com/elastic/kibana/assets/315764/0162f461-b544-44a9-971c-b2a0265d7d3a - [x] gauge isn't showing veil on willRender ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios Flaky test runner: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4755 --------- Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: nickofthyme <[email protected]> Co-authored-by: Stratoula Kalafateli <[email protected]> Co-authored-by: Marta Bondyra <[email protected]>
- Loading branch information
1 parent
2a44f75
commit e6a5647
Showing
53 changed files
with
1,063 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/plugins/chart_expressions/common/chart_size_transition_veil.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* 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 React, { useEffect } from 'react'; | ||
import { useCallback, useRef, useState } from 'react'; | ||
import fastIsEqual from 'fast-deep-equal'; | ||
import { useResizeObserver } from '@elastic/eui'; | ||
import { euiThemeVars } from '@kbn/ui-theme'; | ||
import type { ChartSizeSpec } from './types'; | ||
|
||
/** | ||
* This hook is used to show a veil over the chart while it is being resized | ||
* in response to a change in the container dimensions. | ||
* | ||
* It is only relevant if client dimensions are being requested based on chart configuration. | ||
* | ||
* This whole feature is a nice-to-have. If it proves to be a source of bugs, | ||
* we can consider removing it and accepting the aesthetic drawback. | ||
*/ | ||
export function useSizeTransitionVeil( | ||
chartSizeSpec: ChartSizeSpec, | ||
setChartSize: (d: ChartSizeSpec) => void, | ||
// should be retrieved from handlers.shouldUseSizeTransitionVeil function | ||
shouldUseVeil: boolean | ||
) { | ||
const containerRef = useRef<HTMLDivElement>(null); | ||
const containerSize = useResizeObserver(containerRef.current); | ||
const currentContainerSize = useRef<{ width: number; height: number }>(containerSize); | ||
|
||
// This useEffect hook is here to make up for the fact that the initial container size | ||
// is not correctly reported by the useResizeObserver hook (see https://github.com/elastic/eui/issues/7458). | ||
useEffect(() => { | ||
currentContainerSize.current = { | ||
width: containerRef.current?.clientWidth ?? 0, | ||
height: containerRef.current?.clientHeight ?? 0, | ||
}; | ||
}, []); | ||
|
||
const [showVeil, setShowVeil] = useState(false); | ||
const currentChartSizeSpec = useRef<ChartSizeSpec>(); | ||
const specJustChanged = useRef<boolean>(false); | ||
|
||
useEffect(() => { | ||
if (!fastIsEqual(containerSize, currentContainerSize.current) && specJustChanged.current) { | ||
// If the container size has changed, we need to show the veil to hide the chart since it | ||
// be rendered based on the previous container size before being updated to the current size. | ||
// | ||
// 1. we show the veil | ||
// 2. the charts library will render the chart based on the previous container dimensions | ||
// 3. the charts library will resize the chart to the updated container dimensions | ||
// 4. we hide the veil | ||
setShowVeil(true); | ||
currentContainerSize.current = containerSize; | ||
} | ||
}, [setShowVeil, containerSize]); | ||
|
||
useEffect(() => { | ||
if (!fastIsEqual(chartSizeSpec, currentChartSizeSpec.current)) { | ||
setChartSize(chartSizeSpec); | ||
currentChartSizeSpec.current = chartSizeSpec; | ||
specJustChanged.current = true; | ||
|
||
setTimeout(() => { | ||
specJustChanged.current = false; | ||
}, 500); | ||
} | ||
}, [chartSizeSpec, setChartSize]); | ||
|
||
const onResize = useCallback(() => { | ||
setShowVeil(false); | ||
}, []); | ||
|
||
return { | ||
veil: ( | ||
<div | ||
css={{ | ||
height: '100%', | ||
width: '100%', | ||
backgroundColor: euiThemeVars.euiColorEmptyShade, | ||
position: 'absolute', | ||
zIndex: 1, | ||
display: shouldUseVeil && showVeil ? 'block' : 'none', | ||
}} | ||
/> | ||
), | ||
onResize, | ||
containerRef, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...xpressions/expression_gauge/public/components/__snapshots__/gauge_component.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.