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

[Uptime] Update pings chart colors #46780

Merged
Show file tree
Hide file tree
Changes from 2 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

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 @@ -16,14 +16,15 @@ import {
} from '@elastic/charts';
import { EuiEmptyPrompt, EuiTitle, EuiPanel } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { Fragment } from 'react';
import React, { Fragment, useContext } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { HistogramDataPoint } from '../../../../common/graphql/types';
import { getColorsMap } from './get_colors_map';
import { getChartDateLabel } from '../../../lib/helper';
import { withUptimeGraphQL, UptimeGraphQLQueryProps } from '../../higher_order';
import { snapshotHistogramQuery } from '../../../queries/snapshot_histogram_query';
import { ChartWrapper } from './chart_wrapper';
import { UptimeSettingsContext } from '../../../contexts';

export interface SnapshotHistogramProps {
/**
Expand All @@ -34,14 +35,6 @@ export interface SnapshotHistogramProps {
* The date/time for the end of the timespan.
*/
absoluteEndDate: number;
/**
shahzad31 marked this conversation as resolved.
Show resolved Hide resolved
* The color value that is used to represent up checks.
*/
successColor: string;
/**
* The color value that is used to represent down checks.
*/
dangerColor: string;

/**
* Height is needed, since by defauly charts takes height of 100%
Expand All @@ -58,8 +51,6 @@ type Props = UptimeGraphQLQueryProps<SnapshotHistogramQueryResult> & SnapshotHis
export const SnapshotHistogramComponent = ({
absoluteStartDate,
absoluteEndDate,
dangerColor,
successColor,
data,
loading = false,
height,
Expand Down Expand Up @@ -107,6 +98,9 @@ export const SnapshotHistogramComponent = ({
const downMonitorsName = i18n.translate('xpack.uptime.snapshotHistogram.downMonitorsId', {
defaultMessage: 'Down Monitors',
});

const { colors } = useContext(UptimeSettingsContext);

const downSpecId = getSpecId(downMonitorsName);

const upMonitorsId = i18n.translate('xpack.uptime.snapshotHistogram.series.upLabel', {
Expand Down Expand Up @@ -154,10 +148,12 @@ export const SnapshotHistogramComponent = ({
})}
/>
<BarSeries
customSeriesColors={getColorsMap(successColor, upSpecId)}
data={histogram.map(({ x, upCount }) => [x, upCount || 0])}
id={upSpecId}
name={upMonitorsId}
customSeriesColors={getColorsMap(colors.danger, downSpecId)}
data={histogram.map(({ x, downCount }) => [x, downCount || 0])}
id={downSpecId}
name={i18n.translate('xpack.uptime.snapshotHistogram.series.downLabel', {
defaultMessage: 'Down',
})}
stackAccessors={[0]}
timeZone="local"
xAccessor={0}
Expand All @@ -166,12 +162,10 @@ export const SnapshotHistogramComponent = ({
yScaleType="linear"
/>
<BarSeries
customSeriesColors={getColorsMap(dangerColor, downSpecId)}
data={histogram.map(({ x, downCount }) => [x, downCount || 0])}
id={downSpecId}
name={i18n.translate('xpack.uptime.snapshotHistogram.series.downLabel', {
defaultMessage: 'Down',
})}
customSeriesColors={getColorsMap(colors.gray, upSpecId)}
data={histogram.map(({ x, upCount }) => [x, upCount || 0])}
id={upSpecId}
name={upMonitorsId}
stackAccessors={[0]}
timeZone="local"
xAccessor={0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export const MonitorChartsComponent = ({
<SnapshotHistogram
absoluteStartDate={absoluteDateRangeStart}
absoluteEndDate={absoluteDateRangeEnd}
successColor={colors.success}
dangerColor={colors.danger}
variables={{ dateRangeStart, dateRangeEnd, monitorId }}
height="400px"
/>
Expand Down
2 changes: 0 additions & 2 deletions x-pack/legacy/plugins/uptime/public/pages/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ export const OverviewPage = ({ basePath, logOverviewPageLoad, setBreadcrumbs }:
<SnapshotHistogram
absoluteStartDate={absoluteDateRangeStart}
absoluteEndDate={absoluteDateRangeEnd}
successColor={colors.success}
dangerColor={colors.danger}
variables={sharedProps}
height="120px"
/>
Expand Down
3 changes: 3 additions & 0 deletions x-pack/legacy/plugins/uptime/public/uptime_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { store } from './state';
export interface UptimeAppColors {
danger: string;
success: string;
gray: string;
range: string;
mean: string;
warning: string;
Expand Down Expand Up @@ -67,6 +68,7 @@ const Application = (props: UptimeAppProps) => {
colors = {
danger: euiDarkVars.euiColorDanger,
mean: euiDarkVars.euiColorPrimary,
gray: euiDarkVars.euiColorLightShade,
range: euiDarkVars.euiFocusBackgroundColor,
success: euiDarkVars.euiColorSuccess,
warning: euiDarkVars.euiColorWarning,
Expand All @@ -75,6 +77,7 @@ const Application = (props: UptimeAppProps) => {
colors = {
danger: euiLightVars.euiColorDanger,
mean: euiLightVars.euiColorPrimary,
gray: euiLightVars.euiColorLightShade,
range: euiLightVars.euiFocusBackgroundColor,
success: euiLightVars.euiColorSuccess,
warning: euiLightVars.euiColorWarning,
Expand Down