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

Vislib visualization renderer #80744

Merged
merged 28 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c1429e0
refactor vis_type_vislib to use async vis renderer
nickofthyme Oct 15, 2020
3307b26
fix resizing issue
nickofthyme Oct 15, 2020
4fca736
Merge branch 'master' into vislib-renderer
nickofthyme Oct 16, 2020
70c3584
fix resizing issue
nickofthyme Oct 16, 2020
d4ae5f0
Merge remote-tracking branch 'upstream/master' into vislib-renderer
nickofthyme Oct 16, 2020
439afd5
fix jest tests
nickofthyme Oct 16, 2020
a940e96
wrap vislib controller in react component
nickofthyme Oct 21, 2020
263ae4f
fix dashboard vis reloading
nickofthyme Oct 21, 2020
c100a82
Merge remote-tracking branch 'upstream/master' into vislib-renderer
nickofthyme Oct 21, 2020
0d7ab3f
fix error selector and color updating
nickofthyme Oct 21, 2020
92dc916
refactor ast to pass proper interval
nickofthyme Oct 21, 2020
28c3224
move old vislib tests
nickofthyme Oct 21, 2020
6a64754
fix type errors
nickofthyme Oct 21, 2020
c9121f7
Merge remote-tracking branch 'upstream/master' into vislib-renderer
Oct 27, 2020
aa9b053
Refactoring
Oct 27, 2020
1dc6151
Move visError styles into visualizations
Oct 27, 2020
bc81480
Correctly handle uiState updates
Oct 27, 2020
4fe6472
Fix overflow in gauge/goal visulaizations
Oct 27, 2020
caedcff
Lazy load editor components
Oct 28, 2020
d49aa2d
Merge remote-tracking branch 'upstream/master' into vislib-renderer
Oct 28, 2020
51c5c3c
Minor fixes
Oct 28, 2020
00b3fc8
move styles to legend
nickofthyme Oct 28, 2020
8a115a5
fix unknown types and remove lodash.get
nickofthyme Oct 29, 2020
96cd1c7
Merge branch 'master' into vislib-renderer
nickofthyme Oct 29, 2020
04764b1
fix type error in jest tests
nickofthyme Oct 29, 2020
a7d06e8
Merge branch 'master' into vislib-renderer
kibanamachine Oct 29, 2020
e1d44f4
fix noResults state
nickofthyme Oct 29, 2020
90751e4
fix type definition
nickofthyme Oct 29, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const TagCloudChart = ({
const visController = useRef<any>(null);

useEffect(() => {
visController.current = new TagCloudVisualization(chartDiv.current, colors, fireEvent);
if (chartDiv.current) {
visController.current = new TagCloudVisualization(chartDiv.current, colors, fireEvent);
}
return () => {
visController.current.destroy();
visController.current = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ export const getTimelionVisRenderer: (
const [seriesList] = visData.sheet;
const showNoResult = !seriesList || !seriesList.list.length;

if (showNoResult) {
// send the render complete event when there is no data to show
// to notify that a chart is updated
handlers.done();
}

render(
<VisualizationContainer handlers={handlers} showNoResult={showNoResult}>
<KibanaContextProvider services={{ ...deps }}>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 7 additions & 12 deletions src/plugins/vis_type_vislib/public/area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,20 @@ import {
getConfigCollections,
} from './utils/collections';
import { getAreaOptionTabs, countLabel } from './utils/common_config';
import { createVislibVisController } from './vis_controller';
import { VisTypeVislibDependencies } from './plugin';
import { Rotates } from '../../charts/public';
import { VIS_EVENT_TO_TRIGGER } from '../../../plugins/visualizations/public';
import { BaseVisTypeOptions, VIS_EVENT_TO_TRIGGER } from '../../../plugins/visualizations/public';
import { toExpressionAst } from './to_ast';
import { BasicVislibParams } from './types';

export const createAreaVisTypeDefinition = (deps: VisTypeVislibDependencies) => ({
export const areaVisTypeDefinition: BaseVisTypeOptions<BasicVislibParams> = {
name: 'area',
title: i18n.translate('visTypeVislib.area.areaTitle', { defaultMessage: 'Area' }),
icon: 'visArea',
description: i18n.translate('visTypeVislib.area.areaDescription', {
defaultMessage: 'Emphasize the quantity beneath a line chart',
}),
visualization: createVislibVisController(deps),
getSupportedTriggers: () => {
return [VIS_EVENT_TO_TRIGGER.filter, VIS_EVENT_TO_TRIGGER.brush];
},
getSupportedTriggers: () => [VIS_EVENT_TO_TRIGGER.filter, VIS_EVENT_TO_TRIGGER.brush],
toExpressionAst,
visConfig: {
defaults: {
type: 'area',
Expand Down Expand Up @@ -131,9 +129,6 @@ export const createAreaVisTypeDefinition = (deps: VisTypeVislibDependencies) =>
labels: {},
},
},
events: {
brush: { disabled: false },
},
editorConfig: {
collections: getConfigCollections(),
optionTabs: getAreaOptionTabs(),
Expand Down Expand Up @@ -190,4 +185,4 @@ export const createAreaVisTypeDefinition = (deps: VisTypeVislibDependencies) =>
},
]),
},
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ function GaugeOptions(props: VisOptionsProps<GaugeVisParams>) {
);
}

export { GaugeOptions };
// default export required for React.Lazy
// eslint-disable-next-line import/no-default-export
export { GaugeOptions as default };
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,6 @@ function HeatmapOptions(props: VisOptionsProps<HeatmapVisParams>) {
);
}

export { HeatmapOptions };
// default export required for React.Lazy
// eslint-disable-next-line import/no-default-export
export { HeatmapOptions as default };
51 changes: 51 additions & 0 deletions src/plugins/vis_type_vislib/public/components/options/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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 React, { lazy } from 'react';

import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
import { ValidationVisOptionsProps } from '../common';
import { GaugeVisParams } from '../../gauge';
import { PieVisParams } from '../../pie';
import { BasicVislibParams } from '../../types';
import { HeatmapVisParams } from '../../heatmap';

const GaugeOptionsLazy = lazy(() => import('./gauge'));
const PieOptionsLazy = lazy(() => import('./pie'));
const PointSeriesOptionsLazy = lazy(() => import('./point_series'));
const HeatmapOptionsLazy = lazy(() => import('./heatmap'));
const MetricsAxisOptionsLazy = lazy(() => import('./metrics_axes'));

export const GaugeOptions = (props: VisOptionsProps<GaugeVisParams>) => (
<GaugeOptionsLazy {...props} />
);

export const PieOptions = (props: VisOptionsProps<PieVisParams>) => <PieOptionsLazy {...props} />;

export const PointSeriesOptions = (props: ValidationVisOptionsProps<BasicVislibParams>) => (
<PointSeriesOptionsLazy {...props} />
);

export const HeatmapOptions = (props: VisOptionsProps<HeatmapVisParams>) => (
<HeatmapOptionsLazy {...props} />
);

export const MetricsAxisOptions = (props: ValidationVisOptionsProps<BasicVislibParams>) => (
<MetricsAxisOptionsLazy {...props} />
);
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';
import { mount, shallow } from 'enzyme';

import { IAggConfig, IAggType } from 'src/plugins/data/public';
import { MetricsAxisOptions } from './index';
import MetricsAxisOptions from './index';
import { BasicVislibParams, SeriesParam, ValueAxis } from '../../../types';
import { ValidationVisOptionsProps } from '../../common';
import { Positions } from '../../../utils/collections';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,6 @@ function MetricsAxisOptions(props: ValidationVisOptionsProps<BasicVislibParams>)
) : null;
}

export { MetricsAxisOptions };
// default export required for React.Lazy
// eslint-disable-next-line import/no-default-export
export { MetricsAxisOptions as default };
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,6 @@ function PieOptions(props: VisOptionsProps<PieVisParams>) {
);
}

export { PieOptions };
// default export required for React.Lazy
// eslint-disable-next-line import/no-default-export
export { PieOptions as default };
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
* under the License.
*/

export { PointSeriesOptions } from './point_series';
// default export required for React.Lazy
// eslint-disable-next-line import/no-default-export
export { PointSeriesOptions as default } from './point_series';
11 changes: 6 additions & 5 deletions src/plugins/vis_type_vislib/public/gauge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import { AggGroupNames } from '../../data/public';
import { GaugeOptions } from './components/options';
import { getGaugeCollections, Alignments, GaugeTypes } from './utils/collections';
import { ColorModes, ColorSchemas, ColorSchemaParams, Labels, Style } from '../../charts/public';
import { createVislibVisController } from './vis_controller';
import { VisTypeVislibDependencies } from './plugin';
import { toExpressionAst } from './to_ast';
import { BaseVisTypeOptions } from '../../visualizations/public';
import { BasicVislibParams } from './types';

export interface Gauge extends ColorSchemaParams {
backStyle: 'Full';
Expand Down Expand Up @@ -55,14 +56,15 @@ export interface GaugeVisParams {
gauge: Gauge;
}

export const createGaugeVisTypeDefinition = (deps: VisTypeVislibDependencies) => ({
export const gaugeVisTypeDefinition: BaseVisTypeOptions<BasicVislibParams> = {
name: 'gauge',
title: i18n.translate('visTypeVislib.gauge.gaugeTitle', { defaultMessage: 'Gauge' }),
icon: 'visGauge',
description: i18n.translate('visTypeVislib.gauge.gaugeDescription', {
defaultMessage:
"Gauges indicate the status of a metric. Use it to show how a metric's value relates to reference threshold values.",
}),
toExpressionAst,
visConfig: {
defaults: {
type: 'gauge',
Expand Down Expand Up @@ -109,7 +111,6 @@ export const createGaugeVisTypeDefinition = (deps: VisTypeVislibDependencies) =>
},
},
},
visualization: createVislibVisController(deps),
editorConfig: {
collections: getGaugeCollections(),
optionsTemplate: GaugeOptions,
Expand Down Expand Up @@ -145,4 +146,4 @@ export const createGaugeVisTypeDefinition = (deps: VisTypeVislibDependencies) =>
]),
},
useCustomNoDataScreen: true,
});
};
11 changes: 6 additions & 5 deletions src/plugins/vis_type_vislib/public/goal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ import { i18n } from '@kbn/i18n';

