mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
feat(slo): Synchronize cursor on SLO charts (#155560)
This commit is contained in:
parent
68719bdb07
commit
158ea85468
3 changed files with 16 additions and 3 deletions
|
@ -15,10 +15,11 @@ import {
|
|||
ScaleType,
|
||||
Settings,
|
||||
} from '@elastic/charts';
|
||||
import React from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { EuiIcon, EuiLoadingChart, useEuiTheme } from '@elastic/eui';
|
||||
import numeral from '@elastic/numeral';
|
||||
import moment from 'moment';
|
||||
import { useActiveCursor } from '@kbn/charts-plugin/public';
|
||||
|
||||
import { ChartData } from '../../../typings';
|
||||
import { useKibana } from '../../../utils/kibana_react';
|
||||
|
@ -45,18 +46,29 @@ export function WideChart({ chart, data, id, isLoading, state }: Props) {
|
|||
const color = state === 'error' ? euiTheme.colors.danger : euiTheme.colors.success;
|
||||
const ChartComponent = chart === 'area' ? AreaSeries : LineSeries;
|
||||
|
||||
const chartRef = useRef(null);
|
||||
const handleCursorUpdate = useActiveCursor(charts.activeCursor, chartRef, {
|
||||
isDateHistogram: true,
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
return <EuiLoadingChart size="m" mono data-test-subj="wideChartLoading" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Chart size={{ height: 150, width: '100%' }}>
|
||||
<Chart size={{ height: 150, width: '100%' }} ref={chartRef}>
|
||||
<Settings
|
||||
baseTheme={baseTheme}
|
||||
showLegend={false}
|
||||
theme={[theme]}
|
||||
tooltip="vertical"
|
||||
noResults={<EuiIcon type="visualizeApp" size="l" color="subdued" title="no results" />}
|
||||
onPointerUpdate={handleCursorUpdate}
|
||||
externalPointerEvents={{
|
||||
tooltip: { visible: true },
|
||||
}}
|
||||
pointerUpdateDebounce={0}
|
||||
pointerUpdateTrigger={'x'}
|
||||
/>
|
||||
<Axis
|
||||
id="bottom"
|
||||
|
|
|
@ -54,7 +54,7 @@ const mockKibana = () => {
|
|||
useKibanaMock.mockReturnValue({
|
||||
services: {
|
||||
application: { navigateToUrl: mockNavigate },
|
||||
charts: chartPluginMock.createSetupContract(),
|
||||
charts: chartPluginMock.createStartContract(),
|
||||
http: {
|
||||
basePath: {
|
||||
prepend: mockBasePathPrepend,
|
||||
|
|
|
@ -65,6 +65,7 @@ export function KibanaReactStorybookDecorator(Story: ComponentType) {
|
|||
useChartsBaseTheme: () => {},
|
||||
useChartsTheme: () => {},
|
||||
},
|
||||
activeCursor: () => {},
|
||||
},
|
||||
data: {},
|
||||
dataViews: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue