Skip to content

Commit

Permalink
[Uptime] Update pings chart colors (elastic#46780)
Browse files Browse the repository at this point in the history
* update pings chart colors

* update snaps

* update snaps

* update snaps
  • Loading branch information
shahzad31 committed Oct 11, 2019
1 parent 6c57768 commit e11fac0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 32 deletions.

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 @@ -12,8 +12,6 @@ describe('SnapshotHistogram component', () => {
const props: SnapshotHistogramProps = {
absoluteStartDate: 1548697920000,
absoluteEndDate: 1548700920000,
successColor: '#FEFEFE',
dangerColor: '#FF00FF',
};

it('renders the component without errors', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '@elastic/charts';
import { EuiEmptyPrompt, EuiTitle, EuiPanel } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import React, { useContext } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import moment from 'moment';
import { HistogramDataPoint } from '../../../../common/graphql/types';
Expand All @@ -25,6 +25,7 @@ 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 @@ -35,14 +36,6 @@ export interface SnapshotHistogramProps {
* The date/time for the end of the timespan.
*/
absoluteEndDate: number;
/**
* 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 default charts takes height of 100%
Expand All @@ -59,8 +52,6 @@ type Props = UptimeGraphQLQueryProps<SnapshotHistogramQueryResult> & SnapshotHis
export const SnapshotHistogramComponent = ({
absoluteStartDate,
absoluteEndDate,
dangerColor,
successColor,
data,
loading = false,
height,
Expand Down Expand Up @@ -108,6 +99,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 @@ -166,10 +160,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 @@ -178,12 +174,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 @@ -6,12 +6,11 @@

import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { Fragment, useContext } from 'react';
import React, { Fragment } from 'react';
import { MonitorChart } from '../../../common/graphql/types';
import { UptimeGraphQLQueryProps, withUptimeGraphQL } from '../higher_order';
import { monitorChartsQuery } from '../../queries';
import { DurationChart } from './charts';
import { UptimeSettingsContext } from '../../contexts';
import { SnapshotHistogram } from './charts/snapshot_histogram';
import { useUrlParams } from '../../hooks';

Expand Down Expand Up @@ -45,7 +44,6 @@ export const MonitorChartsComponent = ({
monitorChartsData: { locationDurationLines },
} = data;

const { colors } = useContext(UptimeSettingsContext);
const [getUrlParams] = useUrlParams();
const { absoluteDateRangeStart, absoluteDateRangeEnd } = getUrlParams();

Expand All @@ -64,8 +62,6 @@ export const MonitorChartsComponent = ({
<SnapshotHistogram
absoluteStartDate={absoluteDateRangeStart}
absoluteEndDate={absoluteDateRangeEnd}
successColor={colors.success}
dangerColor={colors.danger}
variables={{ dateRangeStart, dateRangeEnd, monitorId }}
height="400px"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const defaultContext: UMSettingsContextValues = {
range: euiLightVars.euiFocusBackgroundColor,
success: euiLightVars.euiColorSuccess,
warning: euiLightVars.euiColorWarning,
gray: euiLightVars.euiColorLightShade,
},
dateRangeStart: DATE_RANGE_START,
dateRangeEnd: DATE_RANGE_END,
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 @@ -161,8 +161,6 @@ export const OverviewPage = ({
<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 @@ -25,6 +25,7 @@ import { store } from './state';
export interface UptimeAppColors {
danger: string;
success: string;
gray: string;
range: string;
mean: string;
warning: string;
Expand Down Expand Up @@ -73,6 +74,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 @@ -81,6 +83,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

0 comments on commit e11fac0

Please sign in to comment.