import { GaugeOptions } from './components/options';
import { getGaugeCollections, GaugeTypes } from './utils/collections';
import { createVislibVisController } from './vis_controller';
import { VisTypeVislibDependencies } from './plugin';
import { ColorModes, ColorSchemas } from '../../charts/public';
import { AggGroupNames } from '../../data/public';
import { Schemas } from '../../vis_default_editor/public';
import { toExpressionAst } from './to_ast';
import { BaseVisTypeOptions } from '../../visualizations/public';
import { BasicVislibParams } from './types';

export const createGoalVisTypeDefinition = (deps: VisTypeVislibDependencies) => ({
export const goalVisTypeDefinition: BaseVisTypeOptions<BasicVislibParams> = {
name: 'goal',
title: i18n.translate('visTypeVislib.goal.goalTitle', { defaultMessage: 'Goal' }),
icon: 'visGoal',
description: i18n.translate('visTypeVislib.goal.goalDescription', {
defaultMessage: 'A goal chart indicates how close you are to your final goal.',
}),
visualization: createVislibVisController(deps),
toExpressionAst,
visConfig: {
defaults: {
addTooltip: true,
Expand Down Expand Up @@ -110,4 +111,4 @@ export const createGoalVisTypeDefinition = (deps: VisTypeVislibDependencies) =>
]),
},
useCustomNoDataScreen: true,
});
};
20 changes: 7 additions & 13 deletions src/plugins/vis_type_vislib/public/heatmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ import { RangeValues, Schemas } from '../../vis_default_editor/public';
import { AggGroupNames } from '../../data/public';
import { AxisTypes, getHeatmapCollections, Positions, ScaleTypes } from './utils/collections';
import { HeatmapOptions } from './components/options';
import { createVislibVisController } from './vis_controller';
import { TimeMarker } from './vislib/visualizations/time_marker';
import { CommonVislibParams, ValueAxis } from './types';
import { VisTypeVislibDependencies } from './plugin';
import { BasicVislibParams, CommonVislibParams, ValueAxis } from './types';
import { ColorSchemas, ColorSchemaParams } from '../../charts/public';
import { VIS_EVENT_TO_TRIGGER } from '../../../plugins/visualizations/public';
import { BaseVisTypeOptions, VIS_EVENT_TO_TRIGGER } from '../../../plugins/visualizations/public';
import { toExpressionAst } from './to_ast';

