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

[Bug] Distorted visualization title #1119

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions dashboards-observability/common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,11 @@ export enum BarOrientation {
horizontal = 'h',
vertical = 'v',
}

export const PLOT_MARGIN = {
l: 30,
r: 5,
b: 30,
t: 50,
pad: 4,
};
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,7 @@ $vis-editor-sidebar-min-width: 350px;
.panel_title:first-letter {
text-transform: uppercase;
}

.color-theme-combo-box-option .euiFlexItem.euiFlexItem--flexGrowZero {
display: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const ConfigColorTheme = ({
).map((item) => ({
...item,
label: vis.name === VIS_CHART_TYPES.Histogram ? item.name : getPropName(item),
className: 'color-theme-combo-box-option',
}));

const getUpdatedOptions = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,11 @@ exports[`Histogram component Renders histogram component 1`] = `
"orientation": "v",
},
"margin": Object {
"b": 15,
"l": 60,
"pad": 0,
"r": 10,
"t": 30,
"b": 30,
"l": 30,
"pad": 4,
"r": 5,
"t": 50,
},
"showlegend": true,
"title": "",
Expand Down Expand Up @@ -631,11 +631,11 @@ exports[`Histogram component Renders histogram component 1`] = `
"orientation": "v",
},
"margin": Object {
"b": 15,
"l": 60,
"pad": 0,
"r": 10,
"t": 30,
"b": 30,
"l": 30,
"pad": 4,
"r": 5,
"t": 50,
},
"showlegend": true,
"title": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,11 @@ exports[`Treemap component Renders treemap component 1`] = `
],
"height": 220,
"margin": Object {
"b": 15,
"l": 60,
"pad": 0,
"r": 10,
"t": 30,
"b": 30,
"l": 30,
"pad": 4,
"r": 5,
"t": 50,
},
"showlegend": true,
"title": "",
Expand Down Expand Up @@ -655,11 +655,11 @@ exports[`Treemap component Renders treemap component 1`] = `
"traceorder": "normal",
},
"margin": Object {
"b": 15,
"l": 60,
"pad": 0,
"r": 10,
"t": 30,
"b": 30,
"l": 30,
"pad": 4,
"r": 5,
"t": 50,
},
"showlegend": true,
"title": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
PLOTLY_COLOR,
THRESHOLD_LINE_OPACITY,
THRESHOLD_LINE_WIDTH,
PLOT_MARGIN,
} from '../../../../../common/constants/shared';
import { IVisualizationContainerProps } from '../../../../../common/types/explorer';
import { AvailabilityUnitType } from '../../../event_analytics/explorer/visualizations/config_panel/config_panes/config_controls/config_availability';
Expand Down Expand Up @@ -187,6 +188,7 @@ export const Bar = ({ visualizations, layout, config }: any) => {
},
showlegend: showLegend,
hovermode: 'closest',
margin: PLOT_MARGIN,
};
if (availabilityConfig.level) {
const thresholdTraces = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import {
AGGREGATIONS,
GROUPBY,
PLOTLY_GAUGE_COLUMN_NUMBER,
DEFAULT_GAUGE_CHART_PARAMETERS,
} from '../../../../../../common/constants/explorer';
import { DEFAULT_GAUGE_CHART_PARAMETERS } from '../../../../../../common/constants/explorer';
import { PLOT_MARGIN } from '../../../../../../common/constants/shared';
import { ThresholdUnitType } from '../../../../event_analytics/explorer/visualizations/config_panel/config_panes/config_controls/config_thresholds';
import { EmptyPlaceholder } from '../../../../event_analytics/explorer/visualizations/shared_components/empty_placeholder';
import { IVisualizationContainerProps } from '../../../../../../common/types/explorer';
Expand Down Expand Up @@ -193,6 +194,10 @@ export const Gauge = ({ visualizations, layout, config }: any) => {
...layout,
...(layoutConfig.layout && layoutConfig.layout),
title: dataConfig?.panelOptions?.title || layoutConfig.layout?.title || '',
margin: {
...PLOT_MARGIN,
t: 100,
},
};
}, [layout, gaugeData.length, layoutConfig.layout, dataConfig?.panelOptions?.title, orientation]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
FILLOPACITY_DIV_FACTOR,
PLOTLY_COLOR,
VIS_CHART_TYPES,
PLOT_MARGIN,
} from '../../../../../common/constants/shared';
import { IVisualizationContainerProps } from '../../../../../common/types/explorer';
import { hexToRgb } from '../../../../components/event_analytics/utils/utils';
Expand Down Expand Up @@ -95,6 +96,7 @@ export const Histogram = ({ visualizations, layout, config }: any) => {
orientation: legendPosition,
},
showlegend: showLegend,
margin: PLOT_MARGIN,
};

const mergedConfigs = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
FILLOPACITY_DIV_FACTOR,
PLOTLY_COLOR,
VIS_CHART_TYPES,
PLOT_MARGIN,
} from '../../../../../common/constants/shared';
import { getPropName, hexToRgb } from '../../../../components/event_analytics/utils/utils';
import { EmptyPlaceholder } from '../../../event_analytics/explorer/visualizations/shared_components/empty_placeholder';
Expand Down Expand Up @@ -181,6 +182,7 @@ export const Line = ({ visualizations, layout, config }: any) => {
showlegend: showLegend,
...(isBarMode && layoutForBarMode),
...(multiMetrics && multiMetrics),
margin: PLOT_MARGIN,
};

if (dataConfig.thresholds || availabilityConfig.level) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IVisualizationContainerProps } from '../../../../../common/types/explor
import { EmptyPlaceholder } from '../../../event_analytics/explorer/visualizations/shared_components/empty_placeholder';
import { Plt } from '../../plotly/plot';
import { AGGREGATIONS, GROUPBY } from '../../../../../common/constants/explorer';
import { PLOT_MARGIN } from '../../../../../common/constants/shared';

export const HeatMap = ({ visualizations, layout, config }: any) => {
const {
Expand Down Expand Up @@ -143,6 +144,7 @@ export const HeatMap = ({ visualizations, layout, config }: any) => {
...layout,
...(layoutConfig.layout && layoutConfig.layout),
title: dataConfig?.panelOptions?.title || layoutConfig.layout?.title || '',
margin: PLOT_MARGIN,
};

const mergedConfigs = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
MULTI_COLOR_PALETTE,
SINGLE_COLOR_PALETTE,
} from '../../../../../common/constants/colors';
import { DEFAULT_CHART_STYLES } from '../../../../../common/constants/shared';
import { DEFAULT_CHART_STYLES, PLOT_MARGIN } from '../../../../../common/constants/shared';
import { IVisualizationContainerProps } from '../../../../../common/types/explorer';
import { GROUPBY, AGGREGATIONS } from '../../../../../common/constants/explorer';

Expand Down Expand Up @@ -180,6 +180,7 @@ export const TreeMap = ({ visualizations, layout, config }: any) => {
...(layoutConfig.layout && layoutConfig.layout),
title: dataConfig?.panelOptions?.title || layoutConfig.layout?.title || '',
treemapcolorway: colorway,
margin: PLOT_MARGIN,
};

const mapData = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
AGGREGATIONS,
GROUPBY,
} from '../../../../../common/constants/explorer';
import { PLOT_MARGIN } from '../../../../../common/constants/shared';

export const Pie = ({ visualizations, layout, config }: any) => {
const {
Expand Down Expand Up @@ -140,7 +141,6 @@ export const Pie = ({ visualizations, layout, config }: any) => {
},
...layout,
...(layoutConfig.layout && layoutConfig.layout),
title,
legend: {
...layout.legend,
orientation: legend.position || visMetaData.legendposition,
Expand All @@ -149,6 +149,19 @@ export const Pie = ({ visualizations, layout, config }: any) => {
}),
},
showlegend: showLegend,
margin: {
...PLOT_MARGIN,
t: 100,
},
title: {
text: title,
xanchor: 'right',
yanchor: 'top',
x: 1,
y: 1,
xref: 'paper',
yref: 'container',
},
};
}, [series, layoutConfig.layout, title, layout.legend]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ export function Plt(props: PltProps) {

const finalLayout = {
autosize: true,
margin: {
l: 30,
r: 5,
b: 30,
t: 5,
pad: 4,
},
barmode: 'stack',
legend: {
orientation: 'h',
Expand Down