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

Charts plugin (combining ui/color_maps and EuiUtils) #55469

Merged
merged 67 commits into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
7b892cc
Initial shim of kbn_vislib_vis_types
nickofthyme Dec 18, 2019
ab037a5
Move vislib into kbn_vislib_vis_types plugin
nickofthyme Dec 19, 2019
166665f
Fix import errors in test files
nickofthyme Dec 19, 2019
de9ef60
Fix dashboard style issue
nickofthyme Dec 19, 2019
8775808
Fix Internationalization check
nickofthyme Dec 19, 2019
73713fa
Fix jest test
nickofthyme Dec 20, 2019
26d6fc0
Merge branch 'master' into kpm/kbn_vislib_vis_types
nickofthyme Dec 20, 2019
17c667b
Convert remaining plugin files to typescript
nickofthyme Dec 20, 2019
e21c52e
Fix mappedColors import
nickofthyme Dec 20, 2019
e11a761
Move ui/ and plugins/ services and imports to legacy file
nickofthyme Dec 20, 2019
b416b5e
Remove none type changes
nickofthyme Dec 20, 2019
73195f9
Merge branch 'master' into kpm/kbn_vislib_vis_types
nickofthyme Dec 20, 2019
216365e
Fix jest mock imports
nickofthyme Dec 21, 2019
607242c
remove unnecessary persisted_state imports
nickofthyme Dec 21, 2019
dc1668d
Remove angular dependency from vislib tooltip and move into __Legacy
nickofthyme Dec 27, 2019
d58a943
Merge branch 'master' into kpm/kbn_vislib_vis_types
nickofthyme Dec 27, 2019
f94e179
Fix linting errors
nickofthyme Dec 27, 2019
2d383d3
Fix linting errors
nickofthyme Dec 27, 2019
ba6eea9
Update jest snapshots
nickofthyme Dec 27, 2019
ec8b095
Migrate remaining stateful deps to top-level
nickofthyme Jan 2, 2020
e918df2
Fix broken vislib mocha tests after removing Private instance
nickofthyme Jan 2, 2020
48f4958
Merge branch 'master' into kpm/kbn_vislib_vis_types
nickofthyme Jan 2, 2020
e605747
Merge branch 'master' into kpm/kbn_vislib_vis_types
elasticmachine Jan 6, 2020
a0a721e
Update .sass-lint.yml
nickofthyme Jan 9, 2020
e03d81c
address pr comments
nickofthyme Jan 10, 2020
d54759b
Rename vis to vis_type_vislib
nickofthyme Jan 10, 2020
790c9bc
Merge branch 'master' into kpm/kbn_vislib_vis_types
elasticmachine Jan 10, 2020
0f7dca3
Merge branch 'master' into kpm/kbn_vislib_vis_types
nickofthyme Jan 13, 2020
cc508cc
Remove angular dependencey from vis/tooltip
nickofthyme Jan 15, 2020
b6f3678
Move tooltip logic into vislib
nickofthyme Jan 15, 2020
44bf4bc
Remove and fix all ngMock refs in vislib tests
nickofthyme Jan 15, 2020
232d7b3
Merge branch 'master' into kpm/kbn_vislib_vis_types
nickofthyme Jan 15, 2020
4b08f60
Merge branch 'kpm/kbn_vislib_vis_types' into kpm/de-ang-tooltips
nickofthyme Jan 15, 2020
44345e3
Add numeral to renovate config
nickofthyme Jan 15, 2020
0dfa11b
fix i18n errors and namespace naming
nickofthyme Jan 16, 2020
0a0f4dd
Merge branch 'master' into kpm/de-ang-tooltips
nickofthyme Jan 16, 2020
da90152
Add vis_type_vislib to codeowners
nickofthyme Jan 16, 2020
788ffd9
Move vis_legend into vislib and fix errors
nickofthyme Jan 16, 2020
330976d
Update legend directory naming
nickofthyme Jan 16, 2020
6d8b5fe
missed naming change
nickofthyme Jan 16, 2020
5673187
Fix remaining i18n errors
nickofthyme Jan 16, 2020
6818f49
Fix vis_type_vislib/public imports to be only top-level
nickofthyme Jan 16, 2020
5facffd
Fix jest test mock path
nickofthyme Jan 16, 2020
d84a9ca
Update snapshots
nickofthyme Jan 16, 2020
40723d5
Fix karma test errors
nickofthyme Jan 17, 2020
3eb71dc
Merge branch 'master' into kpm/de-ang-tooltips
nickofthyme Jan 17, 2020
38a0fd7
Fix null checks issue
nickofthyme Jan 17, 2020
b8af4c6
Merge branch 'master' into kpm/de-ang-tooltips
nickofthyme Jan 17, 2020
fbb3cc5
Combine ui/color_maps and EuiUtils into new Charts plugin
nickofthyme Jan 21, 2020
086b8cb
Merge branch 'master' into kpm/charts-plugin
nickofthyme Jan 21, 2020
531ae66
Merge branch 'master' into kpm/charts-plugin
nickofthyme Jan 22, 2020
70b2c65
Fix functional tests errors
nickofthyme Jan 22, 2020
01cfee2
Fix i18n errors
nickofthyme Jan 22, 2020
1e8eaae
Fix karma tests
nickofthyme Jan 22, 2020
1ac7f63
Move and jestify heatMapColors tests
nickofthyme Jan 22, 2020
de679e1
Convert remaining js files to ts
nickofthyme Jan 22, 2020
3163a45
Fix jest test and add charts plugin mock
nickofthyme Jan 23, 2020
6b00cea
Merge branch 'master' into kpm/charts-plugin
nickofthyme Jan 23, 2020
efccb73
Move vis/color to Charts plugin
nickofthyme Jan 23, 2020
6cca596
Fix consumers and tests for Charts#color service
nickofthyme Jan 23, 2020
b6378b7
Update missed visTypeVislib naming
nickofthyme Jan 24, 2020
7159711
Move static charts methods to top-level exports
nickofthyme Jan 24, 2020
9449adb
Merge branch 'master' into kpm/charts-plugin
nickofthyme Jan 24, 2020
be4fb9f
Fix remaining pr comments
nickofthyme Jan 24, 2020
de77fef
Fix type check errors
nickofthyme Jan 24, 2020
52344b6
Merge branch 'master' into kpm/charts-plugin
nickofthyme Jan 27, 2020
8c1da89
Merge branch 'master' into kpm/charts-plugin
nickofthyme Jan 27, 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
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"embeddableExamples": "examples/embeddable_examples",
"share": "src/plugins/share",
"home": "src/plugins/home",
"charts": "src/plugins/charts",
"esUi": "src/plugins/es_ui_shared",
"devTools": "src/plugins/dev_tools",
"expressions": "src/plugins/expressions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import {
} from 'src/plugins/data/public';
import { createSavedSearchesService } from './saved_searches';
import { DiscoverStartPlugins } from './plugin';
import { EuiUtilsStart } from '../../../../../plugins/eui_utils/public';
import { SharePluginStart } from '../../../../../plugins/share/public';
import { SavedSearch } from './np_ready/types';
import { DocViewsRegistry } from './np_ready/doc_views/doc_views_registry';
import { ChartsPluginStart } from '../../../../../plugins/charts/public';

