Skip to content

Commit

Permalink
[Chore] Update vega-lite defaults and tests to v5
Browse files Browse the repository at this point in the history
- Add test case for older vega-light spec parsing
- Update default schema version in default spec, test specs, mocked saved objects
- Fix indentation of comments in default spec
- Update jest mock imports to use `vega-lite-next`

Signed-off-by: Josh Romero <[email protected]>
  • Loading branch information
joshuarrrr committed Dec 14, 2022
1 parent dce161f commit e49a466
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ describe('VegaParser.parseSchema', () => {
'should not warn on current vega-lite version',
check('https://vega.github.io/schema/vega-lite/v5.json', true, 0)
);
test(
'should not warn on older vega-lite version',
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/v6.json', true, 1)
Expand Down
64 changes: 32 additions & 32 deletions src/plugins/vis_type_vega/public/default.spec.hjson
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
/*
/*

Welcome to Vega visualizations. Here you can design your own dataviz from scratch using a declarative language called Vega, or its simpler form Vega-Lite. In Vega, you have the full control of what data is loaded, even from multiple sources, how that data is transformed, and what visual elements are used to show it. Use help icon to view Vega examples, tutorials, and other docs. Use the wrench icon to reformat this text, or to remove comments.
Welcome to Vega visualizations. Here you can design your own dataviz from scratch using a declarative language called Vega, or its simpler form Vega-Lite. In Vega, you have the full control of what data is loaded, even from multiple sources, how that data is transformed, and what visual elements are used to show it. Use help icon to view Vega examples, tutorials, and other docs. Use the wrench icon to reformat this text, or to remove comments.

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.
*/
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/v4.json
$schema: https://vega.github.io/schema/vega-lite/v5.json
title: Event counts from all indexes

// Define the data source
data: {
url: {
/*
An object instead of a string for the "url" param is treated as an OpenSearch query. Anything inside this object is not part of the Vega language, but only understood by OpenSearch Dashboards and OpenSearch server. This query counts the number of documents per time interval, assuming you have a @timestamp field in your data.
/*
An object instead of a string for the "url" param is treated as an OpenSearch query. Anything inside this object is not part of the Vega language, but only understood by OpenSearch Dashboards and OpenSearch server. This query counts the number of documents per time interval, assuming you have a @timestamp field in your data.

OpenSearch Dashboards has a special handling for the fields surrounded by "%". They are processed before the the query is sent to OpenSearch. This way the query becomes context aware, and can use the time range and the dashboard filters.
*/
OpenSearch Dashboards has a special handling for the fields surrounded by "%". They are processed before the the query is sent to OpenSearch. This way the query becomes context aware, and can use the time range and the dashboard filters.
*/

// Apply dashboard context filters when set
%context%: true
// Filter the time picker (upper right corner) with this field
%timefield%: @timestamp

/*
See .search() documentation for : https://opensearch.org/docs/latest/clients/javascript/
*/
/*
See .search() documentation for : https://opensearch.org/docs/latest/clients/javascript/
*/

// Which index to search
index: _all
Expand Down Expand Up @@ -53,29 +53,29 @@ See .search() documentation for : https://opensearch.org/docs/latest/clients/ja
size: 0
}
}
/*
OpenSearch will return results in this format:
/*
OpenSearch will return results in this format:

aggregations: {
time_buckets: {
buckets: [
{
key_as_string: 2015-11-30T22:00:00.000Z
key: 1448920800000
doc_count: 0
},
{
key_as_string: 2015-11-30T23:00:00.000Z
key: 1448924400000
doc_count: 0
aggregations: {
time_buckets: {
buckets: [
{
key_as_string: 2015-11-30T22:00:00.000Z
key: 1448920800000
doc_count: 0
},
{
key_as_string: 2015-11-30T23:00:00.000Z
key: 1448924400000
doc_count: 0
}
...
]
}
...
]
}
}
}

For our graph, we only need the list of bucket values. Use the format.property to discard everything else.
*/
For our graph, we only need the list of bucket values. Use the format.property to discard everything else.
*/
format: {property: "aggregations.time_buckets.buckets"}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": "Event counts from all indexes",
"data": {
"url": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"format": {"property": "aggregations.time_buckets.buckets"},
"values": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jest.mock('./default_spec', () => ({

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

// FLAKY: https://github.com/elastic/kibana/issues/71713
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const mockedSavedObjects = [
visState: JSON.stringify({
type: 'vega',
params: {
spec: '{"$schema": "https://vega.github.io/schema/vega-lite/v4.json" }',
spec: '{"$schema": "https://vega.github.io/schema/vega-lite/v5.json" }',
},
}),
},
Expand Down

0 comments on commit e49a466

Please sign in to comment.