kibana/x-pack/plugins/ml/common/util/group_color_utils.ts
Walter Rafelsberger a489e5f0b1
[ML] Data Grid Histograms (#68359)
Adds support for histogram charts to data grid columns.
- Adds a toggle button to the data grid's header to enabled/disable column charts.
- When enabled, the charts get rendered as part of the data grid header.
- Histogram charts will get rendered for fields based on date, number, string and boolean.
2020-06-19 08:39:50 +02:00

38 lines
1,019 B
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import euiVars from '@elastic/eui/dist/eui_theme_dark.json';
import { stringHash } from './string_utils';
const COLORS = [
euiVars.euiColorVis0,
euiVars.euiColorVis1,
euiVars.euiColorVis2,
euiVars.euiColorVis3,
// euiVars.euiColorVis4, // light pink, too hard to read with white text
euiVars.euiColorVis5,
euiVars.euiColorVis6,
euiVars.euiColorVis7,
euiVars.euiColorVis8,
euiVars.euiColorVis9,
euiVars.euiColorDarkShade,
euiVars.euiColorPrimary,
];
const colorMap: Record<string, string> = {};
export function tabColor(name: string): string {
if (colorMap[name] === undefined) {
const n = stringHash(name);
const color = COLORS[n % COLORS.length];
colorMap[name] = color;
return color;
} else {
return colorMap[name];
}
}