export interface DiscoverServices {
addBasePath: (path: string) => string;
Expand All @@ -45,7 +45,7 @@ export interface DiscoverServices {
data: DataPublicPluginStart;
docLinks: DocLinksStart;
docViewsRegistry: DocViewsRegistry;
eui_utils: EuiUtilsStart;
theme: ChartsPluginStart['theme'];
filterManager: FilterManager;
indexPatterns: IndexPatternsContract;
inspector: unknown;
Expand Down Expand Up @@ -77,7 +77,7 @@ export async function buildServices(
data: plugins.data,
docLinks: core.docLinks,
docViewsRegistry,
eui_utils: plugins.eui_utils,
theme: plugins.charts.theme,
filterManager: plugins.data.query.filterManager,
getSavedSearchById: async (id: string) => savedObjectService.get(id),
getSavedSearchUrlById: async (id: string) => savedObjectService.urlFor(id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ export class DiscoverHistogram extends Component<DiscoverHistogramProps, Discove

private subscription?: Subscription;
public state = {
chartsTheme: getServices().eui_utils.getChartsThemeDefault(),
chartsTheme: getServices().theme.chartsDefaultTheme,
};

componentDidMount() {
this.subscription = getServices()
.eui_utils.getChartsTheme$()
.subscribe((chartsTheme: EuiChartThemeType['theme']) => this.setState({ chartsTheme }));
this.subscription = getServices().theme.chartsTheme$.subscribe(
(chartsTheme: EuiChartThemeType['theme']) => this.setState({ chartsTheme })
);
}

componentWillUnmount() {
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/kibana/public/discover/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { IEmbeddableStart, IEmbeddableSetup } from '../../../../../plugins/embed
import { getInnerAngularModule, getInnerAngularModuleEmbeddable } from './get_inner_angular';
import { setAngularModule, setServices } from './kibana_services';
import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public';
import { EuiUtilsStart } from '../../../../../plugins/eui_utils/public';
import { ChartsPluginStart } from '../../../../../plugins/charts/public';
import { buildServices } from './build_services';
import { SharePluginStart } from '../../../../../plugins/share/public';
import { KibanaLegacySetup } from '../../../../../plugins/kibana_legacy/public';
Expand Down Expand Up @@ -56,7 +56,7 @@ export interface DiscoverStartPlugins {
uiActions: IUiActionsStart;
embeddable: IEmbeddableStart;
navigation: NavigationStart;
eui_utils: EuiUtilsStart;
charts: ChartsPluginStart;
data: DataPublicPluginStart;
share: SharePluginStart;
inspector: any;
Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/public/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import './visualize/legacy';
import './dashboard/legacy';
import './management';
import './dev_tools';
import 'ui/color_maps';
import 'ui/agg_response';
import 'ui/agg_types';
import { showAppRedirectNotification } from 'ui/notify';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import _ from 'lodash';
import d3 from 'd3';
import { i18n } from '@kbn/i18n';
import { KibanaMapLayer } from 'ui/vis/map/kibana_map_layer';
import { truncatedColorMaps } from 'ui/color_maps';
import * as topojson from 'topojson-client';
import { toastNotifications } from 'ui/notify';
import * as colorUtil from 'ui/vis/map/color_util';

import { truncatedColorMaps } from '../../../../plugins/charts/public';

const EMPTY_STYLE = {
weight: 1,
opacity: 0.6,
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/region_map/public/region_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import React from 'react';
import { i18n } from '@kbn/i18n';
import { Schemas } from 'ui/vis/editors/default/schemas';
import { truncatedColorSchemas as colorSchemas } from 'ui/color_maps';
import { mapToLayerWithId } from './util';
import { createRegionMapVisualization } from './region_map_visualization';
import { Status } from '../../visualizations/public';
import { RegionMapOptions } from './components/region_map_options';
import { truncatedColorSchemas } from '../../../../plugins/charts/public';

// TODO: reference to TILE_MAP plugin should be removed
import { ORIGIN } from '../../tile_map/common/origin';
Expand Down Expand Up @@ -60,7 +60,7 @@ provided base maps, or add your own. Darker colors represent higher values.',
editorConfig: {
optionsTemplate: props => <RegionMapOptions {...props} serviceSettings={serviceSettings} />,
collections: {
colorSchemas,
colorSchemas: truncatedColorSchemas,
vectorLayers: [],
tmsLayers: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import { i18n } from '@kbn/i18n';
import ChoroplethLayer from './choropleth_layer';
import { truncatedColorMaps } from 'ui/color_maps';
import { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities';
import { toastNotifications } from 'ui/notify';

import { TileMapTooltipFormatter } from './tooltip_formatter';
import { truncatedColorMaps } from '../../../../plugins/charts/public';

// TODO: reference to TILE_MAP plugin should be removed
import { BaseMapsVisualizationProvider } from '../../tile_map/public/base_maps_visualization';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import _ from 'lodash';
import d3 from 'd3';
import $ from 'jquery';
import { EventEmitter } from 'events';
import { truncatedColorMaps } from 'ui/color_maps';
import * as colorUtil from 'ui/vis/map/color_util';

import { truncatedColorMaps } from '../../../../../plugins/charts/public';

export class ScaledCirclesMarkers extends EventEmitter {
constructor(
featureCollection,
Expand Down Expand Up @@ -87,7 +88,7 @@ export class ScaledCirclesMarkers extends EventEmitter {

const quantizeDomain = min !== max ? [min, max] : d3.scale.quantize().domain();

this._legendColors = makeLegendColors(this._colorRamp);
this._legendColors = this.getLegendColors();
this._legendQuantizer = d3.scale
.quantize()
.domain(quantizeDomain)
Expand Down Expand Up @@ -222,11 +223,11 @@ export class ScaledCirclesMarkers extends EventEmitter {
getBounds() {
return this._leafletLayer.getBounds();
}
}

function makeLegendColors(colorRampKey) {
const colorRamp = _.get(truncatedColorMaps[colorRampKey], 'value');
return colorUtil.getLegendColors(colorRamp);
getLegendColors() {
const colorRamp = _.get(truncatedColorMaps[this._colorRamp], 'value');
return colorUtil.getLegendColors(colorRamp);
}
}

function makeColorDarker(color) {
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/tile_map/public/tile_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import React from 'react';
import { i18n } from '@kbn/i18n';

import { Schemas } from 'ui/vis/editors/default/schemas';
import { truncatedColorSchemas as colorSchemas } from 'ui/color_maps';
import { convertToGeoJson } from 'ui/vis/map/convert_to_geojson';

import { createTileMapVisualization } from './tile_map_visualization';
import { Status } from '../../visualizations/public';
import { TileMapOptions } from './components/tile_map_options';
import { MapTypes } from './map_types';
import { supportsCssFilters } from './css_filters';
import { truncatedColorSchemas } from '../../../../plugins/charts/public';

export function createTileMapTypeDefinition(dependencies) {
const CoordinateMapsVisualization = createTileMapVisualization(dependencies);
Expand Down Expand Up @@ -63,7 +63,7 @@ export function createTileMapTypeDefinition(dependencies) {
responseHandler: convertToGeoJson,
editorConfig: {
collections: {
colorSchemas,
colorSchemas: truncatedColorSchemas,
legendPositions: [
{
value: 'bottomleft',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import React from 'react';
import { shallow } from 'enzyme';

import { MetricVisComponent } from './metric_vis_component';
import { Vis } from '../legacy_imports';
import { MetricVisComponent, MetricVisComponentProps } from './metric_vis_component';

jest.mock('ui/new_platform');

type Props = MetricVisComponent['props'];
type Props = MetricVisComponentProps;

const baseVisData = {
columns: [{ id: 'col-0', name: 'Count' }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ import React, { Component } from 'react';

import { isColorDark } from '@elastic/eui';

import { getHeatmapColors, getFormat, Vis } from '../legacy_imports';
import { getFormat, Vis } from '../legacy_imports';
import { MetricVisValue } from './metric_vis_value';
import { fieldFormats } from '../../../../../plugins/data/public';
import { Context } from '../metric_vis_fn';
import { KibanaDatatable } from '../../../../../plugins/expressions/public';
import { getHeatmapColors } from '../../../../../plugins/charts/public';
import { VisParams, MetricVisMetric } from '../types';
import { SchemaConfig } from '../../../visualizations/public';

interface MetricVisComponentProps {
export interface MetricVisComponentProps {
visParams: VisParams;
visData: Context;
vis: Vis;
Expand All @@ -50,7 +51,6 @@ export class MetricVisComponent extends Component<MetricVisComponentProps> {
const to = isPercentageMode ? Math.round((100 * range.to) / max) : range.to;
labels.push(`${from} - ${to}`);
});

return labels;
}

Expand Down
1 change: 1 addition & 0 deletions src/legacy/core_plugins/vis_type_metric/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { plugin } from '.';
const plugins: Readonly<MetricVisPluginSetupDependencies> = {
expressions: npSetup.plugins.expressions,
visualizations: visualizationsSetup,
charts: npSetup.plugins.charts,
};

const pluginInstance = plugin({} as PluginInitializerContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/

export { Vis, VisParams } from 'ui/vis';
export { vislibColorMaps, colorSchemas, ColorSchemas } from 'ui/color_maps';
export { getHeatmapColors } from 'ui/color_maps';
export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities';
export { VisOptionsProps } from 'ui/vis/editors/default';
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/

import { createMetricVisFn } from './metric_vis_fn';

// eslint-disable-next-line
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { functionWrapper } from '../../../../plugins/expressions/public/functions/tests/utils';

jest.mock('ui/new_platform');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import { i18n } from '@kbn/i18n';

import { vislibColorMaps, ColorSchemas } from './legacy_imports';
import {
ExpressionFunction,
KibanaDatatable,
Expand All @@ -29,6 +28,7 @@ import {
} from '../../../../plugins/expressions/public';
import { ColorModes } from '../../vis_type_vislib/public';
import { visType, DimensionsVisParam, VisParams } from './types';
import { ColorSchemas, vislibColorMaps } from '../../../../plugins/charts/public';

export type Context = KibanaDatatable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ import {
setup as visualizationsSetup,
start as visualizationsStart,
} from '../../visualizations/public/np_ready/public/legacy';
import { metricVisTypeDefinition } from './metric_vis_type';
import { createMetricVisTypeDefinition } from './metric_vis_type';

jest.mock('ui/new_platform');

describe('metric_vis - createMetricVisTypeDefinition', () => {
let vis: Vis;

beforeAll(() => {
visualizationsSetup.types.createReactVisualization(metricVisTypeDefinition);
visualizationsSetup.types.createReactVisualization(createMetricVisTypeDefinition());
(npStart.plugins.data.fieldFormats.getType as jest.Mock).mockImplementation(() => {
return fieldFormats.UrlFormat;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import { i18n } from '@kbn/i18n';
import { MetricVisComponent } from './components/metric_vis_component';
import { MetricVisOptions } from './components/metric_vis_options';
import { ColorModes } from '../../vis_type_vislib/public';
import { Schemas, AggGroupNames, colorSchemas, ColorSchemas } from './legacy_imports';
import { Schemas, AggGroupNames } from './legacy_imports';
import { ColorSchemas, colorSchemas } from '../../../../plugins/charts/public';

export const metricVisTypeDefinition = {
export const createMetricVisTypeDefinition = () => ({
name: 'metric',
title: i18n.translate('visTypeMetric.metricTitle', { defaultMessage: 'Metric' }),
icon: 'visMetric',
Expand Down Expand Up @@ -121,4 +122,4 @@ export const metricVisTypeDefinition = {
},
]),
},
};
});
11 changes: 8 additions & 3 deletions src/legacy/core_plugins/vis_type_metric/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressio
import { VisualizationsSetup } from '../../visualizations/public';

import { createMetricVisFn } from './metric_vis_fn';
import { metricVisTypeDefinition } from './metric_vis_type';
import { createMetricVisTypeDefinition } from './metric_vis_type';
import { ChartsPluginSetup } from '../../../../plugins/charts/public';

/** @internal */
export interface MetricVisPluginSetupDependencies {
expressions: ReturnType<ExpressionsPublicPlugin['setup']>;
visualizations: VisualizationsSetup;
charts: ChartsPluginSetup;
}

/** @internal */
Expand All @@ -38,9 +40,12 @@ export class MetricVisPlugin implements Plugin<void, void> {
this.initializerContext = initializerContext;
}

public setup(core: CoreSetup, { expressions, visualizations }: MetricVisPluginSetupDependencies) {
public setup(
core: CoreSetup,
{ expressions, visualizations, charts }: MetricVisPluginSetupDependencies
) {
expressions.registerFunction(createMetricVisFn);
visualizations.types.createReactVisualization(metricVisTypeDefinition);
visualizations.types.createReactVisualization(createMetricVisTypeDefinition());
}

public start(core: CoreStart) {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/vis_type_metric/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/

import { ColorSchemas } from './legacy_imports';
import { Range } from '../../../../plugins/expressions/public';
import { SchemaConfig } from '../../visualizations/public';
import { ColorModes, Labels, Style } from '../../vis_type_vislib/public';
import { ColorSchemas } from '../../../../plugins/charts/public';

export const visType = 'metric';

Expand Down
Loading