Skip to content

Commit

Permalink
changed Vega signal to custom func
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Apr 6, 2018
1 parent d157757 commit 800f66e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -207,7 +207,6 @@
"validate-npm-package-name": "2.2.2",
"vega-lib": "^3.2.1",
"vega-lite": "^2.3.1",
"vega-spec-injector": "^0.0.2",
"vega-schema-url-parser": "1.0.0",
"vision": "4.1.0",
"webpack": "3.6.0",
Expand Down
5 changes: 0 additions & 5 deletions src/core_plugins/vega/public/data_model/vega_parser.js
Expand Up @@ -8,7 +8,6 @@ import hjson from 'hjson';
import { Utils } from './utils';
import { EmsFileParser } from './ems_file_parser';
import { UrlParser } from './url_parser';
import Vsi from 'vega-spec-injector';

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

Expand Down Expand Up @@ -81,10 +80,6 @@ export class VegaParser {
}

this._calcSizing();

const vsi = new Vsi(this._onWarning.bind(this));

vsi.addToList(this.spec, `signals`, ['%ADD_FILTER%']);
}

/**
Expand Down
35 changes: 22 additions & 13 deletions src/core_plugins/vega/public/vega_view/vega_base_view.js
Expand Up @@ -8,6 +8,20 @@ vega.scheme('elastic',
['#00B3A4', '#3185FC', '#DB1374', '#490092', '#FEB6DB', '#F98510', '#E6C220', '#BFA180', '#920000', '#461A0A']
);

// Vega's extension functions are global. When called,
// we forward execution to the instance-specific handler
if (!vega.expressionFunction('kibanaAddFilter')) {
vega.expressionFunction(
'kibanaAddFilter',
function kibanaAddFilter(...args) {
const view = this.context.dataflow;
const handler = view.kibanaAddFilterHandler;
if (!handler) throw new Error('kibanaAddFilter() is not defined for this graph');
view.runAfter(() => handler(...args));
}
);
}

const bypassToken = Symbol();

export function bypassExternalUrlCheck(url) {
Expand Down Expand Up @@ -146,23 +160,18 @@ export class VegaBaseView {
setView(view) {
this._view = view;
if (view) {
view.addSignalListener('%ADD_FILTER%',
/**
* @param {string} sig signal name
* @param {object} value filter object to add
* @param {string} value.field name of the filter field
* @param {string|number} value.value the value of the filter
* @param {string} value.operator how value should be compared. "IS" by default.
*/
(/* sig, value */) => {
/**
* @param {string} field name of the filter field
* @param {string|number} value the value of the filter
* @param {string} [operator] how value should be compared. "IS" by default.
*/
view.kibanaAddFilterHandler = (/*field, value, operator*/) => {


// TODO: add new filter

// TODO: add new filter


}
);
};
}
}

Expand Down
4 changes: 0 additions & 4 deletions yarn.lock
Expand Up @@ -12031,10 +12031,6 @@ vega-schema-url-parser@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/vega-schema-url-parser/-/vega-schema-url-parser-1.0.0.tgz#fc17631e354280d663ed39e3fa8eddb62145402e"

vega-spec-injector@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/vega-spec-injector/-/vega-spec-injector-0.0.2.tgz#f1d990109dd9d845c524738f818baa4b72a60ca6"

vega-statistics@^1.2:
version "1.2.1"
resolved "https://registry.yarnpkg.com/vega-statistics/-/vega-statistics-1.2.1.tgz#a35b3fc3d0039f8bb0a8ba1381d42a1df79ecb34"
Expand Down

0 comments on commit 800f66e

Please sign in to comment.