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

Replace flot with elastic-chart in Timelion #81565

Merged
merged 75 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
ff810c8
First draft migrate timelion to elastic-charts
VladLasitsa Oct 23, 2020
6d7f157
Some refactoring. Added brush event.
VladLasitsa Oct 23, 2020
b888e79
Merge remote-tracking branch 'origin/#79984' into #79984
VladLasitsa Oct 26, 2020
999c2d7
Added title. Some refactoring
VladLasitsa Oct 27, 2020
f43a965
Fixed some type problems. Added logic for yaxes function
VladLasitsa Oct 29, 2020
af60792
Fixed some types, added missing functionality for yaxes
VladLasitsa Oct 30, 2020
f429afe
Fixed some types, added missing functionality for stack property
VladLasitsa Nov 2, 2020
c94a3fc
Merge branch 'master' into #79984
kibanamachine Nov 3, 2020
5cd3a48
Fixed unit test
VladLasitsa Nov 3, 2020
4b3a294
Removed unneeded code
VladLasitsa Nov 3, 2020
1e7eee7
Some refactoring
VladLasitsa Nov 4, 2020
901f8c7
Some refactoring
VladLasitsa Nov 5, 2020
5942f9b
Merge branch 'master' into #79984
kibanamachine Nov 6, 2020
60c1e11
Fixed some remarks.
VladLasitsa Nov 6, 2020
4f8c59a
Fixed some styles
VladLasitsa Nov 6, 2020
9be84d7
Added themes. Removed unneeded styles in BarSeries
VladLasitsa Nov 9, 2020
6711dac
removed unneeded code.
VladLasitsa Nov 12, 2020
6d74017
Fixed some comments
VladLasitsa Nov 16, 2020
039d3b4
Merge remote-tracking branch 'upstream/master' into #79984
VladLasitsa Nov 16, 2020
de41259
Fixed vertical cursor across Timelion visualizations of a dashboad
VladLasitsa Nov 16, 2020
63a12db
Fix some problems with styles
VladLasitsa Nov 17, 2020
2726c0c
Merge remote-tracking branch 'upstream/master' into #79984
VladLasitsa Nov 17, 2020
07181ae
Merge remote-tracking branch 'upstream/master' into #79984
VladLasitsa Nov 19, 2020
ca9aeac
Use RxJS instead of jQuery
VladLasitsa Nov 19, 2020
13033c5
Remove unneeded code
VladLasitsa Nov 24, 2020
703e3f3
Merge remote-tracking branch 'upstream/master' into #79984
VladLasitsa Nov 24, 2020
18d9c37
Fixed some problems
VladLasitsa Nov 25, 2020
53b1c08
Fixed unit test
VladLasitsa Nov 26, 2020
6c8b842
Merge branch 'master' into #79984
kibanamachine Jan 29, 2021
c2ba661
Merge branch 'master' into #79984
VladLasitsa Feb 1, 2021
aac4b77
Fix CI
VladLasitsa Feb 1, 2021
75fb061
Merge branch 'master' into #79984
kibanamachine Feb 4, 2021
24a188a
Fix eslint
VladLasitsa Feb 4, 2021
7ad545f
Merge branch 'master' into #79984
kibanamachine May 12, 2021
d369fc4
Fix some gaps
VladLasitsa May 12, 2021
035516a
Merge branch 'master' into #79984
kibanamachine May 31, 2021
15b6ec7
Fix legend columns
VladLasitsa May 31, 2021
b079e0d
Merge branch 'master' into #79984
kibanamachine Jun 7, 2021
9944016
Some fixes
VladLasitsa Jun 8, 2021
010617c
add 2 versions of Timeline app
alexwizp Jun 9, 2021
bc63434
fix CI
alexwizp Jun 9, 2021
81add31
cleanup code
alexwizp Jun 9, 2021
0bc12e1
fix CI
alexwizp Jun 11, 2021
6f33935
fix legend position
alexwizp Jun 11, 2021
56c0760
fix some cases
alexwizp Jun 11, 2021
f52fd07
fix some cases
alexwizp Jun 14, 2021
cd2cb7e
remove extra casting
alexwizp Jun 14, 2021
e4c3b96
cleanup code
alexwizp Jun 15, 2021
451054c
fix issue with static
alexwizp Jun 15, 2021
1898b8d
fix header formatter
alexwizp Jun 15, 2021
a1edcf5
fix points
alexwizp Jun 15, 2021
641ffab
Merge remote-tracking branch 'upstream/master' into #79984
alexwizp Jun 15, 2021
d330823
fix ts error
alexwizp Jun 16, 2021
f087902
Fix yaxis behavior
VladLasitsa Jun 16, 2021
e4397bb
Merge branch 'master' into #79984
kibanamachine Jun 16, 2021
9af9dcb
Fix some case with yaxis
VladLasitsa Jun 16, 2021
0ca56a1
Merge remote-tracking branch 'upstream/master' into #79984
alexwizp Jun 18, 2021
a84fa78
Merge branch 'master' into #79984
kibanamachine Jun 21, 2021
7ca06e1
Merge branch 'master' into #79984
kibanamachine Jun 21, 2021
022b8a5
Merge branch 'master' into #79984
kibanamachine Jun 22, 2021
0eb286f
Add deprecation message and update asciidoc
VladLasitsa Jun 22, 2021
574d045
Merge branch 'master' into #79984
kibanamachine Jun 24, 2021
572df6e
Fix title
VladLasitsa Jun 28, 2021
b027add
Merge branch 'master' into #79984
kibanamachine Jun 28, 2021
edab9a6
Merge branch 'master' into #79984
kibanamachine Jun 30, 2021
5082a31
Merge branch 'master' into #79984
kibanamachine Jul 1, 2021
8dd67ff
Merge branch 'master' into #79984
kibanamachine Jul 5, 2021
33c9b70
Merge branch 'master' into #79984
kibanamachine Jul 6, 2021
4d5292b
Merge branch 'master' into #79984
kibanamachine Jul 13, 2021
eac6a41
Merge branch 'master' into #79984
kibanamachine Jul 14, 2021
757e95a
Merge branch 'master' into #79984
kibanamachine Jul 20, 2021
56a94b4
Merge branch 'master' into #79984
kibanamachine Jul 27, 2021
c95ef4b
Merge remote-tracking branch 'upstream/master' into #79984
VladLasitsa Jul 29, 2021
bf63108
some text improvements
VladLasitsa Jul 29, 2021
acb6bce
Merge branch 'master' into #79984
kibanamachine Aug 2, 2021
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
4 changes: 4 additions & 0 deletions docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ Shows the Timelion tutorial to users when they first open the Timelion app.
Used for calculating automatic intervals in visualizations, this is the number
of buckets to try to represent.

