Skip to content

Commit e5ca35d

Browse files
Fixed spec to rawSpec
1 parent 75914b6 commit e5ca35d

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/plugins/vis_type_vega/public/data_model/vega_parser.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ const DEFAULT_SCHEMA: string = 'https://vega.github.io/schema/vega/v5.json';
6161
const DEFAULT_PARSER: string = 'elasticsearch';
6262

6363
export class VegaParser {
64-
spec?: VegaSpec;
65-
rawSpec: string;
64+
spec: VegaSpec;
6665
hideWarnings: boolean;
6766
error?: string;
6867
warnings: string[];
@@ -82,13 +81,13 @@ export class VegaParser {
8281
controlsDir?: ControlsLocation;
8382

8483
constructor(
85-
spec: string,
84+
spec: VegaSpec | string,
8685
searchAPI: SearchAPI,
8786
timeCache: TimeCache,
8887
filters: Bool,
8988
serviceSettings: IServiceSettings
9089
) {
91-
this.rawSpec = spec;
90+
this.spec = spec as VegaSpec;
9291
this.hideWarnings = false;
9392

9493
this.error = undefined;
@@ -115,8 +114,8 @@ export class VegaParser {
115114
async _parseAsync() {
116115
if (this.isVegaLite !== undefined) throw new Error();
117116

118-
if (!this.spec) {
119-
this.spec = hjson.parse(this.rawSpec, { legacyRoot: false });
117+
if (typeof this.spec === 'string') {
118+
this.spec = hjson.parse(this.spec, { legacyRoot: false });
120119
}
121120
if (!_.isPlainObject(this.spec)) {
122121
throw new Error(
@@ -661,7 +660,6 @@ export class VegaParser {
661660
* @private
662661
*/
663662
_setDefaultValue(value: unknown, ...fields: string[]) {
664-
if (!this.spec) return;
665663
let o = this.spec;
666664
for (let i = 0; i < fields.length - 1; i++) {
667665
const field = fields[i];

src/plugins/vis_type_vega/public/vega_request_handler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export function createVegaRequestHandler(
6262

6363
const esQueryConfigs = esQuery.getEsQueryConfig(uiSettings);
6464
const filtersDsl = esQuery.buildEsQuery(undefined, query, filters, esQueryConfigs);
65-
// @ts-ignore
6665
const { VegaParser } = await import('./data_model/vega_parser');
6766
const vp = new VegaParser(visParams.spec, searchAPI, timeCache, filtersDsl, serviceSettings);
6867

0 commit comments

Comments
 (0)