export interface HeatmapVisParams extends CommonVislibParams, ColorSchemaParams {
type: 'heatmap';
Expand All @@ -42,17 +41,15 @@ export interface HeatmapVisParams extends CommonVislibParams, ColorSchemaParams
times: TimeMarker[];
}

export const createHeatmapVisTypeDefinition = (deps: VisTypeVislibDependencies) => ({
export const heatmapVisTypeDefinition: BaseVisTypeOptions<BasicVislibParams> = {
name: 'heatmap',
title: i18n.translate('visTypeVislib.heatmap.heatmapTitle', { defaultMessage: 'Heat Map' }),
icon: 'heatmap',
description: i18n.translate('visTypeVislib.heatmap.heatmapDescription', {
defaultMessage: 'Shade cells within a matrix',
}),
getSupportedTriggers: () => {
return [VIS_EVENT_TO_TRIGGER.filter];
},
visualization: createVislibVisController(deps),
getSupportedTriggers: () => [VIS_EVENT_TO_TRIGGER.filter],
toExpressionAst,
visConfig: {
defaults: {
type: 'heatmap',
Expand Down Expand Up @@ -86,9 +83,6 @@ export const createHeatmapVisTypeDefinition = (deps: VisTypeVislibDependencies)
],
},
},
events: {
brush: { disabled: false },
},
editorConfig: {
collections: getHeatmapCollections(),
optionsTemplate: HeatmapOptions,
Expand Down Expand Up @@ -142,4 +136,4 @@ export const createHeatmapVisTypeDefinition = (deps: VisTypeVislibDependencies)
},
]),
},
});
};
Loading