Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vega-view

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-view - npm Package Compare versions

Comparing version 5.8.1 to 5.8.2

20

build/vega-view.js

@@ -44,3 +44,3 @@ (function (global, factory) {

view.on(view.events('view', 'mousemove'), cursor,
function(_, event) {
(_, event) => {
const value = cursor.value,

@@ -143,3 +143,3 @@ user = value ? (vegaUtil.isString(value) ? value : value.user) : Default,

view._resizeListeners.forEach(function(handler) {
view._resizeListeners.forEach(handler => {
try {

@@ -452,3 +452,3 @@ handler(w, h);

if (value !== view.signal(param.signal)) {
view.runAsync(null, function() {
view.runAsync(null, () => {
bind.source = true;

@@ -678,3 +678,3 @@ view.signal(param.signal, value);

if (prevHandler) {
prevHandler.handlers().forEach(function(h) {
prevHandler.handlers().forEach(h => {
handler.on(h.type, h.handler);

@@ -715,3 +715,3 @@ });

view._bind.forEach(function(_) {
view._bind.forEach(_ => {
if (_.param.element && config !== 'container') {

@@ -722,3 +722,3 @@ _.element = lookup(view, _.param.element);

view._bind.forEach(function(_) {
view._bind.forEach(_ => {
bind(view, _.element || elBind, _);

@@ -872,3 +872,3 @@ });

view._resizeWidth = view.add(null,
function(_) {
_ => {
view._width = _.size;

@@ -883,3 +883,3 @@ view._viewWidth = viewWidth(view, _.size);

view._resizeHeight = view.add(null,
function(_) {
_ => {
view._height = _.size;

@@ -902,3 +902,3 @@ view._viewHeight = viewHeight(view, _.size);

function resizeView(viewWidth, viewHeight, width, height, origin, auto) {
this.runAfter(function(view) {
this.runAfter(view => {
var rerun = 0;

@@ -1015,3 +1015,3 @@

function formatObject(obj) {
return Object.keys(obj).map(function(key) {
return Object.keys(obj).map(key => {
var v = obj[key];

@@ -1018,0 +1018,0 @@ return key + ': ' + (vegaUtil.isArray(v) ? formatArray(v) : formatValue(v));

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-dataflow"),require("vega-scenegraph"),require("d3-array"),require("vega-functions"),require("vega-runtime"),require("d3-timer"),require("vega-format")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-dataflow","vega-scenegraph","d3-array","vega-functions","vega-runtime","d3-timer","vega-format"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vega={},e.vega,e.vega,e.vega,e.d3,e.vega,e.vega,e.d3,e.vega)}(this,(function(e,t,n,r,i,a,s,o,u){"use strict";function l(e,t){e&&(null==t?e.removeAttribute("aria-label"):e.setAttribute("aria-label",t))}function d(e,t){const n=e.globalCursor()?"undefined"!=typeof document&&document.body:e.container();if(n)return null==t?n.style.removeProperty("cursor"):n.style.cursor=t}function c(e,n){var r=e._runtime.data;return t.hasOwnProperty(r,n)||t.error("Unrecognized data set: "+n),r[n]}function h(e,r){n.isChangeSet(r)||t.error("Second argument to changes must be a changeset.");var i=c(this,e);return i.modified=!0,this.pulse(i.input,r)}function g(e){var t=e.padding();return Math.max(0,e._viewWidth+t.left+t.right)}function f(e){var t=e.padding();return Math.max(0,e._viewHeight+t.top+t.bottom)}function p(e){var t=e.padding(),n=e._origin;return[t.left+n[0],t.top+n[1]]}function v(e,n,i){var a,s,o,u=e._renderer,l=u&&u.canvas();return l&&(o=p(e),s=n.changedTouches?n.changedTouches[0]:n,(a=r.point(s,l))[0]-=o[0],a[1]-=o[1]),n.dataflow=e,n.item=i,n.vega=function(e,n,r){var i=n?"group"===n.mark.marktype?n:n.mark.group:null;function a(e){var t,r=i;if(e)for(t=n;t;t=t.mark.group)if(t.mark.name===e){r=t;break}return r&&r.mark&&r.mark.interactive?r:{}}function s(e){if(!e)return r;t.isString(e)&&(e=a(e));for(var n=r.slice();e;)n[0]-=e.x||0,n[1]-=e.y||0,e=e.mark&&e.mark.group;return n}return{view:t.constant(e),item:t.constant(n||{}),group:a,xy:s,x:function(e){return s(e)[0]},y:function(e){return s(e)[1]}}}(e,i,a),n}const _={trap:!1};function m(e,n,r){const i=e._eventConfig&&e._eventConfig[n];return!(!1===i||t.isObject(i)&&!i[r])||(e.warn(`Blocked ${n} ${r} event listener.`),!1)}function y(e){return e.item}function w(e){return e.item.mark.source}function b(e){return function(t,n){return n.vega.view().changeset().encode(n.item,e)}}function z(e,t,n){var r=document.createElement(e);for(var i in t)r.setAttribute(i,t[i]);return null!=n&&(r.textContent=n),r}function k(e,n,r){if(!n)return;const i=r.param;let a=r.state;return a||(a=r.state={elements:null,active:!1,set:null,update:t=>{t!==e.signal(i.signal)&&e.runAsync(null,(function(){a.source=!0,e.signal(i.signal,t)}))}},i.debounce&&(a.update=t.debounce(i.debounce,a.update))),function(e,t,n,r){const i=z("div",{class:"vega-bind"}),a="radio"===n.input?i:i.appendChild(z("label"));a.appendChild(z("span",{class:"vega-bind-name"},n.name||n.signal)),t.appendChild(i);let s=C;switch(n.input){case"checkbox":s=L;break;case"select":s=x;break;case"radio":s=A;break;case"range":s=S}s(e,a,n,r)}(a,n,i,e.signal(i.signal)),a.active||(e.on(e._signals[i.signal],null,()=>{a.source?a.source=!1:a.set(e.signal(i.signal))}),a.active=!0),a}function C(e,t,n,r){const i=z("input");for(const e in n)"signal"!==e&&"element"!==e&&i.setAttribute("input"===e?"type":e,n[e]);i.setAttribute("name",n.signal),i.value=r,t.appendChild(i),i.addEventListener("input",()=>e.update(i.value)),e.elements=[i],e.set=e=>i.value=e}function L(e,t,n,r){const i={type:"checkbox",name:n.signal};r&&(i.checked=!0);const a=z("input",i);t.appendChild(a),a.addEventListener("change",()=>e.update(a.checked)),e.elements=[a],e.set=e=>a.checked=!!e||null}function x(e,t,n,r){const i=z("select",{name:n.signal}),a=n.labels||[];n.options.forEach((e,t)=>{const n={value:e};E(e,r)&&(n.selected=!0),i.appendChild(z("option",n,(a[t]||e)+""))}),t.appendChild(i),i.addEventListener("change",()=>{e.update(n.options[i.selectedIndex])}),e.elements=[i],e.set=e=>{for(let t=0,r=n.options.length;t<r;++t)if(E(n.options[t],e))return void(i.selectedIndex=t)}}function A(e,t,n,r){const i=z("span",{class:"vega-bind-radio"}),a=n.labels||[];t.appendChild(i),e.elements=n.options.map((t,s)=>{const o={type:"radio",name:n.signal,value:t};E(t,r)&&(o.checked=!0);const u=z("input",o);u.addEventListener("change",()=>e.update(t));const l=z("label",{},(a[s]||t)+"");return l.prepend(u),i.appendChild(l),u}),e.set=t=>{const n=e.elements,r=n.length;for(let e=0;e<r;++e)E(n[e].value,t)&&(n[e].checked=!0)}}function S(e,t,n,r){r=void 0!==r?r:(+n.max+ +n.min)/2;const a=null!=n.max?n.max:Math.max(100,+r)||100,s=n.min||Math.min(0,a,+r)||0,o=n.step||i.tickStep(s,a,100),u=z("input",{type:"range",name:n.signal,min:s,max:a,step:o});u.value=r;const l=z("span",{},+r);t.appendChild(u),t.appendChild(l);const d=()=>{l.textContent=u.value,e.update(+u.value)};u.addEventListener("input",d),u.addEventListener("change",d),e.elements=[u],e.set=e=>{u.value=e,l.textContent=e}}function E(e,t){return e===t||e+""==t+""}function D(e,t,n,r,i,a){return(t=t||new r(e.loader())).initialize(n,g(e),f(e),p(e),i,a).background(e.background())}function R(e,t){return t?function(){try{t.apply(this,arguments)}catch(t){e.error(t)}}:null}function T(e,t){if("string"==typeof t){if("undefined"==typeof document)return e.error("DOM document instance not found."),null;if(!(t=document.querySelector(t)))return e.error("Signal bind element not found: "+t),null}if(t)try{t.innerHTML=""}catch(n){t=null,e.error(n)}return t}const O=e=>+e||0;function j(e){return t.isObject(e)?{top:O(e.top),bottom:O(e.bottom),left:O(e.left),right:O(e.right)}:(e=>({top:e,bottom:e,left:e,right:e}))(O(e))}async function H(e,n,i,a){const s=r.renderModule(n),o=s&&s.headless;return o||t.error("Unrecognized renderer type: "+n),await e.runAsync(),D(e,null,null,o,i,a).renderAsync(e._scenegraph.root)}var U={skip:!0};function q(e,t){var n=e.autosize(),r=e.padding();return t-(n&&"padding"===n.contains?r.left+r.right:0)}function M(e,t){var n=e.autosize(),r=e.padding();return t-(n&&"padding"===n.contains?r.top+r.bottom:0)}function W(e,n){return n.modified&&t.isArray(n.input.value)&&e.indexOf("_:vega:_")}function V(e,t){return!("parent"===e||t instanceof n.transforms.proxy)}function P(e,n,r,i){var a=e.element();a&&a.setAttribute("title",function(e){return null==e?"":t.isArray(e)?B(e):t.isObject(e)&&!t.isDate(e)?(n=e,Object.keys(n).map((function(e){var r=n[e];return e+": "+(t.isArray(r)?B(r):G(r))})).join("\n")):e+"";var n}(i))}function B(e){return"["+e.map(G).join(", ")+"]"}function G(e){return t.isArray(e)?"[…]":t.isObject(e)&&!t.isDate(e)?"{…}":e}function I(e,i){const o=this;if(i=i||{},n.Dataflow.call(o),i.loader&&o.loader(i.loader),i.logger&&o.logger(i.logger),null!=i.logLevel&&o.logLevel(i.logLevel),i.locale||e.locale){const n=t.extend({},e.locale,i.locale);o.locale(u.locale(n.number,n.time))}o._el=null,o._elBind=null,o._renderType=i.renderer||r.RenderType.Canvas,o._scenegraph=new r.Scenegraph;const l=o._scenegraph.root;o._renderer=null,o._tooltip=i.tooltip||P,o._redraw=!0,o._handler=(new r.CanvasHandler).scene(l),o._globalCursor=!1,o._preventDefault=!1,o._timers=[],o._eventListeners=[],o._resizeListeners=[],o._eventConfig=function(e){const n=t.extend({defaults:{}},e),r=(e,n)=>{n.forEach(n=>{t.isArray(e[n])&&(e[n]=t.toSet(e[n]))})};return r(n.defaults,["prevent","allow"]),r(n,["view","window","selector"]),n}(e.eventConfig),o.globalCursor(o._eventConfig.globalCursor);const c=function(e,t,r){return s.context(e,n.transforms,a.functionContext,r).parse(t)}(o,e,i.expr);o._runtime=c,o._signals=c.signals,o._bind=(e.bindings||[]).map(e=>({state:null,param:t.extend({},e)})),c.root&&c.root.set(l),l.source=c.data.root.input,o.pulse(c.data.root.input,o.changeset().insert(l.items)),o._width=o.width(),o._height=o.height(),o._viewWidth=q(o,o._width),o._viewHeight=M(o,o._height),o._origin=[0,0],o._resize=0,o._autosize=1,function(e){var t=e._signals,n=t.width,r=t.height,i=t.padding;function a(){e._autosize=e._resize=1}e._resizeWidth=e.add(null,(function(t){e._width=t.size,e._viewWidth=q(e,t.size),a()}),{size:n}),e._resizeHeight=e.add(null,(function(t){e._height=t.size,e._viewHeight=M(e,t.size),a()}),{size:r});var s=e.add(null,a,{pad:i});e._resizeWidth.rank=n.rank+1,e._resizeHeight.rank=r.rank+1,s.rank=i.rank+1}(o),function(e){e.add(null,t=>(e._background=t.bg,e._resize=1,t.bg),{bg:e._signals.background})}(o),function(e){const n=e._signals.cursor||(e._signals.cursor=e.add({user:"default",item:null}));e.on(e.events("view","mousemove"),n,(function(e,r){const i=n.value,a=i?t.isString(i)?i:i.user:"default",s=r.item&&r.item.cursor||null;return i&&a===i.user&&s==i.item?i:{user:a,item:s}})),e.add(null,(function(n){let r=n.cursor,i=this.value;return t.isString(r)||(i=r.item,r=r.user),d(e,r&&"default"!==r?r:i||r),i}),{cursor:n})}(o),o.description(e.description),i.hover&&o.hover(),i.container&&o.initialize(i.container,i.bind)}function $(e,n){return t.hasOwnProperty(e._signals,n)?e._signals[n]:t.error("Unrecognized signal name: "+t.stringValue(n))}function N(e,t){const n=(e._targets||[]).filter(e=>e._update&&e._update.handler===t);return n.length?n[0]:null}function F(e,t,n,r){var i=N(n,r);return i||((i=R(e,()=>r(t,n.value))).handler=r,e.on(n,null,i)),e}function J(e,t,n){var r=N(t,n);return r&&t._targets.remove(r),e}t.inherits(I,n.Dataflow,{async evaluate(e,t,r){if(await n.Dataflow.prototype.evaluate.call(this,e,t),this._redraw||this._resize)try{this._renderer&&(this._resize&&(this._resize=0,a=p(i=this),s=g(i),o=f(i),i._renderer.background(i.background()),i._renderer.resize(s,o,a),i._handler.origin(a),i._resizeListeners.forEach((function(e){try{e(s,o)}catch(e){i.error(e)}}))),await this._renderer.renderAsync(this._scenegraph.root)),this._redraw=!1}catch(e){this.error(e)}var i,a,s,o;return r&&n.asyncCallback(this,r),this},dirty(e){this._redraw=!0,this._renderer&&this._renderer.dirty(e)},description(e){if(arguments.length){const t=null!=e?e+"":null;return t!==this._desc&&l(this._el,this._desc=t),this}return this._desc},container(){return this._el},scenegraph(){return this._scenegraph},origin(){return this._origin.slice()},signal(e,t,n){var r=$(this,e);return 1===arguments.length?r.value:this.update(r,t,n)},width(e){return arguments.length?this.signal("width",e):this.signal("width")},height(e){return arguments.length?this.signal("height",e):this.signal("height")},padding(e){return arguments.length?this.signal("padding",j(e)):j(this.signal("padding"))},autosize(e){return arguments.length?this.signal("autosize",e):this.signal("autosize")},background(e){return arguments.length?this.signal("background",e):this.signal("background")},renderer(e){return arguments.length?(r.renderModule(e)||t.error("Unrecognized renderer type: "+e),e!==this._renderType&&(this._renderType=e,this._resetRenderer()),this):this._renderType},tooltip(e){return arguments.length?(e!==this._tooltip&&(this._tooltip=e,this._resetRenderer()),this):this._tooltip},loader(e){return arguments.length?(e!==this._loader&&(n.Dataflow.prototype.loader.call(this,e),this._resetRenderer()),this):this._loader},resize(){return this._autosize=1,this.touch($(this,"autosize"))},_resetRenderer(){this._renderer&&(this._renderer=null,this.initialize(this._el,this._elBind))},_resizeView:function(e,t,n,r,i,a){this.runAfter((function(s){var o=0;s._autosize=0,s.width()!==n&&(o=1,s.signal("width",n,U),s._resizeWidth.skip(!0)),s.height()!==r&&(o=1,s.signal("height",r,U),s._resizeHeight.skip(!0)),s._viewWidth!==e&&(s._resize=1,s._viewWidth=e),s._viewHeight!==t&&(s._resize=1,s._viewHeight=t),s._origin[0]===i[0]&&s._origin[1]===i[1]||(s._resize=1,s._origin=i),o&&s.run("enter"),a&&s.runAfter(e=>e.resize())}),!1,1)},addEventListener(e,t,n){var r=t;return n&&!1===n.trap||((r=R(this,t)).raw=t),this._handler.on(e,r),this},removeEventListener(e,t){for(var n,r,i=this._handler.handlers(e),a=i.length;--a>=0;)if(r=i[a].type,n=i[a].handler,e===r&&(t===n||t===n.raw)){this._handler.off(r,n);break}return this},addResizeListener(e){var t=this._resizeListeners;return t.indexOf(e)<0&&t.push(e),this},removeResizeListener(e){var t=this._resizeListeners,n=t.indexOf(e);return n>=0&&t.splice(n,1),this},addSignalListener(e,t){return F(this,e,$(this,e),t)},removeSignalListener(e,t){return J(this,$(this,e),t)},addDataListener(e,t){return F(this,e,c(this,e).values,t)},removeDataListener(e,t){return J(this,c(this,e).values,t)},globalCursor(e){if(arguments.length){if(this._globalCursor!==!!e){const t=d(this,null);this._globalCursor=!!e,t&&d(this,t)}return this}return this._globalCursor},preventDefault(e){return arguments.length?(this._preventDefault=e,this):this._preventDefault},timer:function(e,t){this._timers.push(o.interval((function(t){e({timestamp:Date.now(),elapsed:t})}),t))},events:function(e,t,r){var i,a=this,s=new n.EventStream(r),o=function(n,r){a.runAsync(null,()=>{"view"===e&&function(e,t){var n=e._eventConfig.defaults,r=n.prevent,i=n.allow;return!1!==r&&!0!==i&&(!0===r||!1===i||(r?r[t]:i?!i[t]:e.preventDefault()))}(a,t)&&n.preventDefault(),s.receive(v(a,n,r))})};if("timer"===e)m(a,"timer",t)&&a.timer(o,t);else if("view"===e)m(a,"view",t)&&a.addEventListener(t,o,_);else if("window"===e?m(a,"window",t)&&"undefined"!=typeof window&&(i=[window]):"undefined"!=typeof document&&m(a,"selector",t)&&(i=document.querySelectorAll(e)),i){for(var u=0,l=i.length;u<l;++u)i[u].addEventListener(t,o);a._eventListeners.push({type:t,sources:i,handler:o})}else a.warn("Can not resolve event source: "+e);return s},finalize:function(){var e,t,n,r=this._tooltip,i=this._timers,a=this._eventListeners;for(e=i.length;--e>=0;)i[e].stop();for(e=a.length;--e>=0;)for(t=(n=a[e]).sources.length;--t>=0;)n.sources[t].removeEventListener(n.type,n.handler);return r&&r.call(this,this._handler,null,null,null),this},hover:function(e,t){return t=[t||"update",(e=[e||"hover"])[0]],this.on(this.events("view","mouseover",y),w,b(e)),this.on(this.events("view","mouseout",y),w,b(t)),this},data:function(e,r){return arguments.length<2?c(this,e).values.value:h.call(this,e,n.changeset().remove(t.truthy).insert(r))},change:h,insert:function(e,t){return h.call(this,e,n.changeset().insert(t))},remove:function(e,t){return h.call(this,e,n.changeset().remove(t))},scale:function(e){var n=this._runtime.scales;return t.hasOwnProperty(n,e)||t.error("Unrecognized scale or projection: "+e),n[e].value},initialize:function(e,t){const n=this,i=n._renderType,a=n._eventConfig.bind,s=r.renderModule(i);e=n._el=e?T(n,e):null,function(e){const t=e.container();t&&(t.setAttribute("role","graphics-document"),t.setAttribute("aria-roleDescription","visualization"),l(t,e.description()))}(n),s||n.error("Unrecognized renderer type: "+i);const o=s.handler||r.CanvasHandler,u=e?s.renderer:s.headless;return n._renderer=u?D(n,n._renderer,e,u):null,n._handler=function(e,t,n,r){var i=new r(e.loader(),R(e,e.tooltip())).scene(e.scenegraph().root).initialize(n,p(e),e);return t&&t.handlers().forEach((function(e){i.on(e.type,e.handler)})),i}(n,n._handler,e,o),n._redraw=!0,e&&"none"!==a&&(t=t?n._elBind=T(n,t):e.appendChild(z("form",{class:"vega-bindings"})),n._bind.forEach((function(e){e.param.element&&"container"!==a&&(e.element=T(n,e.param.element))})),n._bind.forEach((function(e){k(n,e.element||t,e)}))),n},toImageURL:async function(e,n){e!==r.RenderType.Canvas&&e!==r.RenderType.SVG&&e!==r.RenderType.PNG&&t.error("Unrecognized image type: "+e);const i=await H(this,e,n);return e===r.RenderType.SVG?function(e,t){var n=new Blob([e],{type:t});return window.URL.createObjectURL(n)}(i.svg(),"image/svg+xml"):i.canvas().toDataURL("image/png")},toCanvas:async function(e,t){return(await H(this,r.RenderType.Canvas,e,t)).canvas()},toSVG:async function(e){return(await H(this,r.RenderType.SVG,e)).svg()},getState:function(e){return this._runtime.getState(e||{data:W,signals:V,recurse:!0})},setState:function(e){return this.runAsync(null,t=>{t._trigger=!1,t._runtime.setState(e)},e=>{e._trigger=!0}),this}}),e.View=I,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-dataflow"),require("vega-scenegraph"),require("d3-array"),require("vega-functions"),require("vega-runtime"),require("d3-timer"),require("vega-format")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-dataflow","vega-scenegraph","d3-array","vega-functions","vega-runtime","d3-timer","vega-format"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vega={},e.vega,e.vega,e.vega,e.d3,e.vega,e.vega,e.d3,e.vega)}(this,(function(e,t,n,r,i,a,s,o,u){"use strict";function l(e,t){e&&(null==t?e.removeAttribute("aria-label"):e.setAttribute("aria-label",t))}const d="default";function c(e,t){const n=e.globalCursor()?"undefined"!=typeof document&&document.body:e.container();if(n)return null==t?n.style.removeProperty("cursor"):n.style.cursor=t}function h(e,n){var r=e._runtime.data;return t.hasOwnProperty(r,n)||t.error("Unrecognized data set: "+n),r[n]}function g(e,r){n.isChangeSet(r)||t.error("Second argument to changes must be a changeset.");var i=h(this,e);return i.modified=!0,this.pulse(i.input,r)}function p(e){var t=e.padding();return Math.max(0,e._viewWidth+t.left+t.right)}function f(e){var t=e.padding();return Math.max(0,e._viewHeight+t.top+t.bottom)}function v(e){var t=e.padding(),n=e._origin;return[t.left+n[0],t.top+n[1]]}function _(e,n,i){var a,s,o,u=e._renderer,l=u&&u.canvas();return l&&(o=v(e),s=n.changedTouches?n.changedTouches[0]:n,(a=r.point(s,l))[0]-=o[0],a[1]-=o[1]),n.dataflow=e,n.item=i,n.vega=function(e,n,r){var i=n?"group"===n.mark.marktype?n:n.mark.group:null;function a(e){var t,r=i;if(e)for(t=n;t;t=t.mark.group)if(t.mark.name===e){r=t;break}return r&&r.mark&&r.mark.interactive?r:{}}function s(e){if(!e)return r;t.isString(e)&&(e=a(e));for(var n=r.slice();e;)n[0]-=e.x||0,n[1]-=e.y||0,e=e.mark&&e.mark.group;return n}return{view:t.constant(e),item:t.constant(n||{}),group:a,xy:s,x:function(e){return s(e)[0]},y:function(e){return s(e)[1]}}}(e,i,a),n}const m="view",y={trap:!1};function w(e,n,r){const i=e._eventConfig&&e._eventConfig[n];return!(!1===i||t.isObject(i)&&!i[r])||(e.warn(`Blocked ${n} ${r} event listener.`),!1)}function b(e){return e.item}function z(e){return e.item.mark.source}function k(e){return function(t,n){return n.vega.view().changeset().encode(n.item,e)}}function C(e,t,n){var r=document.createElement(e);for(var i in t)r.setAttribute(i,t[i]);return null!=n&&(r.textContent=n),r}const L="vega-bind",x="vega-bind-name";function A(e,n,r){if(!n)return;const i=r.param;let a=r.state;return a||(a=r.state={elements:null,active:!1,set:null,update:t=>{t!==e.signal(i.signal)&&e.runAsync(null,()=>{a.source=!0,e.signal(i.signal,t)})}},i.debounce&&(a.update=t.debounce(i.debounce,a.update))),function(e,t,n,r){const i=C("div",{class:L}),a="radio"===n.input?i:i.appendChild(C("label"));a.appendChild(C("span",{class:x},n.name||n.signal)),t.appendChild(i);let s=S;switch(n.input){case"checkbox":s=E;break;case"select":s=D;break;case"radio":s=R;break;case"range":s=T}s(e,a,n,r)}(a,n,i,e.signal(i.signal)),a.active||(e.on(e._signals[i.signal],null,()=>{a.source?a.source=!1:a.set(e.signal(i.signal))}),a.active=!0),a}function S(e,t,n,r){const i=C("input");for(const e in n)"signal"!==e&&"element"!==e&&i.setAttribute("input"===e?"type":e,n[e]);i.setAttribute("name",n.signal),i.value=r,t.appendChild(i),i.addEventListener("input",()=>e.update(i.value)),e.elements=[i],e.set=e=>i.value=e}function E(e,t,n,r){const i={type:"checkbox",name:n.signal};r&&(i.checked=!0);const a=C("input",i);t.appendChild(a),a.addEventListener("change",()=>e.update(a.checked)),e.elements=[a],e.set=e=>a.checked=!!e||null}function D(e,t,n,r){const i=C("select",{name:n.signal}),a=n.labels||[];n.options.forEach((e,t)=>{const n={value:e};O(e,r)&&(n.selected=!0),i.appendChild(C("option",n,(a[t]||e)+""))}),t.appendChild(i),i.addEventListener("change",()=>{e.update(n.options[i.selectedIndex])}),e.elements=[i],e.set=e=>{for(let t=0,r=n.options.length;t<r;++t)if(O(n.options[t],e))return void(i.selectedIndex=t)}}function R(e,t,n,r){const i=C("span",{class:"vega-bind-radio"}),a=n.labels||[];t.appendChild(i),e.elements=n.options.map((t,s)=>{const o={type:"radio",name:n.signal,value:t};O(t,r)&&(o.checked=!0);const u=C("input",o);u.addEventListener("change",()=>e.update(t));const l=C("label",{},(a[s]||t)+"");return l.prepend(u),i.appendChild(l),u}),e.set=t=>{const n=e.elements,r=n.length;for(let e=0;e<r;++e)O(n[e].value,t)&&(n[e].checked=!0)}}function T(e,t,n,r){r=void 0!==r?r:(+n.max+ +n.min)/2;const a=null!=n.max?n.max:Math.max(100,+r)||100,s=n.min||Math.min(0,a,+r)||0,o=n.step||i.tickStep(s,a,100),u=C("input",{type:"range",name:n.signal,min:s,max:a,step:o});u.value=r;const l=C("span",{},+r);t.appendChild(u),t.appendChild(l);const d=()=>{l.textContent=u.value,e.update(+u.value)};u.addEventListener("input",d),u.addEventListener("change",d),e.elements=[u],e.set=e=>{u.value=e,l.textContent=e}}function O(e,t){return e===t||e+""==t+""}function j(e,t,n,r,i,a){return(t=t||new r(e.loader())).initialize(n,p(e),f(e),v(e),i,a).background(e.background())}function H(e,t){return t?function(){try{t.apply(this,arguments)}catch(t){e.error(t)}}:null}function U(e,t){if("string"==typeof t){if("undefined"==typeof document)return e.error("DOM document instance not found."),null;if(!(t=document.querySelector(t)))return e.error("Signal bind element not found: "+t),null}if(t)try{t.innerHTML=""}catch(n){t=null,e.error(n)}return t}const q=e=>+e||0;function M(e){return t.isObject(e)?{top:q(e.top),bottom:q(e.bottom),left:q(e.left),right:q(e.right)}:(e=>({top:e,bottom:e,left:e,right:e}))(q(e))}async function W(e,n,i,a){const s=r.renderModule(n),o=s&&s.headless;return o||t.error("Unrecognized renderer type: "+n),await e.runAsync(),j(e,null,null,o,i,a).renderAsync(e._scenegraph.root)}var V="width",P="height",B="padding",G={skip:!0};function I(e,t){var n=e.autosize(),r=e.padding();return t-(n&&n.contains===B?r.left+r.right:0)}function $(e,t){var n=e.autosize(),r=e.padding();return t-(n&&n.contains===B?r.top+r.bottom:0)}function N(e,n){return n.modified&&t.isArray(n.input.value)&&e.indexOf("_:vega:_")}function F(e,t){return!("parent"===e||t instanceof n.transforms.proxy)}function J(e,n,r,i){var a=e.element();a&&a.setAttribute("title",function(e){return null==e?"":t.isArray(e)?K(e):t.isObject(e)&&!t.isDate(e)?(n=e,Object.keys(n).map(e=>{var r=n[e];return e+": "+(t.isArray(r)?K(r):Q(r))}).join("\n")):e+"";var n}(i))}function K(e){return"["+e.map(Q).join(", ")+"]"}function Q(e){return t.isArray(e)?"[…]":t.isObject(e)&&!t.isDate(e)?"{…}":e}function X(e,i){const o=this;if(i=i||{},n.Dataflow.call(o),i.loader&&o.loader(i.loader),i.logger&&o.logger(i.logger),null!=i.logLevel&&o.logLevel(i.logLevel),i.locale||e.locale){const n=t.extend({},e.locale,i.locale);o.locale(u.locale(n.number,n.time))}o._el=null,o._elBind=null,o._renderType=i.renderer||r.RenderType.Canvas,o._scenegraph=new r.Scenegraph;const l=o._scenegraph.root;o._renderer=null,o._tooltip=i.tooltip||J,o._redraw=!0,o._handler=(new r.CanvasHandler).scene(l),o._globalCursor=!1,o._preventDefault=!1,o._timers=[],o._eventListeners=[],o._resizeListeners=[],o._eventConfig=function(e){const n=t.extend({defaults:{}},e),r=(e,n)=>{n.forEach(n=>{t.isArray(e[n])&&(e[n]=t.toSet(e[n]))})};return r(n.defaults,["prevent","allow"]),r(n,["view","window","selector"]),n}(e.eventConfig),o.globalCursor(o._eventConfig.globalCursor);const h=function(e,t,r){return s.context(e,n.transforms,a.functionContext,r).parse(t)}(o,e,i.expr);o._runtime=h,o._signals=h.signals,o._bind=(e.bindings||[]).map(e=>({state:null,param:t.extend({},e)})),h.root&&h.root.set(l),l.source=h.data.root.input,o.pulse(h.data.root.input,o.changeset().insert(l.items)),o._width=o.width(),o._height=o.height(),o._viewWidth=I(o,o._width),o._viewHeight=$(o,o._height),o._origin=[0,0],o._resize=0,o._autosize=1,function(e){var t=e._signals,n=t.width,r=t.height,i=t.padding;function a(){e._autosize=e._resize=1}e._resizeWidth=e.add(null,t=>{e._width=t.size,e._viewWidth=I(e,t.size),a()},{size:n}),e._resizeHeight=e.add(null,t=>{e._height=t.size,e._viewHeight=$(e,t.size),a()},{size:r});var s=e.add(null,a,{pad:i});e._resizeWidth.rank=n.rank+1,e._resizeHeight.rank=r.rank+1,s.rank=i.rank+1}(o),function(e){e.add(null,t=>(e._background=t.bg,e._resize=1,t.bg),{bg:e._signals.background})}(o),function(e){const n=e._signals.cursor||(e._signals.cursor=e.add({user:d,item:null}));e.on(e.events("view","mousemove"),n,(e,r)=>{const i=n.value,a=i?t.isString(i)?i:i.user:d,s=r.item&&r.item.cursor||null;return i&&a===i.user&&s==i.item?i:{user:a,item:s}}),e.add(null,(function(n){let r=n.cursor,i=this.value;return t.isString(r)||(i=r.item,r=r.user),c(e,r&&r!==d?r:i||r),i}),{cursor:n})}(o),o.description(e.description),i.hover&&o.hover(),i.container&&o.initialize(i.container,i.bind)}function Y(e,n){return t.hasOwnProperty(e._signals,n)?e._signals[n]:t.error("Unrecognized signal name: "+t.stringValue(n))}function Z(e,t){const n=(e._targets||[]).filter(e=>e._update&&e._update.handler===t);return n.length?n[0]:null}function ee(e,t,n,r){var i=Z(n,r);return i||((i=H(e,()=>r(t,n.value))).handler=r,e.on(n,null,i)),e}function te(e,t,n){var r=Z(t,n);return r&&t._targets.remove(r),e}t.inherits(X,n.Dataflow,{async evaluate(e,t,r){if(await n.Dataflow.prototype.evaluate.call(this,e,t),this._redraw||this._resize)try{this._renderer&&(this._resize&&(this._resize=0,a=v(i=this),s=p(i),o=f(i),i._renderer.background(i.background()),i._renderer.resize(s,o,a),i._handler.origin(a),i._resizeListeners.forEach(e=>{try{e(s,o)}catch(e){i.error(e)}})),await this._renderer.renderAsync(this._scenegraph.root)),this._redraw=!1}catch(e){this.error(e)}var i,a,s,o;return r&&n.asyncCallback(this,r),this},dirty(e){this._redraw=!0,this._renderer&&this._renderer.dirty(e)},description(e){if(arguments.length){const t=null!=e?e+"":null;return t!==this._desc&&l(this._el,this._desc=t),this}return this._desc},container(){return this._el},scenegraph(){return this._scenegraph},origin(){return this._origin.slice()},signal(e,t,n){var r=Y(this,e);return 1===arguments.length?r.value:this.update(r,t,n)},width(e){return arguments.length?this.signal("width",e):this.signal("width")},height(e){return arguments.length?this.signal("height",e):this.signal("height")},padding(e){return arguments.length?this.signal("padding",M(e)):M(this.signal("padding"))},autosize(e){return arguments.length?this.signal("autosize",e):this.signal("autosize")},background(e){return arguments.length?this.signal("background",e):this.signal("background")},renderer(e){return arguments.length?(r.renderModule(e)||t.error("Unrecognized renderer type: "+e),e!==this._renderType&&(this._renderType=e,this._resetRenderer()),this):this._renderType},tooltip(e){return arguments.length?(e!==this._tooltip&&(this._tooltip=e,this._resetRenderer()),this):this._tooltip},loader(e){return arguments.length?(e!==this._loader&&(n.Dataflow.prototype.loader.call(this,e),this._resetRenderer()),this):this._loader},resize(){return this._autosize=1,this.touch(Y(this,"autosize"))},_resetRenderer(){this._renderer&&(this._renderer=null,this.initialize(this._el,this._elBind))},_resizeView:function(e,t,n,r,i,a){this.runAfter(s=>{var o=0;s._autosize=0,s.width()!==n&&(o=1,s.signal(V,n,G),s._resizeWidth.skip(!0)),s.height()!==r&&(o=1,s.signal(P,r,G),s._resizeHeight.skip(!0)),s._viewWidth!==e&&(s._resize=1,s._viewWidth=e),s._viewHeight!==t&&(s._resize=1,s._viewHeight=t),s._origin[0]===i[0]&&s._origin[1]===i[1]||(s._resize=1,s._origin=i),o&&s.run("enter"),a&&s.runAfter(e=>e.resize())},!1,1)},addEventListener(e,t,n){var r=t;return n&&!1===n.trap||((r=H(this,t)).raw=t),this._handler.on(e,r),this},removeEventListener(e,t){for(var n,r,i=this._handler.handlers(e),a=i.length;--a>=0;)if(r=i[a].type,n=i[a].handler,e===r&&(t===n||t===n.raw)){this._handler.off(r,n);break}return this},addResizeListener(e){var t=this._resizeListeners;return t.indexOf(e)<0&&t.push(e),this},removeResizeListener(e){var t=this._resizeListeners,n=t.indexOf(e);return n>=0&&t.splice(n,1),this},addSignalListener(e,t){return ee(this,e,Y(this,e),t)},removeSignalListener(e,t){return te(this,Y(this,e),t)},addDataListener(e,t){return ee(this,e,h(this,e).values,t)},removeDataListener(e,t){return te(this,h(this,e).values,t)},globalCursor(e){if(arguments.length){if(this._globalCursor!==!!e){const t=c(this,null);this._globalCursor=!!e,t&&c(this,t)}return this}return this._globalCursor},preventDefault(e){return arguments.length?(this._preventDefault=e,this):this._preventDefault},timer:function(e,t){this._timers.push(o.interval((function(t){e({timestamp:Date.now(),elapsed:t})}),t))},events:function(e,t,r){var i,a=this,s=new n.EventStream(r),o=function(n,r){a.runAsync(null,()=>{e===m&&function(e,t){var n=e._eventConfig.defaults,r=n.prevent,i=n.allow;return!1!==r&&!0!==i&&(!0===r||!1===i||(r?r[t]:i?!i[t]:e.preventDefault()))}(a,t)&&n.preventDefault(),s.receive(_(a,n,r))})};if("timer"===e)w(a,"timer",t)&&a.timer(o,t);else if(e===m)w(a,"view",t)&&a.addEventListener(t,o,y);else if("window"===e?w(a,"window",t)&&"undefined"!=typeof window&&(i=[window]):"undefined"!=typeof document&&w(a,"selector",t)&&(i=document.querySelectorAll(e)),i){for(var u=0,l=i.length;u<l;++u)i[u].addEventListener(t,o);a._eventListeners.push({type:t,sources:i,handler:o})}else a.warn("Can not resolve event source: "+e);return s},finalize:function(){var e,t,n,r=this._tooltip,i=this._timers,a=this._eventListeners;for(e=i.length;--e>=0;)i[e].stop();for(e=a.length;--e>=0;)for(t=(n=a[e]).sources.length;--t>=0;)n.sources[t].removeEventListener(n.type,n.handler);return r&&r.call(this,this._handler,null,null,null),this},hover:function(e,t){return t=[t||"update",(e=[e||"hover"])[0]],this.on(this.events("view","mouseover",b),z,k(e)),this.on(this.events("view","mouseout",b),z,k(t)),this},data:function(e,r){return arguments.length<2?h(this,e).values.value:g.call(this,e,n.changeset().remove(t.truthy).insert(r))},change:g,insert:function(e,t){return g.call(this,e,n.changeset().insert(t))},remove:function(e,t){return g.call(this,e,n.changeset().remove(t))},scale:function(e){var n=this._runtime.scales;return t.hasOwnProperty(n,e)||t.error("Unrecognized scale or projection: "+e),n[e].value},initialize:function(e,t){const n=this,i=n._renderType,a=n._eventConfig.bind,s=r.renderModule(i);e=n._el=e?U(n,e):null,function(e){const t=e.container();t&&(t.setAttribute("role","graphics-document"),t.setAttribute("aria-roleDescription","visualization"),l(t,e.description()))}(n),s||n.error("Unrecognized renderer type: "+i);const o=s.handler||r.CanvasHandler,u=e?s.renderer:s.headless;return n._renderer=u?j(n,n._renderer,e,u):null,n._handler=function(e,t,n,r){var i=new r(e.loader(),H(e,e.tooltip())).scene(e.scenegraph().root).initialize(n,v(e),e);return t&&t.handlers().forEach(e=>{i.on(e.type,e.handler)}),i}(n,n._handler,e,o),n._redraw=!0,e&&"none"!==a&&(t=t?n._elBind=U(n,t):e.appendChild(C("form",{class:"vega-bindings"})),n._bind.forEach(e=>{e.param.element&&"container"!==a&&(e.element=U(n,e.param.element))}),n._bind.forEach(e=>{A(n,e.element||t,e)})),n},toImageURL:async function(e,n){e!==r.RenderType.Canvas&&e!==r.RenderType.SVG&&e!==r.RenderType.PNG&&t.error("Unrecognized image type: "+e);const i=await W(this,e,n);return e===r.RenderType.SVG?function(e,t){var n=new Blob([e],{type:t});return window.URL.createObjectURL(n)}(i.svg(),"image/svg+xml"):i.canvas().toDataURL("image/png")},toCanvas:async function(e,t){return(await W(this,r.RenderType.Canvas,e,t)).canvas()},toSVG:async function(e){return(await W(this,r.RenderType.SVG,e)).svg()},getState:function(e){return this._runtime.getState(e||{data:N,signals:F,recurse:!0})},setState:function(e){return this.runAsync(null,t=>{t._trigger=!1,t._runtime.setState(e)},e=>{e._trigger=!0}),this}}),e.View=X,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "vega-view",
"version": "5.8.1",
"version": "5.8.2",
"description": "View component and transforms for Vega visualizations.",

@@ -26,12 +26,12 @@ "keywords": [

"dependencies": {
"d3-array": "^2.5.1",
"d3-timer": "^1.0.10",
"vega-dataflow": "^5.7.1",
"vega-format": "^1.0.2",
"vega-functions": "^5.7.2",
"vega-runtime": "^6.1.1",
"vega-scenegraph": "^4.9.0",
"vega-util": "^1.15.0"
"d3-array": "^2.7.0",
"d3-timer": "^2.0.0",
"vega-dataflow": "^5.7.2",
"vega-format": "^1.0.3",
"vega-functions": "^5.7.3",
"vega-runtime": "^6.1.2",
"vega-scenegraph": "^4.9.1",
"vega-util": "^1.15.1"
},
"gitHead": "28db83352e43e321dfe55fc5cb6489b211e45662"
"gitHead": "8d6793f4ca7eaaf2d22186764e9ce2dae687cf52"
}

@@ -35,3 +35,3 @@ import element from './element';

if (value !== view.signal(param.signal)) {
view.runAsync(null, function() {
view.runAsync(null, () => {
bind.source = true;

@@ -38,0 +38,0 @@ view.signal(param.signal, value);

@@ -14,3 +14,3 @@ import {isString} from 'vega-util';

view.on(view.events('view', 'mousemove'), cursor,
function(_, event) {
(_, event) => {
const value = cursor.value,

@@ -17,0 +17,0 @@ user = value ? (isString(value) ? value : value.user) : Default,

@@ -12,3 +12,3 @@ import {offset} from './render-size';

if (prevHandler) {
prevHandler.handlers().forEach(function(h) {
prevHandler.handlers().forEach(h => {
handler.on(h.type, h.handler);

@@ -15,0 +15,0 @@ });

@@ -36,3 +36,3 @@ import {initializeAria} from './aria';

view._bind.forEach(function(_) {
view._bind.forEach(_ => {
if (_.param.element && config !== 'container') {

@@ -43,3 +43,3 @@ _.element = lookup(view, _.param.element);

view._bind.forEach(function(_) {
view._bind.forEach(_ => {
bind(view, _.element || elBind, _);

@@ -46,0 +46,0 @@ });

@@ -29,3 +29,3 @@ export function width(view) {

view._resizeListeners.forEach(function(handler) {
view._resizeListeners.forEach(handler => {
try {

@@ -32,0 +32,0 @@ handler(w, h);

@@ -30,3 +30,3 @@ var Width = 'width',

view._resizeWidth = view.add(null,
function(_) {
_ => {
view._width = _.size;

@@ -41,3 +41,3 @@ view._viewWidth = viewWidth(view, _.size);

view._resizeHeight = view.add(null,
function(_) {
_ => {
view._height = _.size;

@@ -60,3 +60,3 @@ view._viewHeight = viewHeight(view, _.size);

export function resizeView(viewWidth, viewHeight, width, height, origin, auto) {
this.runAfter(function(view) {
this.runAfter(view => {
var rerun = 0;

@@ -63,0 +63,0 @@

@@ -16,3 +16,3 @@ import {isArray, isDate, isObject} from 'vega-util';

function formatObject(obj) {
return Object.keys(obj).map(function(key) {
return Object.keys(obj).map(key => {
var v = obj[key];

@@ -19,0 +19,0 @@ return key + ': ' + (isArray(v) ? formatArray(v) : formatValue(v));

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc