a489e5f0b1
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.
37 lines
1,019 B
TypeScript
37 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];
|
|
}
|
|
}
|