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

Update vega version #68639

Merged
merged 17 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
2 changes: 1 addition & 1 deletion docs/visualize/vega.asciidoc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,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
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function getWebpackConfig(bundle: Bundle, worker: WorkerConfig) {
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
1 change: 1 addition & 0 deletions src/dev/license_checker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const LICENSE_WHITELIST = [
'Apache*',
'Apache, Version 2.0',
'Apache-2.0',
'0BSD',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timroes please let me know when we get approval to do this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We double checked that this license is good here: #67666 (comment)

'BSD 3-Clause',
'BSD New',
'BSD',
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading