-
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.
Replace flot with elastic-chart in Timelion (#81565)
* First draft migrate timelion to elastic-charts * Some refactoring. Added brush event. * Added title. Some refactoring * Fixed some type problems. Added logic for yaxes function * Fixed some types, added missing functionality for yaxes * Fixed some types, added missing functionality for stack property * Fixed unit test * Removed unneeded code * Some refactoring * Some refactoring * Fixed some remarks. * Fixed some styles * Added themes. Removed unneeded styles in BarSeries * removed unneeded code. * Fixed some comments * Fixed vertical cursor across Timelion visualizations of a dashboad * Fix some problems with styles * Use RxJS instead of jQuery * Remove unneeded code * Fixed some problems * Fixed unit test * Fix CI * Fix eslint * Fix some gaps * Fix legend columns * Some fixes * add 2 versions of Timeline app * fix CI * cleanup code * fix CI * fix legend position * fix some cases * fix some cases * remove extra casting * cleanup code * fix issue with static * fix header formatter * fix points * fix ts error * Fix yaxis behavior * Fix some case with yaxis * Add deprecation message and update asciidoc * Fix title * some text improvements Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
- Loading branch information
1 parent
33bc6f1
commit 8088565
Showing
35 changed files
with
1,717 additions
and
770 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export const UI_SETTINGS = { | ||
LEGACY_CHARTS_LIBRARY: 'timelion:legacyChartsLibrary', | ||
ES_TIMEFIELD: 'timelion:es.timefield', | ||
DEFAULT_INDEX: 'timelion:es.default_index', | ||
TARGET_BUCKETS: 'timelion:target_buckets', | ||
MAX_BUCKETS: 'timelion:max_buckets', | ||
MIN_INTERVAL: 'timelion:min_interval', | ||
GRAPHITE_URL: 'timelion:graphite.url', | ||
QUANDL_KEY: 'timelion:quandl.key', | ||
}; |
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,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export interface VisSeries { | ||
yaxis?: number; | ||
label: string; | ||
lines?: { | ||
show?: boolean; | ||
lineWidth?: number; | ||
fill?: number; | ||
steps?: number; | ||
}; | ||
points?: { | ||
show?: boolean; | ||
symbol?: 'cross' | 'x' | 'circle' | 'square' | 'diamond' | 'plus' | 'triangle'; | ||
fillColor?: string; | ||
fill?: number; | ||
radius?: number; | ||
lineWidth?: number; | ||
}; | ||
bars: { | ||
lineWidth?: number; | ||
fill?: number; | ||
}; | ||
color?: string; | ||
data: Array<Array<number | null>>; | ||
stack: boolean; | ||
} |
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
62 changes: 62 additions & 0 deletions
62
src/plugins/vis_type_timelion/public/components/series/area.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,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { AreaSeries, ScaleType, CurveType, AreaSeriesStyle, PointShape } from '@elastic/charts'; | ||
import type { VisSeries } from '../../../common/vis_data'; | ||
|
||
interface AreaSeriesComponentProps { | ||
index: number; | ||
visData: VisSeries; | ||
groupId: string; | ||
} | ||
|
||
const isShowLines = (lines: VisSeries['lines'], points: VisSeries['points']) => | ||
lines?.show ? true : points?.show ? false : true; | ||
|
||
const getAreaSeriesStyle = ({ color, lines, points }: AreaSeriesComponentProps['visData']) => | ||
({ | ||
line: { | ||
opacity: isShowLines(lines, points) ? 1 : 0, | ||
stroke: color, | ||
strokeWidth: lines?.lineWidth !== undefined ? Number(lines.lineWidth) : 3, | ||
visible: isShowLines(lines, points), | ||
}, | ||
area: { | ||
fill: color, | ||
opacity: lines?.fill ?? 0, | ||
visible: lines?.show ?? points?.show ?? true, | ||
}, | ||
point: { | ||
fill: points?.fillColor ?? color, | ||
opacity: points?.lineWidth !== undefined ? (points.fill || 1) * 10 : 10, | ||
radius: points?.radius ?? 3, | ||
stroke: color, | ||
strokeWidth: points?.lineWidth ?? 2, | ||
visible: points?.show ?? false, | ||
shape: points?.symbol === 'cross' ? PointShape.X : points?.symbol, | ||
}, | ||
curve: lines?.steps ? CurveType.CURVE_STEP : CurveType.LINEAR, | ||
} as AreaSeriesStyle); | ||
|
||
export const AreaSeriesComponent = ({ index, groupId, visData }: AreaSeriesComponentProps) => ( | ||
<AreaSeries | ||
id={index + visData.label} | ||
groupId={groupId} | ||
name={visData.label} | ||
xScaleType={ScaleType.Time} | ||
yScaleType={ScaleType.Linear} | ||
xAccessor={0} | ||
yAccessors={[1]} | ||
data={visData.data} | ||
sortIndex={index} | ||
color={visData.color} | ||
stackAccessors={visData.stack ? [0] : undefined} | ||
areaSeriesStyle={getAreaSeriesStyle(visData)} | ||
/> | ||
); |
58 changes: 58 additions & 0 deletions
58
src/plugins/vis_type_timelion/public/components/series/bar.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,58 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { BarSeries, ScaleType, BarSeriesStyle } from '@elastic/charts'; | ||
import type { VisSeries } from '../../../common/vis_data'; | ||
|
||
interface BarSeriesComponentProps { | ||
index: number; | ||
visData: VisSeries; | ||
groupId: string; | ||
} | ||
|
||
const getBarSeriesStyle = ({ color, bars }: BarSeriesComponentProps['visData']) => { | ||
let opacity = bars.fill ?? 1; | ||
|
||
if (opacity < 0) { | ||
opacity = 0; | ||
} else if (opacity > 1) { | ||
opacity = 1; | ||
} | ||
|
||
return { | ||
rectBorder: { | ||
stroke: color, | ||
strokeWidth: Math.max(1, bars.lineWidth ? Math.ceil(bars.lineWidth / 2) : 1), | ||
visible: true, | ||
}, | ||
rect: { | ||
fill: color, | ||
opacity, | ||
widthPixel: 1, | ||
}, | ||
} as BarSeriesStyle; | ||
}; | ||
|
||
export const BarSeriesComponent = ({ index, groupId, visData }: BarSeriesComponentProps) => ( | ||
<BarSeries | ||
id={index + visData.label} | ||
groupId={groupId} | ||
name={visData.label} | ||
xScaleType={ScaleType.Time} | ||
yScaleType={ScaleType.Linear} | ||
xAccessor={0} | ||
yAccessors={[1]} | ||
data={visData.data} | ||
sortIndex={index} | ||
enableHistogramMode={false} | ||
color={visData.color} | ||
stackAccessors={visData.stack ? [0] : undefined} | ||
barSeriesStyle={getBarSeriesStyle(visData)} | ||
/> | ||
); |
10 changes: 10 additions & 0 deletions
10
src/plugins/vis_type_timelion/public/components/series/index.ts
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,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { BarSeriesComponent } from './bar'; | ||
export { AreaSeriesComponent } from './area'; |
56 changes: 3 additions & 53 deletions
56
src/plugins/vis_type_timelion/public/components/timelion_vis.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 |
---|---|---|
@@ -1,60 +1,10 @@ | ||
.timChart { | ||
.timelionChart { | ||
height: 100%; | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
|
||
// Custom Jquery FLOT / schema selectors | ||
// Cannot change at the moment | ||
|
||
.chart-top-title { | ||
@include euiFontSizeXS; | ||
flex: 0; | ||
text-align: center; | ||
font-weight: $euiFontWeightBold; | ||
} | ||
|
||
.chart-canvas { | ||
min-width: 100%; | ||
flex: 1; | ||
overflow: hidden; | ||
} | ||
|
||
.legendLabel { | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
overflow-x: hidden; | ||
line-height: normal; | ||
} | ||
|
||
.legendColorBox { | ||
vertical-align: middle; | ||
} | ||
|
||
.ngLegendValue { | ||
color: $euiTextColor; | ||
cursor: pointer; | ||
|
||
&:focus, | ||
&:hover { | ||
text-decoration: underline; | ||
} | ||
} | ||
|
||
.ngLegendValueNumber { | ||
margin-left: $euiSizeXS; | ||
margin-right: $euiSizeXS; | ||
font-weight: $euiFontWeightBold; | ||
} | ||
|
||
.flot-tick-label { | ||
font-size: $euiFontSizeXS; | ||
color: $euiColorDarkShade; | ||
} | ||
} | ||
|
||
.timChart__legendCaption { | ||
color: $euiTextColor; | ||
white-space: nowrap; | ||
font-weight: $euiFontWeightBold; | ||
.timelionChart__topTitle { | ||
text-align: center; | ||
} |
Oops, something went wrong.