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 57 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 { Chrome, 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 @@ -59,7 +59,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 @@ -40,6 +40,9 @@ import afterdatachangeandresizePng from './afterdatachangeandresize.png';
import aftercolorchangePng from './aftercolorchange.png';
import changestartupPng from './changestartup.png';
import { setup as visualizationsSetup } from '../../../visualizations/public/np_ready/public/legacy';
// TODO: Remove when converted to jest
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { colorMapsService as colorMaps } from '../../../../../plugins/charts/public/services';

import { createRegionMapVisualization } from '../region_map_visualization';
import { createRegionMapTypeDefinition } from '../region_map_type';
Expand Down Expand Up @@ -105,6 +108,7 @@ describe('RegionMapsVisualizationTests', function() {
$injector,
regionmapsConfig,
uiSettings,
colorMaps,
};

if (!visRegComplete) {
Expand Down
21 changes: 16 additions & 5 deletions src/legacy/core_plugins/region_map/public/choropleth_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ 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';
Expand Down Expand Up @@ -73,12 +72,22 @@ export default class ChoroplethLayer extends KibanaMapLayer {
}
}

constructor(name, attribution, format, showAllShapes, meta, layerConfig, serviceSettings) {
constructor(
name,
attribution,
format,
showAllShapes,
meta,
layerConfig,
serviceSettings,
colorMaps
) {
super();
this._serviceSettings = serviceSettings;
this._metrics = null;
this._joinField = null;
this._colorRamp = truncatedColorMaps[Object.keys(truncatedColorMaps)[0]].value;
this._colorRamp =
colorMaps.truncatedColorMaps[Object.keys(colorMaps.truncatedColorMaps)[0]].value;
this._lineWeight = 1;
this._tooltipFormatter = () => '';
this._attribution = attribution;
Expand Down Expand Up @@ -279,7 +288,8 @@ CORS configuration of the server permits requests from the Kibana application on
showAllData,
meta,
layerConfig,
serviceSettings
serviceSettings,
colorMaps
) {
const clonedLayer = new ChoroplethLayer(
name,
Expand All @@ -288,7 +298,8 @@ CORS configuration of the server permits requests from the Kibana application on
showAllData,
meta,
layerConfig,
serviceSettings
serviceSettings,
colorMaps
);
clonedLayer.setJoinField(this._joinField);
clonedLayer.setColorRamp(this._colorRamp);
Expand Down
1 change: 1 addition & 0 deletions src/legacy/core_plugins/region_map/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const regionmapsConfig = npSetup.core.injectedMetadata.getInjectedVar(
const plugins: Readonly<RegionMapPluginSetupDependencies> = {
expressions: npSetup.plugins.expressions,
visualizations: visualizationsSetup,
charts: npSetup.plugins.charts,

// Temporary solution
// It will be removed when all dependent services are migrated to the new platform.
Expand Down
6 changes: 5 additions & 1 deletion src/legacy/core_plugins/region_map/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ import { LegacyDependenciesPlugin, LegacyDependenciesPluginSetup } from './shim'
import { createRegionMapFn } from './region_map_fn';
// @ts-ignore
import { createRegionMapTypeDefinition } from './region_map_type';
import { ChartsPluginSetup } from '../../../../plugins/charts/public';

/** @private */
interface RegionMapVisualizationDependencies extends LegacyDependenciesPluginSetup {
uiSettings: IUiSettingsClient;
colorMaps: ChartsPluginSetup['colorMaps'];
}

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

Expand All @@ -61,9 +64,10 @@ export class RegionMapPlugin implements Plugin<Promise<void>, void> {

public async setup(
core: CoreSetup,
{ expressions, visualizations, __LEGACY }: RegionMapPluginSetupDependencies
{ expressions, visualizations, charts, __LEGACY }: RegionMapPluginSetupDependencies
) {
const visualizationDependencies: Readonly<RegionMapVisualizationDependencies> = {
colorMaps: charts.colorMaps,
uiSettings: core.uiSettings,
...(await __LEGACY.setup()),
};
Expand Down
5 changes: 2 additions & 3 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,7 +19,6 @@
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';
Expand All @@ -29,7 +28,7 @@ import { RegionMapOptions } from './components/region_map_options';
import { ORIGIN } from '../../tile_map/common/origin';

export function createRegionMapTypeDefinition(dependencies) {
const { uiSettings, regionmapsConfig, serviceSettings } = dependencies;
const { uiSettings, regionmapsConfig, serviceSettings, colorMaps } = dependencies;
const visualization = createRegionMapVisualization(dependencies);

return {
Expand Down Expand Up @@ -60,7 +59,7 @@ provided base maps, or add your own. Darker colors represent higher values.',
editorConfig: {
optionsTemplate: props => <RegionMapOptions {...props} serviceSettings={serviceSettings} />,
collections: {
colorSchemas,
colorSchemas: colorMaps.truncatedColorSchemas,
vectorLayers: [],
tmsLayers: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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';

Expand All @@ -28,7 +27,12 @@ import { TileMapTooltipFormatter } from './tooltip_formatter';
// TODO: reference to TILE_MAP plugin should be removed
import { BaseMapsVisualizationProvider } from '../../tile_map/public/base_maps_visualization';

export function createRegionMapVisualization({ serviceSettings, $injector, uiSettings }) {
export function createRegionMapVisualization({
serviceSettings,
$injector,
uiSettings,
colorMaps,
}) {
const BaseMapsVisualization = new BaseMapsVisualizationProvider(serviceSettings);
const tooltipFormatter = new TileMapTooltipFormatter($injector);

Expand Down Expand Up @@ -112,7 +116,7 @@ export function createRegionMapVisualization({ serviceSettings, $injector, uiSet
const metricFieldFormatter = getFormat(this._params.metric.format);

this._choroplethLayer.setJoinField(visParams.selectedJoinField.name);
this._choroplethLayer.setColorRamp(truncatedColorMaps[visParams.colorSchema].value);
this._choroplethLayer.setColorRamp(colorMaps.truncatedColorMaps[visParams.colorSchema].value);
this._choroplethLayer.setLineWeight(visParams.outlineWeight);
this._choroplethLayer.setTooltipFormatter(
tooltipFormatter,
Expand Down Expand Up @@ -149,7 +153,8 @@ export function createRegionMapVisualization({ serviceSettings, $injector, uiSet
showAllData,
this._params.selectedLayer.meta,
this._params.selectedLayer,
serviceSettings
serviceSettings,
colorMaps
);
} else {
this._choroplethLayer = new ChoroplethLayer(
Expand All @@ -159,7 +164,8 @@ export function createRegionMapVisualization({ serviceSettings, $injector, uiSet
showAllData,
this._params.selectedLayer.meta,
this._params.selectedLayer,
serviceSettings
serviceSettings,
colorMaps
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../../ui/public/vis/__tests__/map/e
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_desaturated';
import EMS_STYLE_DARK_MAP from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_dark';
import { setup as visualizationsSetup } from '../../../visualizations/public/np_ready/public/legacy';
// TODO: Remove when converted to jest
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { colorMapsService as colorMaps } from '../../../../../plugins/charts/public/services';

import { createTileMapVisualization } from '../tile_map_visualization';
import { createTileMapTypeDefinition } from '../tile_map_type';
Expand Down Expand Up @@ -82,6 +85,7 @@ describe('CoordinateMapsVisualizationTest', function() {
serviceSettings,
uiSettings,
$injector,
colorMaps,
};

if (!visRegComplete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import scaledCircleMarkersPng from './scaledCircleMarkers.png';
// import shadedCircleMarkersPng from './shadedCircleMarkers.png';
import { ImageComparator } from 'test_utils/image_comparator';
import GeoHashSampleData from './dummy_es_response.json';
// TODO: Mock this plugin in jest tests
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { colorMapsService } from '../../../../../plugins/charts/public/services';

describe('geohash_layer', function() {
let domNode;
Expand Down Expand Up @@ -102,7 +105,8 @@ describe('geohash_layer', function() {
GeoHashSampleData.meta,
geohashGridOptions,
kibanaMap.getZoomLevel(),
kibanaMap
kibanaMap,
colorMapsService
);
kibanaMap.addLayer(geohashLayer);

Expand All @@ -124,7 +128,8 @@ describe('geohash_layer', function() {
{},
{ mapType: 'Scaled Circle Markers', colorRamp: 'Yellow to Red' },
kibanaMap.getZoomLevel(),
kibanaMap
kibanaMap,
colorMapsService
);
kibanaMap.addLayer(geohashLayer);

Expand Down
15 changes: 11 additions & 4 deletions src/legacy/core_plugins/tile_map/public/geohash_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { GeohashGridMarkers } from './markers/geohash_grid';
import { MapTypes } from './map_types';

export class GeohashLayer extends KibanaMapLayer {
constructor(featureCollection, featureCollectionMetaData, options, zoom, kibanaMap) {
constructor(featureCollection, featureCollectionMetaData, options, zoom, kibanaMap, colorMaps) {
super();

this._featureCollection = featureCollection;
Expand All @@ -38,6 +38,7 @@ export class GeohashLayer extends KibanaMapLayer {
this._geohashOptions = options;
this._zoom = zoom;
this._kibanaMap = kibanaMap;
this._colorMaps = colorMaps;
const geojson = L.geoJson(this._featureCollection);
this._bounds = geojson.getBounds();
this._createGeohashMarkers();
Expand All @@ -59,7 +60,9 @@ export class GeohashLayer extends KibanaMapLayer {
this._featureCollectionMetaData,
markerOptions,
this._zoom,
this._kibanaMap
this._kibanaMap,
undefined,
this._colorMaps
);
break;
case MapTypes.ShadedCircleMarkers:
Expand All @@ -68,7 +71,9 @@ export class GeohashLayer extends KibanaMapLayer {
this._featureCollectionMetaData,
markerOptions,
this._zoom,
this._kibanaMap
this._kibanaMap,
undefined,
this._colorMaps
);
break;
case MapTypes.ShadedGeohashGrid:
Expand All @@ -77,7 +82,9 @@ export class GeohashLayer extends KibanaMapLayer {
this._featureCollectionMetaData,
markerOptions,
this._zoom,
this._kibanaMap
this._kibanaMap,
undefined,
this._colorMaps
);
break;
case MapTypes.Heatmap:
Expand Down
1 change: 1 addition & 0 deletions src/legacy/core_plugins/tile_map/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { plugin } from '.';
const plugins: Readonly<TileMapPluginSetupDependencies> = {
expressions: npSetup.plugins.expressions,
visualizations: visualizationsSetup,
charts: npSetup.plugins.charts,

// Temporary solution
// It will be removed when all dependent services are migrated to the new platform.
Expand Down
Loading