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

[7.x] [ML] Fixes series color in data visualizer metric distribution chart (#44499) #44608

Merged
merged 1 commit into from
Sep 2, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Axis,
BarSeries,
Chart,
DataSeriesColorsValues,
getAxisId,
getSpecId,
niceTimeFormatter,
Expand Down Expand Up @@ -59,22 +58,23 @@ export const DocumentCountChart: FC<Props> = ({

const dateFormatter = niceTimeFormatter([timeRangeEarliest, timeRangeLatest]);

// TODO - switch to use inline areaSeriesStyle to set series fill once charts version is 8.0.0+
const IS_DARK_THEME = useUiChromeContext()
.getUiSettingsClient()
.get('theme:darkMode');
const themeName = IS_DARK_THEME ? darkTheme : lightTheme;
const EVENT_RATE_COLOR = themeName.euiColorVis2;
const barSeriesColorValues: DataSeriesColorsValues = {
colorValues: [],
specId: getSpecId(SPEC_ID),
};
const seriesColors = new Map([[barSeriesColorValues, EVENT_RATE_COLOR]]);

return (
<div style={{ width, height }}>
<Chart>
<Settings xDomain={xDomain} />
<Settings
xDomain={xDomain}
theme={{
colors: {
vizColors: [EVENT_RATE_COLOR],
},
}}
/>
<Axis
id={getAxisId('bottom')}
position={Position.Bottom}
Expand All @@ -91,7 +91,6 @@ export const DocumentCountChart: FC<Props> = ({
yAccessors={['value']}
// Display empty chart when no data in range
data={chartPoints.length > 0 ? chartPoints : [{ time: timeRangeEarliest, value: 0 }]}
customSeriesColors={seriesColors}
/>
</Chart>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
Axis,
Chart,
CurveType,
DataSeriesColorsValues,
getAxisId,
getSpecId,
Position,
Expand Down Expand Up @@ -55,17 +54,11 @@ export const MetricDistributionChart: FC<Props> = ({ width, height, chartData, f
defaultMessage: 'distribution',
});

// TODO - switch to use inline areaSeriesStyle to set series fill once charts version is 8.0.0+
const IS_DARK_THEME = useUiChromeContext()
.getUiSettingsClient()
.get('theme:darkMode');
const themeName = IS_DARK_THEME ? darkTheme : lightTheme;
const EVENT_RATE_COLOR = themeName.euiColorVis1;
const seriesColorValues: DataSeriesColorsValues = {
colorValues: [],
specId: getSpecId(SPEC_ID),
};
const seriesColors = new Map([[seriesColorValues, EVENT_RATE_COLOR]]);
const AREA_SERIES_COLOR = themeName.euiColorVis1;

const headerFormatter: TooltipValueFormatter = (tooltipData: TooltipValue) => {
const xValue = tooltipData.value;
Expand All @@ -87,9 +80,11 @@ export const MetricDistributionChart: FC<Props> = ({ width, height, chartData, f
<Chart>
<Settings
theme={{
colors: {
vizColors: [AREA_SERIES_COLOR],
},
areaSeriesStyle: {
line: {
stroke: 'red',
strokeWidth: 1,
visible: true,
},
Expand All @@ -98,7 +93,7 @@ export const MetricDistributionChart: FC<Props> = ({ width, height, chartData, f
radius: 0,
opacity: 0,
},
area: { fill: 'red', visible: true, opacity: 1 },
area: { visible: true, opacity: 1 },
},
}}
tooltip={{ headerFormatter }}
Expand All @@ -123,21 +118,6 @@ export const MetricDistributionChart: FC<Props> = ({ width, height, chartData, f
yAccessors={['y']}
data={chartData.length > 0 ? chartData : [{ x: 0, y: 0 }]}
curve={CurveType.CURVE_STEP_AFTER}
// TODO - switch to use inline areaSeriesStyle to set series fill once charts version is 8.0.0+
// areaSeriesStyle={{
// line: {
// stroke: 'red',
// strokeWidth: 0,
// visible: false,
// },
// point: {
// visible: false,
// radius: 0,
// opacity: 0,
// },
// area: { fill: 'red', visible: true, opacity: 1 },
// }}
customSeriesColors={seriesColors}
/>
</Chart>
</div>
Expand Down