Skip to content

Commit

Permalink
[9.0] [ObsUX] Fix chart colors for observability overview apm and hos…
Browse files Browse the repository at this point in the history
…ts charts (#210847) (#210989)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[ObsUX] Fix chart colors for observability overview apm and hosts
charts (#210847)](#210847)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Miriam","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-13T11:54:43Z","message":"[ObsUX]
Fix chart colors for observability overview apm and hosts charts
(#210847)\n\n## Summary\r\n\r\nFixed the colors for the observability
overview charts on APM and Hosts\r\n\r\nBEFORE\r\n\r\n<img
width=\"1685\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/ee68eec4-742c-44ab-bbb6-8890bee1c0bf\"\r\n/>\r\n\r\nAFTER\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/2d8f8970-0938-4ccb-8679-533760fb3622)\r\n\r\n\r\n>
[!NOTE] \r\n> For some reason CPU chart on Hosts it's not showing, seems
a bug, but\r\nthat's out of the scope of this
issue\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"3bf3dad7a01d6eefd34013833e6d8e6f0c3614a0","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","Team:obs-ux-infra_services","Team:obs-ux-management","v9.1.0"],"title":"[ObsUX]
Fix chart colors for observability overview apm and hosts
charts","number":210847,"url":"https://github.com/elastic/kibana/pull/210847","mergeCommit":{"message":"[ObsUX]
Fix chart colors for observability overview apm and hosts charts
(#210847)\n\n## Summary\r\n\r\nFixed the colors for the observability
overview charts on APM and Hosts\r\n\r\nBEFORE\r\n\r\n<img
width=\"1685\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/ee68eec4-742c-44ab-bbb6-8890bee1c0bf\"\r\n/>\r\n\r\nAFTER\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/2d8f8970-0938-4ccb-8679-533760fb3622)\r\n\r\n\r\n>
[!NOTE] \r\n> For some reason CPU chart on Hosts it's not showing, seems
a bug, but\r\nthat's out of the scope of this
issue\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"3bf3dad7a01d6eefd34013833e6d8e6f0c3614a0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210847","number":210847,"mergeCommit":{"message":"[ObsUX]
Fix chart colors for observability overview apm and hosts charts
(#210847)\n\n## Summary\r\n\r\nFixed the colors for the observability
overview charts on APM and Hosts\r\n\r\nBEFORE\r\n\r\n<img
width=\"1685\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/ee68eec4-742c-44ab-bbb6-8890bee1c0bf\"\r\n/>\r\n\r\nAFTER\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/2d8f8970-0938-4ccb-8679-533760fb3622)\r\n\r\n\r\n>
[!NOTE] \r\n> For some reason CPU chart on Hosts it's not showing, seems
a bug, but\r\nthat's out of the scope of this
issue\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"3bf3dad7a01d6eefd34013833e6d8e6f0c3614a0"}}]}]
BACKPORT-->

Co-authored-by: Miriam <[email protected]>
  • Loading branch information
kibanamachine and MiriamAparicio authored Feb 13, 2025
1 parent 250d055 commit 15acdfa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
1 change: 0 additions & 1 deletion packages/kbn-babel-preset/styled_components_files.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ import {
XYBrushEvent,
} from '@elastic/charts';
import { timeFormatter } from '@elastic/charts/dist/utils/data/formatters';
import { EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiIcon } from '@elastic/eui';
import { EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiIcon, useEuiTheme } from '@elastic/eui';
import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
import moment from 'moment';
import React, { useContext } from 'react';
import React from 'react';
import { useHistory } from 'react-router-dom';
import { ThemeContext } from 'styled-components';
import { useChartThemes, FETCH_STATUS, useFetcher } from '@kbn/observability-shared-plugin/public';
import { useDatePickerContext } from '../../../../../hooks/use_date_picker_context';
import { SectionContainer } from '../section_container';
Expand Down Expand Up @@ -54,7 +53,7 @@ function formatTpmStat(value?: number) {
}

export function APMSection({ bucketSize }: Props) {
const theme = useContext(ThemeContext);
const { euiTheme } = useEuiTheme();
const chartThemes = useChartThemes();
const history = useHistory();
const { forceUpdate, hasDataMap } = useHasData();
Expand Down Expand Up @@ -92,8 +91,6 @@ export function APMSection({ bucketSize }: Props) {

const isLoading = status === FETCH_STATUS.LOADING;

const transactionsColor = theme.eui.euiColorVis1;

return (
<SectionContainer
title={i18n.translate('xpack.observability.overview.apm.title', {
Expand Down Expand Up @@ -142,7 +139,7 @@ export function APMSection({ bucketSize }: Props) {
</EuiToolTip>
}
isLoading={isLoading}
color={transactionsColor}
// color={transactionsColor}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand All @@ -164,7 +161,7 @@ export function APMSection({ bucketSize }: Props) {
yScaleType={ScaleType.Linear}
xAccessor={'x'}
yAccessors={['y']}
color={transactionsColor}
color={euiTheme.colors.vis.euiColorVis0}
/>
<Axis
id="y-axis"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ interface Props {
value: NumberOrNull;
timeseries: any[];
formatter: (value: NumberOrNull) => string;
color: number;
color: string;
}
export function MetricWithSparkline({ id, formatter, value, timeseries, color }: Props) {
const { baseTheme, sparklineTheme } = useChartThemes();
const colors = baseTheme.colors?.vizColors ?? [];

if (!value) {
return (
Expand Down Expand Up @@ -53,7 +52,7 @@ export function MetricWithSparkline({ id, formatter, value, timeseries, color }:
data={timeseries}
xAccessor={'timestamp'}
yAccessors={[id]}
color={colors[color] || '#006BB4'}
color={color}
/>
</Chart>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
EuiBasicTableColumn,
EuiLoadingChart,
EuiTableSortingType,
useEuiTheme,
} from '@elastic/eui';
import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
Expand All @@ -32,11 +33,6 @@ import { formatDuration } from './lib/format_duration';
import { MetricWithSparkline } from './metric_with_sparkline';
import type { BucketSize } from '../../../helpers/calculate_bucket_size';

const COLOR_ORANGE = 7;
const COLOR_BLUE = 1;
const COLOR_GREEN = 0;
const COLOR_PURPLE = 3;

interface Props {
bucketSize: BucketSize;
}
Expand All @@ -51,6 +47,7 @@ const bytesPerSecondFormatter = (value: NumberOrNull) =>
value === null ? '' : numeral(value).format('0b') + '/s';

export function MetricsSection({ bucketSize }: Props) {
const { euiTheme } = useEuiTheme();
const { forceUpdate, hasDataMap } = useHasData();
const { relativeStart, relativeEnd, absoluteStart, absoluteEnd, lastUpdated } =
useDatePickerContext();
Expand Down Expand Up @@ -141,7 +138,7 @@ export function MetricsSection({ bucketSize }: Props) {
value={value}
formatter={percentFormatter}
timeseries={record.timeseries}
color={COLOR_ORANGE}
color={euiTheme.colors.vis.euiColorVis0}
/>
),
},
Expand All @@ -157,7 +154,7 @@ export function MetricsSection({ bucketSize }: Props) {
value={value}
formatter={numberFormatter}
timeseries={record.timeseries}
color={COLOR_BLUE}
color={euiTheme.colors.vis.euiColorVis1}
/>
),
},
Expand All @@ -171,7 +168,7 @@ export function MetricsSection({ bucketSize }: Props) {
value={value}
formatter={bytesPerSecondFormatter}
timeseries={record.timeseries}
color={COLOR_GREEN}
color={euiTheme.colors.vis.euiColorVis2}
/>
),
},
Expand All @@ -185,7 +182,7 @@ export function MetricsSection({ bucketSize }: Props) {
value={value}
formatter={bytesPerSecondFormatter}
timeseries={record.timeseries}
color={COLOR_PURPLE}
color={euiTheme.colors.vis.euiColorVis3}
/>
),
},
Expand Down

0 comments on commit 15acdfa

Please sign in to comment.