mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* Reenable vega debug * Restore to simple VEGA_DEBUG implementation
This commit is contained in:
parent
e87f67eb3f
commit
167b29b2b0
3 changed files with 30 additions and 0 deletions
|
@ -21,6 +21,7 @@ import $ from 'jquery';
|
|||
import moment from 'moment';
|
||||
import dateMath from '@kbn/datemath';
|
||||
import * as vega from 'vega-lib';
|
||||
import * as vegaLite from 'vega-lite';
|
||||
import { Utils } from '../data_model/utils';
|
||||
import { VISUALIZATION_COLORS } from '@elastic/eui';
|
||||
import { TooltipHandler } from './vega_tooltip';
|
||||
|
@ -329,6 +330,33 @@ export class VegaBaseView {
|
|||
return { from, to, mode };
|
||||
}
|
||||
|
||||
/**
|
||||
* Set global debug variable to simplify vega debugging in console. Show info message first time
|
||||
*/
|
||||
setDebugValues(view, spec, vlspec) {
|
||||
if (window) {
|
||||
if (window.VEGA_DEBUG === undefined && console) {
|
||||
console.log('%cWelcome to Kibana Vega Plugin!', 'font-size: 16px; font-weight: bold;');
|
||||
console.log('You can access the Vega view with VEGA_DEBUG. ' +
|
||||
'Learn more at https://vega.github.io/vega/docs/api/debugging/.');
|
||||
}
|
||||
const debugObj = {};
|
||||
window.VEGA_DEBUG = debugObj;
|
||||
window.VEGA_DEBUG.VEGA_VERSION = vega.version;
|
||||
window.VEGA_DEBUG.VEGA_LITE_VERSION = vegaLite.version;
|
||||
window.VEGA_DEBUG.view = view;
|
||||
window.VEGA_DEBUG.vega_spec = spec;
|
||||
window.VEGA_DEBUG.vegalite_spec = vlspec;
|
||||
|
||||
// On dispose, clean up, but don't use undefined to prevent repeated debug statements
|
||||
this._addDestroyHandler(() => {
|
||||
if (debugObj === window.VEGA_DEBUG) {
|
||||
window.VEGA_DEBUG = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
// properly handle multiple destroy() calls by converting this._destroyHandlers
|
||||
// into the _ongoingDestroy promise, while handlers are being disposed
|
||||
|
|
|
@ -107,6 +107,7 @@ export class VegaMapView extends VegaBaseView {
|
|||
});
|
||||
|
||||
const vegaView = vegaMapLayer.getVegaView();
|
||||
this.setDebugValues(vegaView, this._parser.spec, this._parser.vlspec);
|
||||
await this.setView(vegaView);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ export class VegaView extends VegaBaseView {
|
|||
if (!this._$container) return;
|
||||
|
||||
const view = new vega.View(vega.parse(this._parser.spec), this._vegaViewConfig);
|
||||
this.setDebugValues(view, this._parser.spec, this._parser.vlspec);
|
||||
|
||||
view.warn = this.onWarn.bind(this);
|
||||
view.error = this.onError.bind(this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue