Skip to content

Commit

Permalink
Update vega version (#68639)
Browse files Browse the repository at this point in the history
* update vega version

* a11y skip test

* a11y skip test attempt 2

* adding back all a11y tests

* fix failed karma test

* remove extra  0BSD license

* coalesce yarn.lock versions a little

* update kbn/pm dist

* fix CI

* fix Vega View for ML

Co-authored-by: Michail Yasonik <michail.yasonik@elastic.co>
Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
4 people committed Jun 16, 2020
1 parent 7211257 commit c98845c
Show file tree
Hide file tree
Showing 26 changed files with 2,195 additions and 2,065 deletions.
2 changes: 1 addition & 1 deletion docs/visualize/vega.asciidoc
Expand Up @@ -32,7 +32,7 @@ image::images/vega_lite_default.png[]
The default visualization uses Vega-Lite version 2. To use Vega version 4, edit
the `schema`.

Go to `$schema`, enter `https://vega.github.io/schema/vega/v4.json`, then click
Go to `$schema`, enter `https://vega.github.io/schema/vega/v5.json`, then click
*Update*.

[float]
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -280,9 +280,9 @@
"uuid": "3.3.2",
"val-loader": "^1.1.1",
"validate-npm-package-name": "2.2.2",
"vega-lib": "4.3.0",
"vega-lite": "^2.6.0",
"vega-schema-url-parser": "1.0.0",
"vega": "^5.13.0",
"vega-lite": "^4.13.1",
"vega-schema-url-parser": "^1.1.0",
"vega-tooltip": "^0.12.0",
"vision": "^5.3.3",
"webpack": "^4.41.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/src/worker/webpack.config.ts
Expand Up @@ -81,7 +81,7 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
noParse: [
/[\/\\]node_modules[\/\\]elasticsearch-browser[\/\\]/,
/[\/\\]node_modules[\/\\]lodash[\/\\]index\.js$/,
/[\/\\]node_modules[\/\\]vega-lib[\/\\]build[\/\\]vega\.js$/,
/[\/\\]node_modules[\/\\]vega[\/\\]build[\/\\]vega\.js$/,
],

rules: [
Expand Down
3,145 changes: 1,648 additions & 1,497 deletions packages/kbn-pm/dist/index.js

Large diffs are not rendered by default.

@@ -1,7 +1,7 @@
{
// Adapted from Vega's https://vega.github.io/vega/examples/stacked-area-chart/

$schema: https://vega.github.io/schema/vega/v3.0.json
$schema: https://vega.github.io/schema/vega/v5.json
data: [
{
name: table
Expand Down
@@ -1,7 +1,7 @@
# This graph creates a single rectangle for the whole graph on top of a map
# Note that the actual map tiles are not loaded
{
$schema: https://vega.github.io/schema/vega/v3.0.json
$schema: https://vega.github.io/schema/vega/v5.json
config: {
kibana: {type: "map", mapStyle: false}
}
Expand Down
Expand Up @@ -24,7 +24,7 @@
]
}
]
$schema: https://vega.github.io/schema/vega/v3.json
$schema: https://vega.github.io/schema/vega/v5.json
marks: [
{
from: {data: "table"}
Expand Down
Expand Up @@ -333,7 +333,7 @@ describe('VegaVisualizations', () => {
vegaVis = new VegaVisualization(domNode, vis);
const vegaParser = new VegaParser(
`{
"$schema": "https://vega.github.io/schema/vega/v3.json",
"$schema": "https://vega.github.io/schema/vega/v5.json",
"marks": [
{
"type": "text",
Expand Down Expand Up @@ -366,11 +366,6 @@ describe('VegaVisualizations', () => {
await vegaVis.render(vegaParser, vis.params, { data: true });
const vegaView = vegaVis._vegaView._view;
expect(vegaView.height()).to.be(250.00000001);

vegaView.height(250);
await vegaView.runAsync();
// as soon as this test fails, the workaround with the subpixel value can be removed.
expect(vegaView.height()).to.be(0);
} finally {
vegaVis.destroy();
}
Expand Down
@@ -1,5 +1,5 @@
{
$schema: https://vega.github.io/schema/vega-lite/v2.json
$schema: https://vega.github.io/schema/vega-lite/v4.json
data: {
format: {property: "aggregations.time_buckets.buckets"}
values: {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/ui_exports/ui_export_defaults.js
Expand Up @@ -24,7 +24,7 @@ export const UI_EXPORT_DEFAULTS = {
webpackNoParseRules: [
/node_modules[\/\\](angular|elasticsearch-browser)[\/\\]/,
/node_modules[\/\\](mocha|moment)[\/\\]/,
/node_modules[\/\\]vega-lib[\/\\]build[\/\\]vega\.js$/,
/node_modules[\/\\]vega[\/\\]build[\/\\]vega\.js$/,
],

webpackAliases: {
Expand Down
Expand Up @@ -420,7 +420,7 @@ export const getSavedObjects = (): SavedObject[] => [
defaultMessage: '[Flights] Airport Connections (Hover Over Airport)',
}),
visState:
'{"aggs":[],"params":{"spec":"{\\n $schema: https://vega.github.io/schema/vega/v3.0.json\\n config: {\\n kibana: {type: \\"map\\", latitude: 25, longitude: -70, zoom: 3}\\n }\\n data: [\\n {\\n name: table\\n url: {\\n index: kibana_sample_data_flights\\n %context%: true\\n // Uncomment to enable time filtering\\n // %timefield%: timestamp\\n body: {\\n size: 0\\n aggs: {\\n origins: {\\n terms: {field: \\"OriginAirportID\\", size: 10000}\\n aggs: {\\n originLocation: {\\n top_hits: {\\n size: 1\\n _source: {\\n includes: [\\"OriginLocation\\", \\"Origin\\"]\\n }\\n }\\n }\\n distinations: {\\n terms: {field: \\"DestAirportID\\", size: 10000}\\n aggs: {\\n destLocation: {\\n top_hits: {\\n size: 1\\n _source: {\\n includes: [\\"DestLocation\\"]\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n format: {property: \\"aggregations.origins.buckets\\"}\\n transform: [\\n {\\n type: geopoint\\n projection: projection\\n fields: [\\n originLocation.hits.hits[0]._source.OriginLocation.lon\\n originLocation.hits.hits[0]._source.OriginLocation.lat\\n ]\\n }\\n ]\\n }\\n {\\n name: selectedDatum\\n on: [\\n {trigger: \\"!selected\\", remove: true}\\n {trigger: \\"selected\\", insert: \\"selected\\"}\\n ]\\n }\\n ]\\n signals: [\\n {\\n name: selected\\n value: null\\n on: [\\n {events: \\"@airport:mouseover\\", update: \\"datum\\"}\\n {events: \\"@airport:mouseout\\", update: \\"null\\"}\\n ]\\n }\\n ]\\n scales: [\\n {\\n name: airportSize\\n type: linear\\n domain: {data: \\"table\\", field: \\"doc_count\\"}\\n range: [\\n {signal: \\"zoom*zoom*0.2+1\\"}\\n {signal: \\"zoom*zoom*10+1\\"}\\n ]\\n }\\n ]\\n marks: [\\n {\\n type: group\\n from: {\\n facet: {\\n name: facetedDatum\\n data: selectedDatum\\n field: distinations.buckets\\n }\\n }\\n data: [\\n {\\n name: facetDatumElems\\n source: facetedDatum\\n transform: [\\n {\\n type: geopoint\\n projection: projection\\n fields: [\\n destLocation.hits.hits[0]._source.DestLocation.lon\\n destLocation.hits.hits[0]._source.DestLocation.lat\\n ]\\n }\\n {type: \\"formula\\", expr: \\"{x:parent.x, y:parent.y}\\", as: \\"source\\"}\\n {type: \\"formula\\", expr: \\"{x:datum.x, y:datum.y}\\", as: \\"target\\"}\\n {type: \\"linkpath\\", shape: \\"diagonal\\"}\\n ]\\n }\\n ]\\n scales: [\\n {\\n name: lineThickness\\n type: linear\\n domain: {data: \\"facetDatumElems\\", field: \\"doc_count\\"}\\n range: [1, 8]\\n }\\n {\\n name: lineOpacity\\n type: linear\\n domain: {data: \\"facetDatumElems\\", field: \\"doc_count\\"}\\n range: [0.2, 0.8]\\n }\\n ]\\n marks: [\\n {\\n from: {data: \\"facetDatumElems\\"}\\n type: path\\n interactive: false\\n encode: {\\n update: {\\n path: {field: \\"path\\"}\\n stroke: {value: \\"black\\"}\\n strokeWidth: {scale: \\"lineThickness\\", field: \\"doc_count\\"}\\n strokeOpacity: {scale: \\"lineOpacity\\", field: \\"doc_count\\"}\\n }\\n }\\n }\\n ]\\n }\\n {\\n name: airport\\n type: symbol\\n from: {data: \\"table\\"}\\n encode: {\\n update: {\\n size: {scale: \\"airportSize\\", field: \\"doc_count\\"}\\n xc: {signal: \\"datum.x\\"}\\n yc: {signal: \\"datum.y\\"}\\n tooltip: {\\n signal: \\"{title: datum.originLocation.hits.hits[0]._source.Origin + \' (\' + datum.key + \')\', connnections: length(datum.distinations.buckets), flights: datum.doc_count}\\"\\n }\\n }\\n }\\n }\\n ]\\n}"},"title":"[Flights] Airport Connections (Hover Over Airport)","type":"vega"}',
'{"aggs":[],"params":{"spec":"{\\n $schema: https://vega.github.io/schema/vega/v5.json\\n config: {\\n kibana: {type: \\"map\\", latitude: 25, longitude: -70, zoom: 3}\\n }\\n data: [\\n {\\n name: table\\n url: {\\n index: kibana_sample_data_flights\\n %context%: true\\n // Uncomment to enable time filtering\\n // %timefield%: timestamp\\n body: {\\n size: 0\\n aggs: {\\n origins: {\\n terms: {field: \\"OriginAirportID\\", size: 10000}\\n aggs: {\\n originLocation: {\\n top_hits: {\\n size: 1\\n _source: {\\n includes: [\\"OriginLocation\\", \\"Origin\\"]\\n }\\n }\\n }\\n distinations: {\\n terms: {field: \\"DestAirportID\\", size: 10000}\\n aggs: {\\n destLocation: {\\n top_hits: {\\n size: 1\\n _source: {\\n includes: [\\"DestLocation\\"]\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n format: {property: \\"aggregations.origins.buckets\\"}\\n transform: [\\n {\\n type: geopoint\\n projection: projection\\n fields: [\\n originLocation.hits.hits[0]._source.OriginLocation.lon\\n originLocation.hits.hits[0]._source.OriginLocation.lat\\n ]\\n }\\n ]\\n }\\n {\\n name: selectedDatum\\n on: [\\n {trigger: \\"!selected\\", remove: true}\\n {trigger: \\"selected\\", insert: \\"selected\\"}\\n ]\\n }\\n ]\\n signals: [\\n {\\n name: selected\\n value: null\\n on: [\\n {events: \\"@airport:mouseover\\", update: \\"datum\\"}\\n {events: \\"@airport:mouseout\\", update: \\"null\\"}\\n ]\\n }\\n ]\\n scales: [\\n {\\n name: airportSize\\n type: linear\\n domain: {data: \\"table\\", field: \\"doc_count\\"}\\n range: [\\n {signal: \\"zoom*zoom*0.2+1\\"}\\n {signal: \\"zoom*zoom*10+1\\"}\\n ]\\n }\\n ]\\n marks: [\\n {\\n type: group\\n from: {\\n facet: {\\n name: facetedDatum\\n data: selectedDatum\\n field: distinations.buckets\\n }\\n }\\n data: [\\n {\\n name: facetDatumElems\\n source: facetedDatum\\n transform: [\\n {\\n type: geopoint\\n projection: projection\\n fields: [\\n destLocation.hits.hits[0]._source.DestLocation.lon\\n destLocation.hits.hits[0]._source.DestLocation.lat\\n ]\\n }\\n {type: \\"formula\\", expr: \\"{x:parent.x, y:parent.y}\\", as: \\"source\\"}\\n {type: \\"formula\\", expr: \\"{x:datum.x, y:datum.y}\\", as: \\"target\\"}\\n {type: \\"linkpath\\", shape: \\"diagonal\\"}\\n ]\\n }\\n ]\\n scales: [\\n {\\n name: lineThickness\\n type: log\\n clamp: true\\n range: [1, 8]\\n }\\n {\\n name: lineOpacity\\n type: log\\n clamp: true\\n range: [0.2, 0.8]\\n }\\n ]\\n marks: [\\n {\\n from: {data: \\"facetDatumElems\\"}\\n type: path\\n interactive: false\\n encode: {\\n update: {\\n path: {field: \\"path\\"}\\n stroke: {value: \\"black\\"}\\n strokeWidth: {scale: \\"lineThickness\\", field: \\"doc_count\\"}\\n strokeOpacity: {scale: \\"lineOpacity\\", field: \\"doc_count\\"}\\n }\\n }\\n }\\n ]\\n }\\n {\\n name: airport\\n type: symbol\\n from: {data: \\"table\\"}\\n encode: {\\n update: {\\n size: {scale: \\"airportSize\\", field: \\"doc_count\\"}\\n xc: {signal: \\"datum.x\\"}\\n yc: {signal: \\"datum.y\\"}\\n tooltip: {\\n signal: \\"{title: datum.originLocation.hits.hits[0]._source.Origin + \' (\' + datum.key + \')\', connnections: length(datum.distinations.buckets), flights: datum.doc_count}\\"\\n }\\n }\\n }\\n }\\n ]\\n}"},"title":"[Flights] Airport Connections (Hover Over Airport)","type":"vega"}',
uiStateJSON: '{}',
description: '',
version: 1,
Expand Down

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions src/plugins/vis_type_vega/public/data_model/vega_parser.js
Expand Up @@ -18,8 +18,7 @@
*/

import _ from 'lodash';
import * as vega from 'vega-lib';
import * as vegaLite from 'vega-lite';
import { vega, vegaLite } from '../lib/vega';
import schemaParser from 'vega-schema-url-parser';
import versionCompare from 'compare-versions';
import { EsQueryParser } from './es_query_parser';
Expand All @@ -32,15 +31,13 @@ import { i18n } from '@kbn/i18n';

// Set default single color to match other Kibana visualizations
const defaultColor = VISUALIZATION_COLORS[0];

const DEFAULT_SCHEMA = 'https://vega.github.io/schema/vega/v3.0.json';

const locToDirMap = {
left: 'row-reverse',
right: 'row',
top: 'column-reverse',
bottom: 'column',
};
const DEFAULT_SCHEMA = 'https://vega.github.io/schema/vega/v5.json';

// If there is no "%type%" parameter, use this parser
const DEFAULT_PARSER = 'elasticsearch';
Expand Down
18 changes: 12 additions & 6 deletions src/plugins/vis_type_vega/public/data_model/vega_parser.test.js
Expand Up @@ -20,8 +20,14 @@
import { cloneDeep } from 'lodash';
import { VegaParser } from './vega_parser';
import { bypassExternalUrlCheck } from '../vega_view/vega_base_view';

jest.mock('../services');

jest.mock('../lib/vega', () => ({
vega: jest.requireActual('vega'),
vegaLite: jest.requireActual('vega-lite'),
}));

describe(`VegaParser._setDefaultValue`, () => {
function check(spec, expected, ...params) {
return () => {
Expand Down Expand Up @@ -146,30 +152,30 @@ describe('VegaParser._parseSchema', () => {
test('should warn on no vega version specified', () => {
const vp = new VegaParser({});
expect(vp._parseSchema()).toBe(false);
expect(vp.spec).toEqual({ $schema: 'https://vega.github.io/schema/vega/v3.0.json' });
expect(vp.spec).toEqual({ $schema: 'https://vega.github.io/schema/vega/v5.json' });
expect(vp.warnings).toHaveLength(1);
});

test(
'should not warn on current vega version',
check('https://vega.github.io/schema/vega/v4.0.json', false, 0)
check('https://vega.github.io/schema/vega/v5.json', false, 0)
);
test(
'should not warn on older vega version',
check('https://vega.github.io/schema/vega/v3.0.json', false, 0)
check('https://vega.github.io/schema/vega/v4.json', false, 0)
);
test(
'should warn on vega version too new to be supported',
check('https://vega.github.io/schema/vega/v5.0.json', false, 1)
check('https://vega.github.io/schema/vega/v5.99.json', false, 1)
);

test(
'should not warn on current vega-lite version',
check('https://vega.github.io/schema/vega-lite/v2.0.json', true, 0)
check('https://vega.github.io/schema/vega-lite/v4.json', true, 0)
);
test(
'should warn on vega-lite version too new to be supported',
check('https://vega.github.io/schema/vega-lite/v3.0.json', true, 1)
check('https://vega.github.io/schema/vega-lite/v5.json', true, 1)
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_type_vega/public/default.spec.hjson
Expand Up @@ -6,7 +6,7 @@ Welcome to Vega visualizations. Here you can design your own dataviz from scrat
This example graph shows the document count in all indexes in the current time range. You might need to adjust the time filter in the upper right corner.
*/

$schema: https://vega.github.io/schema/vega-lite/v2.json
$schema: https://vega.github.io/schema/vega-lite/v4.json
title: Event counts from all indexes

// Define the data source
Expand Down
23 changes: 23 additions & 0 deletions src/plugins/vis_type_vega/public/lib/vega.js
@@ -0,0 +1,23 @@
/*
* 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 * as vegaLite from 'vega-lite/build-es5/vega-lite';
import * as vega from 'vega/build-es5/vega';

export { vega, vegaLite };
3 changes: 1 addition & 2 deletions src/plugins/vis_type_vega/public/vega_view/vega_base_view.js
Expand Up @@ -20,8 +20,7 @@
import $ from 'jquery';
import moment from 'moment';
import dateMath from '@elastic/datemath';
import * as vega from 'vega-lib';
import * as vegaLite from 'vega-lite';
import { vega, vegaLite } from '../lib/vega';
import { Utils } from '../data_model/utils';
import { VISUALIZATION_COLORS } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
Expand Down
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import * as vega from 'vega-lib';
import { i18n } from '@kbn/i18n';
import { vega } from '../lib/vega';
import { VegaBaseView } from './vega_base_view';
import { VegaMapLayer } from './vega_map_layer';
import { getEmsTileLayerId, getUISettings, getKibanaMapFactory } from '../services';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_type_vega/public/vega_view/vega_view.js
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import * as vega from 'vega-lib';
import { vega } from '../lib/vega';
import { VegaBaseView } from './vega_base_view';

export class VegaView extends VegaBaseView {
Expand Down
7 changes: 6 additions & 1 deletion test/accessibility/services/a11y/a11y.ts
Expand Up @@ -70,7 +70,12 @@ export function A11yProvider({ getService }: FtrProviderContext) {
exclude: ([] as string[])
.concat(excludeTestSubj || [])
.map((ts) => [testSubjectToCss(ts)])
.concat([['.ace_scrollbar']]),
.concat([
['.ace_scrollbar'],
[
'.leaflet-vega-container[role="graphics-document"][aria-roledescription="visualization"]',
],
]),
};
}

Expand Down
1 change: 1 addition & 0 deletions x-pack/package.json
Expand Up @@ -237,6 +237,7 @@
"cytoscape": "^3.10.0",
"d3": "3.5.17",
"d3-scale": "1.0.7",
"d3-array": "1.2.4",
"dedent": "^0.7.0",
"del": "^5.1.0",
"dragselect": "1.13.1",
Expand Down

0 comments on commit c98845c

Please sign in to comment.