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

[ES|QL] [Unified Histogram] Changes the ratio to be rectangle #187981

Merged
merged 2 commits into from
Jul 11, 2024
Merged
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
19 changes: 3 additions & 16 deletions src/plugins/unified_histogram/public/chart/histogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* Side Public License, v 1.
*/

import { useEuiTheme, useResizeObserver } from '@elastic/eui';
import { useEuiTheme } from '@elastic/eui';
import { css } from '@emotion/react';
import React, { useState, useRef, useEffect } from 'react';
import React, { useState } from 'react';
import type { DataView } from '@kbn/data-views-plugin/public';
import type { DefaultInspectorAdapters, Datatable } from '@kbn/expressions-plugin/common';
import type { IKibanaSearchResponse } from '@kbn/search-types';
Expand Down Expand Up @@ -106,7 +106,6 @@ export function Histogram({
abortController,
}: HistogramProps) {
const [bucketInterval, setBucketInterval] = useState<UnifiedHistogramBucketInterval>();
const [chartSize, setChartSize] = useState('100%');
const { timeRangeText, timeRangeDisplay } = useTimeRange({
uiSettings,
bucketInterval,
Expand All @@ -115,19 +114,8 @@ export function Histogram({
isPlainRecord,
timeField: dataView.timeFieldName,
});
const chartRef = useRef<HTMLDivElement | null>(null);
const { height: containerHeight, width: containerWidth } = useResizeObserver(chartRef.current);
const { attributes } = visContext;

useEffect(() => {
if (attributes.visualizationType === 'lnsMetric') {
const size = containerHeight < containerWidth ? containerHeight : containerWidth;
setChartSize(`${size}px`);
} else {
setChartSize('100%');
}
}, [attributes, containerHeight, containerWidth]);

const onLoad = useStableCallback(
(
isLoading: boolean,
Expand Down Expand Up @@ -197,7 +185,7 @@ export function Histogram({
}

& .lnsExpressionRenderer {
width: ${chartSize};
width: ${attributes.visualizationType === 'lnsMetric' ? '90$' : '100%'};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, looks like the latest changes switched the width from 90% to 90$. I opened a PR to fix it here and promise not to charge 90$ for it: #188150.

margin: auto;
box-shadow: ${attributes.visualizationType === 'lnsMetric' ? boxShadow : 'none'};
}
Expand All @@ -222,7 +210,6 @@ export function Histogram({
data-request-data={requestData}
data-suggestion-type={visContext.suggestionType}
css={chartCss}
ref={chartRef}
>
<lens.EmbeddableComponent
{...lensProps}
Expand Down