-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create vis_type_xy plugin to replace histogram, area and line charts (#…
- Loading branch information
1 parent
cea865f
commit ddea10e
Showing
282 changed files
with
8,357 additions
and
2,763 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/plugins/charts/public/static/components/color_picker.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$visColorPickerWidth: $euiSizeL * 8; // 8 columns | ||
|
||
.visColorPicker__value { | ||
width: $visColorPickerWidth; | ||
} | ||
|
||
.visColorPicker__valueDot { | ||
cursor: pointer; | ||
|
||
&:hover { | ||
transform: scale(1.4); | ||
} | ||
|
||
&-isSelected { | ||
border: $euiSizeXS solid; | ||
border-radius: 100%; | ||
} | ||
} |
138 changes: 138 additions & 0 deletions
138
src/plugins/charts/public/static/components/color_picker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import classNames from 'classnames'; | ||
import React, { BaseSyntheticEvent } from 'react'; | ||
|
||
import { EuiButtonEmpty, EuiFlexItem, EuiIcon } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
import './color_picker.scss'; | ||
|
||
export const legendColors: string[] = [ | ||
'#3F6833', | ||
'#967302', | ||
'#2F575E', | ||
'#99440A', | ||
'#58140C', | ||
'#052B51', | ||
'#511749', | ||
'#3F2B5B', | ||
'#508642', | ||
'#CCA300', | ||
'#447EBC', | ||
'#C15C17', | ||
'#890F02', | ||
'#0A437C', | ||
'#6D1F62', | ||
'#584477', | ||
'#629E51', | ||
'#E5AC0E', | ||
'#64B0C8', | ||
'#E0752D', | ||
'#BF1B00', | ||
'#0A50A1', | ||
'#962D82', | ||
'#614D93', | ||
'#7EB26D', | ||
'#EAB839', | ||
'#6ED0E0', | ||
'#EF843C', | ||
'#E24D42', | ||
'#1F78C1', | ||
'#BA43A9', | ||
'#705DA0', | ||
'#9AC48A', | ||
'#F2C96D', | ||
'#65C5DB', | ||
'#F9934E', | ||
'#EA6460', | ||
'#5195CE', | ||
'#D683CE', | ||
'#806EB7', | ||
'#B7DBAB', | ||
'#F4D598', | ||
'#70DBED', | ||
'#F9BA8F', | ||
'#F29191', | ||
'#82B5D8', | ||
'#E5A8E2', | ||
'#AEA2E0', | ||
'#E0F9D7', | ||
'#FCEACA', | ||
'#CFFAFF', | ||
'#F9E2D2', | ||
'#FCE2DE', | ||
'#BADFF4', | ||
'#F9D9F9', | ||
'#DEDAF7', | ||
]; | ||
|
||
interface ColorPickerProps { | ||
id?: string; | ||
label: string | number | null; | ||
onChange: (color: string | null, event: BaseSyntheticEvent) => void; | ||
color: string; | ||
} | ||
|
||
export const ColorPicker = ({ onChange, color: selectedColor, id, label }: ColorPickerProps) => ( | ||
<div className="visColorPicker"> | ||
<span id={`${id}ColorPickerDesc`} className="euiScreenReaderOnly"> | ||
<FormattedMessage | ||
id="charts.colorPicker.setColor.screenReaderDescription" | ||
defaultMessage="Set color for value {legendDataLabel}" | ||
values={{ legendDataLabel: label }} | ||
/> | ||
</span> | ||
<div className="visColorPicker__value" role="listbox"> | ||
{legendColors.map((color) => ( | ||
<EuiIcon | ||
role="option" | ||
tabIndex={0} | ||
type="dot" | ||
size="l" | ||
color={selectedColor} | ||
key={color} | ||
aria-label={color} | ||
aria-describedby={`${id}ColorPickerDesc`} | ||
aria-selected={color === selectedColor} | ||
onClick={(e) => onChange(color, e)} | ||
onKeyPress={(e) => onChange(color, e)} | ||
className={classNames('visColorPicker__valueDot', { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
'visColorPicker__valueDot-isSelected': color === selectedColor, | ||
})} | ||
style={{ color }} | ||
data-test-subj={`visColorPickerColor-${color}`} | ||
/> | ||
))} | ||
</div> | ||
{legendColors.some((c) => c === selectedColor) && ( | ||
<EuiFlexItem grow={false}> | ||
<EuiButtonEmpty | ||
size="s" | ||
onClick={(e: any) => onChange(null, e)} | ||
onKeyPress={(e: any) => onChange(null, e)} | ||
> | ||
<FormattedMessage id="charts.colorPicker.clearColor" defaultMessage="Clear color" /> | ||
</EuiButtonEmpty> | ||
</EuiFlexItem> | ||
)} | ||
</div> | ||
); |
64 changes: 64 additions & 0 deletions
64
src/plugins/charts/public/static/components/current_time.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import moment, { Moment } from 'moment'; | ||
import React, { FC } from 'react'; | ||
|
||
import { LineAnnotation, AnnotationDomainTypes, LineAnnotationStyle } from '@elastic/charts'; | ||
import lightEuiTheme from '@elastic/eui/dist/eui_theme_light.json'; | ||
import darkEuiTheme from '@elastic/eui/dist/eui_theme_dark.json'; | ||
|
||
interface CurrentTimeProps { | ||
isDarkMode: boolean; | ||
domainEnd?: number | Moment; | ||
} | ||
|
||
/** | ||
* Render current time line annotation on @elastic/charts `Chart` | ||
*/ | ||
export const CurrentTime: FC<CurrentTimeProps> = ({ isDarkMode, domainEnd }) => { | ||
const lineAnnotationStyle: Partial<LineAnnotationStyle> = { | ||
line: { | ||
strokeWidth: 2, | ||
stroke: isDarkMode ? darkEuiTheme.euiColorDanger : lightEuiTheme.euiColorDanger, | ||
opacity: 0.7, | ||
}, | ||
}; | ||
|
||
// Domain end of 'now' will be milliseconds behind current time, so we extend time by 1 minute and check if | ||
// the annotation is within this range; if so, the line annotation uses the domainEnd as its value | ||
const now = moment(); | ||
const isAnnotationAtEdge = domainEnd | ||
? moment(domainEnd).add(1, 'm').isAfter(now) && now.isAfter(domainEnd) | ||
: false; | ||
const lineAnnotationData = [ | ||
{ | ||
dataValue: isAnnotationAtEdge ? domainEnd : now.valueOf(), | ||
}, | ||
]; | ||
|
||
return ( | ||
<LineAnnotation | ||
id="__current-time__" | ||
hideTooltips | ||
domainType={AnnotationDomainTypes.XDomain} | ||
dataValues={lineAnnotationData} | ||
style={lineAnnotationStyle} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.