= {
uiSettings: core.uiSettings,
- colorMaps: charts.colorMaps,
+ charts,
...__LEGACY,
};
diff --git a/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/_vis_fixture.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/_vis_fixture.js
index e974642b22385..1a667389c83bc 100644
--- a/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/_vis_fixture.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/_vis_fixture.js
@@ -24,12 +24,15 @@ import {
vislibSeriesResponseHandlerProvider,
vislibSlicesResponseHandlerProvider,
} from 'ui/vis/response_handlers/vislib';
-import { vislibColor } from 'ui/vis/components/color/color';
import { Vis } from '../../../vis';
-// TODO: Remove when converted to jest
-// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { colorMapsService as colorMaps } from '../../../../../../../../plugins/charts/public/services';
+
+// TODO: Remove when converted to jest mocks
+import {
+ colorMapsService as colorMaps,
+ ColorsService,
+ // eslint-disable-next-line @kbn/eslint/no-restricted-paths
+} from '../../../../../../../../plugins/charts/public/services';
const $visCanvas = $('')
.attr('id', 'vislib-vis-fixtures')
@@ -64,10 +67,15 @@ afterEach(function() {
const getDeps = () => {
const uiSettings = new Map();
+ const colors = new ColorsService();
+ colors.init(uiSettings);
+
return {
uiSettings,
- vislibColor,
- colorMaps,
+ charts: {
+ colors,
+ colorMaps,
+ },
vislibSeriesResponseHandlerProvider,
vislibSlicesResponseHandlerProvider,
};
diff --git a/src/legacy/core_plugins/vis_type_vislib/public/vislib/vis.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/vis.js
index 32afb6a008b61..3f27ee8062a75 100644
--- a/src/legacy/core_plugins/vis_type_vislib/public/vislib/vis.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/vis.js
@@ -55,7 +55,7 @@ export class Vis extends EventEmitter {
this.data,
this.uiState,
this.element,
- this.deps.vislibColor
+ this.deps.charts.colors.vislibColor.bind(this.deps.charts.colors)
);
}
diff --git a/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/meter.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/meter.js
index e07b73a07ade5..ce67fdeae3811 100644
--- a/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/meter.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/meter.js
@@ -56,9 +56,9 @@ const defaultConfig = {
};
export class MeterGauge {
- constructor(gaugeChart, { colorMaps }) {
+ constructor(gaugeChart, { charts }) {
this.gaugeChart = gaugeChart;
- this.colorMaps = colorMaps;
+ this.colorMaps = charts.colorMaps;
this.gaugeConfig = gaugeChart.gaugeConfig;
this.gaugeConfig = _.defaultsDeep(this.gaugeConfig, defaultConfig);
diff --git a/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.js
index 3b1c9f8ff0fbd..42e68bea88f86 100644
--- a/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.js
@@ -42,7 +42,7 @@ export class HeatmapChart extends PointSeries {
constructor(handler, chartEl, chartData, seriesConfigArgs, deps) {
super(handler, chartEl, chartData, seriesConfigArgs, deps);
- this.colorMaps = deps.colorMaps;
+ this.colorMaps = deps.charts.colorMaps;
this.seriesConfig = _.defaults(seriesConfigArgs || {}, defaults);
this.handler.visConfig.set('legend', {
diff --git a/src/plugins/charts/public/services/colors/color_palette.ts b/src/plugins/charts/public/services/colors/color_palette.ts
index 3c808037705a2..7b8e93bbde240 100644
--- a/src/plugins/charts/public/services/colors/color_palette.ts
+++ b/src/plugins/charts/public/services/colors/color_palette.ts
@@ -19,6 +19,7 @@
import d3 from 'd3';
import _ from 'lodash';
+
import { seedColors } from './seed_colors';
const offset = 300; // Hue offset to start at
diff --git a/src/plugins/charts/public/services/colors/colors.ts b/src/plugins/charts/public/services/colors/colors.ts
index 13eeecf0023ed..bbe3ae9a67a6b 100644
--- a/src/plugins/charts/public/services/colors/colors.ts
+++ b/src/plugins/charts/public/services/colors/colors.ts
@@ -22,6 +22,7 @@ import _ from 'lodash';
import { CoreSetup } from 'kibana/public';
import { MappedColors } from './mapped_colors';
+import { seedColors } from './seed_colors';
/**
* Accepts an array of strings or numbers that are used to create a
@@ -32,6 +33,8 @@ import { MappedColors } from './mapped_colors';
export class ColorsService {
private _mappedColors?: MappedColors;
+ public readonly seedColors = seedColors;
+
public get mappedColors() {
if (!this._mappedColors) {
throw new Error('ColorService not yet initialized');
@@ -45,8 +48,6 @@ export class ColorsService {
}
vislibColor(arrayOfStringsOrNumbers?: any, colorMapping = {}) {
- colorMapping = colorMapping || {};
-
if (!Array.isArray(arrayOfStringsOrNumbers)) {
throw new Error(
`vislibColor expects an array but recived: ${typeof arrayOfStringsOrNumbers}`