Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
});
}
}
setDebugValues(view, spec, vlspec) {
if (!this._editorMode) {
// VEGA_DEBUG should only be enabled in the editor mode
return;
}
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;
}
});
}
}
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;
}
});
}
}
import React from 'react';
import ReactDOM from 'react-dom';
import * as ReactGA from 'react-ga';
import {Provider} from 'react-redux';
import {hashHistory, Route, Router} from 'react-router';
import * as vega from 'vega';
import * as vl from 'vega-lite';
import App from './components/app';
import configureStore from './store/configure-store';
window.VEGA_DEBUG = window.VEGA_DEBUG || {};
window.VEGA_DEBUG.vega = vega;
window.VEGA_DEBUG.vl = vl;
window.VEGA_DEBUG.VEGA_VERSION = vega.version;
window.VEGA_DEBUG.VEGA_LITE_VERSION = vl.version;
// Configure history for react-router
const store = configureStore(hashHistory);
// Google analytics
ReactGA.initialize('UA-44428446-7');
function logPageView() {
ReactGA.set({page: window.location.pathname + window.location.search});
ReactGA.pageview(window.location.pathname + window.location.search);
}
// Now that redux and react-router have been configured, we can render the
// React application to the DOM!
ReactDOM.render(
(
import {FORMAT, readVegaFile} from './utils/helper';
import {showOpenDialog} from './utils/dialog';
import DropArea from './components/DropArea';
import VegaRenderer from './components/VegaRenderer';
import downloadURI from './utils/downloadURI';
const vg = require('vega');
const vl = require('vega-lite');
window.VEGA_DEBUG = window.VEGA_DEBUG || {};
window.VEGA_DEBUG = {};
window.VEGA_DEBUG.vega = vg;
window.VEGA_DEBUG.vl = vl;
window.VEGA_DEBUG.VEGA_VERSION = vg.version;
window.VEGA_DEBUG.VEGA_LITE_VERSION = vl.version;
console.log('%cWelcome to Vega-Desktop!', '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 MenuBar = styled.div`
background-color: #eee;
padding: 5px;
position: fixed;
width: 100%;
z-index: 100;
`;
const StatusBar = styled.div`
background-color: #efefef;
padding: 5px 8px;
font-size: 0.8em;
_parseSchema() {
if (!this.spec.$schema) {
this._onWarning(i18n.translate('vega.vegaParser.inputSpecDoesNotSpecifySchemaWarningMessage', {
defaultMessage: 'The input spec does not specify a {schemaParam}, defaulting to {defaultSchema}',
values: { defaultSchema: `"${DEFAULT_SCHEMA}"`, schemaParam: '"$schema"' },
}));
this.spec.$schema = DEFAULT_SCHEMA;
}
const schema = schemaParser(this.spec.$schema);
const isVegaLite = schema.library === 'vega-lite';
const libVersion = isVegaLite ? vegaLite.version : vega.version;
if (versionCompare(schema.version, libVersion) > 0) {
this._onWarning(i18n.translate('vega.vegaParser.notValidLibraryVersionForInputSpecWarningMessage', {
defaultMessage: 'The input spec uses {schemaLibrary} {schemaVersion}, but current version of {schemaLibrary} is {libraryVersion}.',
values: {
schemaLibrary: schema.library,
schemaVersion: schema.version,
libraryVersion: libVersion,
},
}));
}
return isVegaLite;
}
_parseSchema() {
if (!this.spec.$schema) {
this._onWarning(`The input spec does not specify a "$schema", defaulting to "${DEFAULT_SCHEMA}"`);
this.spec.$schema = DEFAULT_SCHEMA;
}
const schema = schemaParser(this.spec.$schema);
const isVegaLite = schema.library === 'vega-lite';
const libVersion = isVegaLite ? vegaLite.version : vega.version;
if (versionCompare(schema.version, libVersion) > 0) {
this._onWarning(
`The input spec uses ${schema.library} ${schema.version}, but ` +
`current version of ${schema.library} is ${libVersion}.`
);
}
return isVegaLite;
}
<div>
<div>
{
this.vega = c;
}}
className="vis"
format={format}
spec={spec}
filePath={filePath}
/>
</div>
</div>
{format === FORMAT.VEGA_LITE ?
`Vega-Lite v${vl.version}` :
`Vega v${vg.version}`}
);
}
}
export function parseInputSpec(inputSpec, onWarning) {
let spec = { ...inputSpec };
if (!spec.$schema) {
onWarning(`The input spec does not specify a "$schema", defaulting to "${DEFAULT_SCHEMA}"`);
spec.$schema = DEFAULT_SCHEMA;
}
const schema = schemaParser(spec.$schema);
const isVegaLite = schema.library === 'vega-lite';
const libVersion = isVegaLite ? vegaLite.version : vega.version;
if (versionCompare(schema.version, libVersion) > 0) {
onWarning(
`The input spec uses "${schema.library}" ${schema.version}, but ` +
`current version of "${schema.library}" is ${libVersion}.`
);
}
const hostConfig = spec._hostConfig;
if (hostConfig !== undefined) {
delete spec.hostConfig;
if (typeof hostConfig !== 'object') {
throw new Error('_hostConfig must be an object');
}
}
_parseSchema() {
if (!this.spec.$schema) {
this._onWarning(i18n.translate('visTypeVega.vegaParser.inputSpecDoesNotSpecifySchemaWarningMessage', {
defaultMessage: 'The input spec does not specify a {schemaParam}, defaulting to {defaultSchema}',
values: { defaultSchema: `"${DEFAULT_SCHEMA}"`, schemaParam: '"$schema"' },
}));
this.spec.$schema = DEFAULT_SCHEMA;
}
const schema = schemaParser(this.spec.$schema);
const isVegaLite = schema.library === 'vega-lite';
const libVersion = isVegaLite ? vegaLite.version : vega.version;
if (versionCompare(schema.version, libVersion) > 0) {
this._onWarning(i18n.translate('visTypeVega.vegaParser.notValidLibraryVersionForInputSpecWarningMessage', {
defaultMessage: 'The input spec uses {schemaLibrary} {schemaVersion}, but current version of {schemaLibrary} is {libraryVersion}.',
values: {
schemaLibrary: schema.library,
schemaVersion: schema.version,
libraryVersion: libVersion,
},
}));
}
return isVegaLite;
}