[[timelion-legacyChartsLibrary]]`timelion:legacyChartsLibrary`::
Enables the legacy charts library for timelion charts in Visualize.


[float]
[[kibana-visualization-settings]]
==== Visualization
Expand Down
1 change: 1 addition & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export class DocLinksService {
indexManagement: `${ELASTICSEARCH_DOCS}index-mgmt.html`,
kibanaSearchSettings: `${KIBANA_DOCS}advanced-options.html#kibana-search-settings`,
visualizationSettings: `${KIBANA_DOCS}advanced-options.html#kibana-visualization-settings`,
timelionSettings: `${KIBANA_DOCS}advanced-options.html#kibana-timelion-settings`,
},
ml: {
guide: `${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/index.html`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'text',
_meta: { description: 'Non-default value of setting.' },
},
'timelion:legacyChartsLibrary': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'timelion:target_buckets': {
type: 'long',
_meta: { description: 'Non-default value of setting.' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface UsageStats {
'visualization:tileMap:maxPrecision': number;
'csv:separator': string;
'visualization:tileMap:WMSdefaults': string;
'timelion:legacyChartsLibrary': boolean;
'timelion:target_buckets': number;
'timelion:max_buckets': number;
'timelion:es.timefield': string;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7258,6 +7258,12 @@
"description": "Non-default value of setting."
}
},
"timelion:legacyChartsLibrary": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"timelion:target_buckets": {
"type": "long",
"_meta": {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/timelion/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
registerListenEventListener,
watchMultiDecorator,
} from '../../kibana_legacy/public';
import { getTimezone } from '../../vis_type_timelion/public';
import { _LEGACY_ as visTypeTimelion } from '../../vis_type_timelion/public';
import { initCellsDirective } from './directives/cells/cells';
import { initFullscreenDirective } from './directives/fullscreen/fullscreen';
import { initFixedElementDirective } from './directives/fixed_element';
Expand Down Expand Up @@ -144,7 +144,7 @@ export function initTimelionApp(app, deps) {
$scope.updatedSheets = [];

const savedVisualizations = deps.plugins.visualizations.savedVisualizationsLoader;
const timezone = getTimezone(deps.core.uiSettings);
const timezone = visTypeTimelion.getTimezone(deps.core.uiSettings);

const defaultExpression = '.es(*)';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import _ from 'lodash';
import { parseTimelionExpressionAsync } from '../../../vis_type_timelion/public';
import { _LEGACY_ as visTypeTimelion } from '../../../vis_type_timelion/public';

export const SUGGESTION_TYPE = {
ARGUMENTS: 'arguments',
Expand Down Expand Up @@ -180,7 +180,7 @@ async function extractSuggestionsFromParsedResult(

export async function suggest(expression, functionList, cursorPosition, argValueSuggestions) {
try {
const result = await parseTimelionExpressionAsync(expression);
const result = await visTypeTimelion.parseTimelionExpressionAsync(expression);
return await extractSuggestionsFromParsedResult(
result,
cursorPosition,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/timelion/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
// styles for timelion visualization are lazy loaded only while a vis is opened
// this will duplicate styles only if both Timelion app and timelion visualization are loaded
// could be left here as it is since the Timelion app is deprecated
@import '../../vis_type_timelion/public/components/timelion_vis.scss';
@import '../../vis_type_timelion/public/legacy/timelion_vis.scss';
18 changes: 6 additions & 12 deletions src/plugins/timelion/public/panels/timechart/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ import $ from 'jquery';
import moment from 'moment-timezone';
// @ts-ignore
import observeResize from '../../lib/observe_resize';
import {
calculateInterval,
DEFAULT_TIME_FORMAT,
tickFormatters,
xaxisFormatterProvider,
generateTicksProvider,
} from '../../../../vis_type_timelion/public';
import { _LEGACY_ as visTypeTimelion } from '../../../../vis_type_timelion/public';
import { TimelionVisualizationDependencies } from '../../application';

const DEBOUNCE_DELAY = 50;
Expand All @@ -37,9 +31,9 @@ export function timechartFn(dependencies: TimelionVisualizationDependencies) {
help: 'Draw a timeseries chart',
render($scope: any, $elem: any) {
const template = '<div class="chart-top-title"></div><div class="chart-canvas"></div>';
const formatters = tickFormatters() as any;
const getxAxisFormatter = xaxisFormatterProvider(uiSettings);
const generateTicks = generateTicksProvider();
const formatters = visTypeTimelion.tickFormatters() as any;
const getxAxisFormatter = visTypeTimelion.xaxisFormatterProvider(uiSettings);
const generateTicks = visTypeTimelion.generateTicksProvider();

// TODO: I wonder if we should supply our own moment that sets this every time?
// could just use angular's injection to provide a moment service?
Expand Down Expand Up @@ -226,7 +220,7 @@ export function timechartFn(dependencies: TimelionVisualizationDependencies) {
if (legendCaption) {
legendCaption.text(
moment(pos.x).format(
_.get(dataset, '[0]._global.legend.timeFormat', DEFAULT_TIME_FORMAT)
_.get(dataset, '[0]._global.legend.timeFormat', visTypeTimelion.DEFAULT_TIME_FORMAT)
)
);
}
Expand Down Expand Up @@ -289,7 +283,7 @@ export function timechartFn(dependencies: TimelionVisualizationDependencies) {

// Get the X-axis tick format
const time = timefilter.timefilter.getBounds() as any;
const interval = calculateInterval(
const interval = visTypeTimelion.calculateInterval(
time.min.valueOf(),
time.max.valueOf(),
uiSettings.get('timelion:target_buckets') || 200,
Expand Down
18 changes: 18 additions & 0 deletions src/plugins/vis_type_timelion/common/constants.ts
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',
};
33 changes: 33 additions & 0 deletions src/plugins/vis_type_timelion/common/vis_data.ts
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;
}
2 changes: 1 addition & 1 deletion src/plugins/vis_type_timelion/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"kibanaVersion": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["visualizations", "data", "expressions"],
"requiredPlugins": ["visualizations", "data", "expressions", "charts"],
"requiredBundles": ["kibanaUtils", "kibanaReact", "visDefaultEditor"],
"owner": {
"name": "Kibana App",
Expand Down
62 changes: 62 additions & 0 deletions src/plugins/vis_type_timelion/public/components/series/area.tsx
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']) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: showLines

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 src/plugins/vis_type_timelion/public/components/series/bar.tsx
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 src/plugins/vis_type_timelion/public/components/series/index.ts
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 src/plugins/vis_type_timelion/public/components/timelion_vis.scss
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 {
VladLasitsa marked this conversation as resolved.
Show resolved Hide resolved
text-align: center;
}
Loading