/*! * Copyright 2002 - 2013 Webdetails, a Pentaho company. All rights reserved. * * This software was developed by Webdetails and is provided under the terms * of the Mozilla Public License, Version 2.0, or any later version. You may not use * this file except in compliance with the license. If you need a copy of the license, * please go to http://mozilla.org/MPL/2.0/. The Initial Developer is Webdetails. * * Software distributed under the Mozilla Public License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to * the license for the specific language governing your rights and limitations. */ /*!!*/ var pvc=function(e,t){function i(){if(Tt.debug>0&&"undefined"!=typeof console)["log","info",["trace","debug"],"error","warn",["group","groupCollapsed"],"groupEnd"].forEach(function(e){e=e instanceof Array?e:[e,e];a(Tt,e[0],e[1],"[pvChart]")});else{Tt.debug>1&&(Tt.debug=1);["log","info","trace","warn","group","groupEnd"].forEach(function(t){Tt[t]=e.noop});var i="[pvChart ERROR]: ";Tt.error=function(t){t&&"object"==typeof t&&t.message&&(t=t.message);t=""+e.nullyTo(t,"");t.indexOf(i)<0&&(t=i+t);throw new Error(t)}}Tt.logError=Tt.error;t.error=Tt.error}function n(){var e=t.Behavior.tipsy;if(e&&e.setDebug){e.setDebug(Tt.debug);e.log=Tt.log}}function a(t,i,n,a){n||(n=i);var r,s=console,o=s[n]||s.log;if(o){var l=a+": %s";if(e.fun.is(o))r=o.bind(s,l);else{var u=Function.prototype.apply;r=function(){u.call(o,s,e.array.append([l],arguments))}}}t[i]=r}function r(t,i){return t?e.object.is(t)?t.abs:i?i+e.firstUpperCase(t):t:i}function s(e){e=t.color(e);var i=e.r,n=e.g,a=e.b,r=(i+n+a)/3,s=2;return Math.abs(i-r)<=s&&Math.abs(n-r)<=s&&Math.abs(a-r)<=s }function o(t){t||e.fail.argumentRequired("keyArgs");var i=t.type||e.fail.argumentRequired("keyArgs.type");switch(i){case"linear":return new Tt.color.LinearScalesBuild(t).buildMap();case"discrete":return new Tt.color.DiscreteScalesBuild(t).buildMap();case"normal":return new Tt.color.NormalScalesBuild(t).buildMap()}throw e.error.argumentInvalid("scaleType","Unexistent scale type '{0}'.",[i])}function l(t){t||e.fail.argumentRequired("keyArgs");var i=t.type||e.fail.argumentRequired("keyArgs.type");switch(i){case"linear":return new Tt.color.LinearScalesBuild(t).build();case"discrete":return new Tt.color.DiscreteScalesBuild(t).build();case"normal":return new Tt.color.NormalScalesBuild(t).build()}throw e.error.argumentInvalid("scaleType","Unexistent scale type '{0}'.",[i])}function u(t,i){function n(e){return d[e].resolve()}function a(e,t){var i=n(e);return t&&!i.isSpecified?void 0:i.value}function r(e){return n(e).isSpecified}function s(e){return a(e,!0)}function o(t){return e.hasOwn(d,t)}function l(e){return h(e,!1) }function u(e){return h(e,!0)}function c(e){return n(e)._dv}function h(t,i){for(var n in t){var r=e.hasOwnProp.call(d,n)&&d[n];if(r){var s=t[n];void 0!==s&&r.set(s,i)}}return a}t||e.fail.argumentRequired("specs");var d={};e.each(t,function(e,t){var n=new Et(t,a,i,e);d[n.name]=n});a.option=a;a.specified=s;a.defaultValue=c;a.isSpecified=r;a.isDefined=o;a.specify=l;a.defaults=u;return a}function c(e){return function(t){for(var i=0,n=e.length;n>i;i++){var a=e[i];"string"==typeof a&&(a=this[a]);if(a.call(this,t)===!0)return!0}}}function h(e){return function(t){t.specify(e);return!0}}function d(e){return function(t){var i=e.call(this,t);if(void 0!==i){t.specify(i);return!0}}}function f(e){return function(t){var i=e.call(this,t);if(void 0!==i){t.defaultValue(i);return!0}}}function v(e,t){var i=e&&e.length;if(i){for(var n=0;i>n;n++){var a=e[n];t&&(a[t]=null);a.dispose()}e.length=0}}function p(e,t,i,n,a){i[n]=e;var r=e[t]||(e[t]=[]);null==a||a>=r.length?r.push(i):r.splice(a,0,i)}function m(t,i,n,a){var r=t[i]; if(r){var s=r.indexOf(n);s>=0&&e.array.removeAt(r,s)}n[a]=null}function g(e){this.playedVisualRoles.set(e.name,e);_.call(this.complexType,this)}function b(e){this.playedVisualRoles.rem(e.name);_.call(this.complexType,this)}function _(){this._isPctRoleDimTypeMap=null}function y(t,i){function n(){var n={},r=e.query(a.source).select(function(e){i(e,n);var t=n.series;null!=t&&null!=t.v&&(t=t.v);return t||null}).distinct().array();return a._createPlot2SeriesKeySet(t,r)}var a=this;return this._dataPartGet(n,i)}function x(e,t){return e.id-t.id}function S(e,t){return t.id-e.id}function w(){delete this.isSelected}function C(e){return e.isNull||e.isSelected}function k(e){return e.isSelected===!0}function D(e){return e.isSelected===!1}function P(e){return e.isVisible===!0}function I(e){return e.isVisible===!1}function R(e){return e.isNull===!0}function M(e){return e.isNull===!1}function T(t,i,n,a,r,s){var o;if(this.owner===this){if(null==r){var l=t._formatter;r=l?l(a,i):a}r=""+r;!r&&Tt.debug>=2&&Tt.log("Only the null value should have an empty label."); o=new Tt.data.Atom(this,a,r,i,n);s&&(o.isVirtual=!0)}else{var u=this.parent||this.linkParent;o=u._atomsByKey[n]||T.call(u,t,i,n,a,r,s)}e.array.insert(this._atoms,o,this._atomComparer);z.call(this);this._atomsByKey[n]=o;return o}function A(t){var i=t.key,n=this;if(t.dimension===n){n.owner===n||e.assert("Should be an owner dimension");i||t!==n._virtualNullAtom||(t=n.intern(null));return t}var a=!n._lazyInit;if(a){var r=n._atomsByKey[i];if(r){if(r!==t)throw e.error.operationInvalid("Atom is from a different root data.");return t}if(n.owner===n)throw e.error.operationInvalid("Atom is from a different root data.")}A.call(n.parent||n.linkParent,t);if(a){n._atomsByKey[i]=t;if(i)e.array.insert(n._atoms,t,n._atomComparer);else{n._nullAtom=t;n._atoms.unshift(t)}z.call(n)}return t}function L(t){var i=e.get(t,"visible"),n=e.get(t,"selected");return(null==i?null:!!i)+":"+(null==n?null:!!n)}function O(e){var t=this._nullAtom;if(!t){if(this.owner===this){var i=this.type._formatter,n=""+(i?i.call(null,null,e):""); t=new Tt.data.Atom(this,null,n,null,"");this.data._atomsBase[this.name]=t}else t=O.call(this.parent||this.linkParent,e);this._atomsByKey[""]=this._nullAtom=t;this._atoms.unshift(t)}return t}function V(){this.owner===this||e.assert("Can only create atoms on an owner dimension.");if(!this._virtualNullAtom){this._virtualNullAtom=new Tt.data.Atom(this,null,"",null,"");this.data._atomsBase[this.name]=this._virtualNullAtom}return this._virtualNullAtom}function N(){this.owner===this||e.assert("Can only unintern atoms of an owner dimension.");var t=this._atoms;if(t){for(var i=this._atomsByKey,n=0,a=t.length;a>n;){var r=t[n];if(r.visited){delete r.visited;n++}else if(r!==this._virtualNullAtom){t.splice(n,1);a--;var s=r.key;delete i[s];if(!s){delete this._nullAtom;this.data._atomsBase[this.name]=this._virtualNullAtom}}}z.call(this)}}function B(){var t=this._atoms;if(t){for(var i,n=this._atomsByKey,a=0,r=t.length;r>a;){var s=t[a];if(s.isVirtual){t.splice(a,1);r--;i=!0;var o=s.key||e.assert("Cannot be the null or virtual null atom."); delete n[o]}else a++}i&&z.call(this)}}function z(){this._atomVisibleDatumsCount=this._sumCache=this._visibleAtoms=this._visibleIndexes=null}function F(e){p(this,"childNodes",e,"parent");e.owner=this.owner}function E(e){p(this,"_linkChildren",e,"linkParent");e.owner=this.owner}function W(t,i){var n;if(!this._disposed&&(n=this._atomVisibleDatumsCount)){var a=t.atoms[this.name],r=a.key;e.hasOwn(this._atomsByKey,r)||e.assert("Atom must exist in this dimension.");var s=n[r];i||s>0||e.assert("Must have had accounted for at least one visible datum.");n[r]=(s||0)+(i?1:-1);this._visibleAtoms=this._sumCache=this._visibleIndexes=null}}function q(){var e=this._atomVisibleDatumsCount;if(!e){e={};this.data.datums(null,{visible:!0}).each(function(t){var i=t.atoms[this.name],n=i.key;e[n]=(e[n]||0)+1},this);this._atomVisibleDatumsCount=e}return e}function G(e){var t=[];this._atoms.forEach(function(i,n){this.isVisible(i)===e&&t.push(n)},this);return t}function H(t){return e.query(this._atoms).where(function(e){return this.isVisible(e)===t },this).array()}function j(t,i){this.insertAt(t,i);e.lazy(this,"_childrenByKey")[t.key]=t}function U(e,t){p(this,"_linkChildren",e,"linkParent",t)}function K(e){m(this,"_linkChildren",e,"linkParent")}function Q(){v(this.childNodes,"parent");this._childrenByKey=null;v(this._linkChildren,"linkParent");this._groupByCache=null;this._sumAbsCache=null}function Y(){this.isOwner()||e.fail("Can only be called on the owner data.")}function Z(t,i){!t.isNull||e.assert("Null datums do not notify selected changes");i?this._selectedNotNullDatums.set(t.id,t):this._selectedNotNullDatums.rem(t.id);this._sumAbsCache=null}function X(t,i){var n=t.id,a=this,r=e.hasOwnProp;if(r.call(a._datumsById,n)){!t.isNull||e.assert("Null datums do not notify visible changes");i?a._visibleNotNullDatums.set(n,t):a._visibleNotNullDatums.rem(n);a._sumAbsCache=null;for(var s=a._dimensionsList,o=0,l=s.length;l>o;)W.call(s[o++],t,i);s=a.childNodes;o=0;l=s.length;for(;l>o;)X.call(s[o++],t,i);s=a._linkChildren;if(s&&(l=s.length)){o=0; for(;l>o;)X.call(s[o++],t,i)}}}function J(t,i){e.string.is(t)||e.fail.argumentInvalid("groupLevelText","Invalid grouping specification.");return e.query(t.split(/\s*\|\s*/)).where(e.truthy).select(function(t){var n=Ht.exec(t)||e.fail.argumentInvalid("groupLevelText","Invalid grouping level syntax '{0}'.",[t]),a=n[1],r=(n[2]||"").toLowerCase(),s="desc"===r;return new Tt.data.GroupingDimensionSpec(a,s,i)})}function et(t,i){function n(t){if(t){var i=t.key;if(!e.hasOwnProp.call(m,i)){!u&&s&&e.hasOwnProp.call(s,i)&&(t=s[i]);var n=t.id;p.push(t);m[i]=t;g[n]=t;v&&v.push(t);tt.call(this,t,c,l);if(!t.isNull){d&&t.isSelected&&d.set(n,t);t.isVisible&&h.set(n,t)}}}}t||e.fail.argumentRequired("addDatums");var a,r,s,o,l=e.get(i,"doAtomGC",!1),u=e.get(i,"isAdditive",!1),c=!!this._dimensions,h=this._visibleNotNullDatums,d=this._selectedNotNullDatums,f=this._datums;if(f){s=this._datumsByKey;o=this._datumsById;u&&l&&f.forEach(function(e){tt.call(this,e,!1,!0)},this)}else u=!1;var v,p,m,g;if(u){v=[];p=f;g=o; m=s;this._sumAbsCache=null}else{this._datums=p=[];this._datumsById=g={};this._datumsByKey=m={};if(f){Q.call(this);h.clear();d&&d.clear()}}if(e.array.is(t)){a=0;r=t.length;for(;r>a;)n.call(this,t[a++])}else{if(!(t instanceof e.Query))throw e.error.argumentInvalid("addDatums","Argument is of invalid type.");t.each(n,this)}if(l){var b=this._dimensionsList;a=0;r=b.length;for(;r>a;)N.call(b[a++])}if(u){var _=this._linkChildren;if(_){a=0;r=_.length;for(;r>a;)it.call(_[a++],v)}}}function tt(e,t,i){var n=this._dimensionsList;n||(t=!1);if(t||i){var a,r,s,o=e.atoms,l=0;if(n){a=n.length;for(;a>l;){s=n[l++];r=o[s.name];if(r){t&&A.call(s,r);i&&(r.visited=!0)}}}else{var u=this.type.dimensionsNames();a=u.length;for(;a>l;){r=o[u[l++]];r&&(r.visited=!0)}}}}function it(t){t||e.fail.argumentRequired("newDatums");var i=this._groupOper;if(i)t=i.executeAdd(this,t);else{var n=this._wherePred;n&&(t=t.filter(n));nt.call(this,t)}var a=this._linkChildren,r=a&&a.length;if(r)for(var s=0;r>s;s++)it.call(a[s],t)}function nt(e){var t=this; t._sumAbsCache=null;for(var i=t._datums,n=t._visibleNotNullDatums,a=t._selectedNotNullDatums,r=t._datumsById,s=0,o=e.length;o>s;s++){var l=e[s],u=l.id;r[u]=l;tt.call(t,l,!0,!1);if(!l.isNull){a&&l.isSelected&&a.set(u,l);l.isVisible&&n.set(u,l)}i.push(l)}}function at(t){function i(t){if(null!=t){"object"==typeof t||e.fail.invalidArgument("datumFilter");var i={},a=!1;for(var r in t){var s=this.dimensions(r).getDistinctAtoms(e.array.as(t[r]));if(s.length){a=!0;i[r]=s}}a&&n.push(i)}}var n=[];t=e.array.as(t);t&&t.forEach(i,this);return n}function rt(t,i){var n=e.get(i,"visible"),a=e.get(i,"isNull"),r=e.get(i,"selected"),s=e.get(i,"where");null!=n&&(t=t.where(n?P:I));null!=a&&(t=t.where(a?R:M));null!=r&&(t=t.where(r?k:D));s&&(t=t.where(s));return t}function st(t,i){var n=e.get(i,"visible"),a=e.get(i,"isNull"),r=e.get(i,"selected"),s=e.get(i,"where"),o=[];null!=n&&o.unshift(n?P:I);null!=a&&o.unshift(a?R:M);null!=r&&o.unshift(r?k:D);s&&o.unshift(s);t&&o.unshift(ot(t));var l=o.length;if(l){if(1===l)return o[0]; var u=function(e){for(var t=l;t;)if(!o[--t](e))return!1;return!0};return u}}function ot(e){function t(t){for(var a=t.atoms,r=0;n>r;r++)if(i(a,e[r]))return!0;return!1}function i(e,t){for(var i in t)if(t[i].indexOf(e[i])<0)return!1;return!0}var n=e.length;return t}function lt(t,i){var n=e.array.as(e.get(i,"orderBy")),a=e.create(i||{},{orderBy:null}),r=e.query(t).selectMany(function(e,t){n&&(a.orderBy=n[t]);return ut.call(this,e,a)},this);return r.distinct(e.propGet("id"))}function ut(t,i){var n=i.orderBy;if(n){if(n.indexOf("|")>=0)throw e.error.argumentInvalid("keyArgs.orderBy","Multi-dimension order by is not supported.")}else n=Object.keys(t).sort().join(",");var a=this.groupBy(n,i),r=a.treeHeight,s=[];return e.query(function(){var i;if(this._data){if(this._datumsQuery){this._data||e.assert("Must have a current data");s.length||e.assert("Must have a parent data");!this._dimAtomsOrQuery||e.assert();if(this._datumsQuery.next()){this.item=this._datumsQuery.item;return 1}this._datumsQuery=null; i=s.pop();this._data=i.data;this._dimAtomsOrQuery=i.dimAtomsOrQuery}}else{this._data=a;this._dimAtomsOrQuery=e.query(t[a._groupLevelSpec.dimensions[0].name])}this._dimAtomsOrQuery||e.assert("Invalid programmer");this._data||e.assert("Must have a current data");for(var n=s.length;;){for(;this._dimAtomsOrQuery.next();){var o=this._dimAtomsOrQuery.item,l=this._data.child(o.key);if(l&&(r-1>n||l._datums.length)){s.push({data:this._data,dimAtomsOrQuery:this._dimAtomsOrQuery});this._data=l;if(!(r-1>n)){this._dimAtomsOrQuery=null;this._datumsQuery=e.query(l._datums);this._datumsQuery.next();this.item=this._datumsQuery.item;return 1}this._dimAtomsOrQuery=e.query(t[l._groupLevelSpec.dimensions[0].name]);n++}}if(!n)return 0;i=s.pop();this._data=i.data;this._dimAtomsOrQuery=i.dimAtomsOrQuery;n--}return 0})}function ct(e){if(this._renderId!==e){this._renderId=e;this.renderState={}}}function ht(e){var t;e&&(t=e.ownerScene)&&(e=t);var i=this._active;if(i!==e){i&&dt.call(i,!1);this._active=i=e||null;i&&dt.call(i,!0); return!0}return!1}function dt(e){this.isActive!==e&&(e?this.isActive=!0:delete this.isActive)}function ft(e,t){return function(){var i=this.vars[e];if(void 0===i){i=this[t]();void 0===i&&(i=null);this.vars[e]=i}return i}}function vt(e,i){this.event=t.event;this.pvMark=e;if(e){var n=this.sign=e.sign||null;!i&&n&&(i=n.scene());if(i)this.index=i.childIndex();else{this.index=null;i=new Tt.visual.Scene(null,{panel:this.panel})}}else{this.sign=null;this.index=null;i=new Tt.visual.Scene(null,{panel:this.panel,source:this.chart.root.data})}this.scene=i}function pt(t){var i=mt(t)||e.assert("There must exist an ancestor sign");return new Tt.visual.BasicSign(i.panel,t)}function mt(e){var t;do e=e.parent;while(!(!e||(t=e.sign)||e.proto&&(t=e.proto.sign)));return t}function gt(e){return e.isDiscrete()?"discrete":e.firstDimensionValueType()===Date?"timeSeries":"numeric"}function bt(e,t){return Tt.parseDomainScope(e,t.orientation)}function _t(t){if(t){if(e.hasOwn(Vt.namesSet,t)){var i=Tt.BasePanel["y"===this.orientation?"horizontalAlign":"verticalAlign2"]; return i[t]}Tt.debug>=2&&Tt.log(e.format("Invalid axis position value '{0}'.",[t]))}return"x"===this.orientation?"bottom":"left"}function yt(e){var t=this.option("Position");return zt.toOrtho(e,t)}function xt(e){var t=this.option("Position");return zt.to(e,{singleProp:Tt.BasePanel.orthogonalLength[t]})}function St(i){var n;if(i){var a;e.eachOwn(i,function(e,n){a=!0;i[n]=t.color(e)});a&&(n=i)}return n}function wt(){var e,i=this.scaleType;if(i)if("discrete"===i)if(0===this.index)e=Tt.createColorScheme();else{var n=this;e=function(){return n.chart._getRoleColorScale(n.role.name)}}else{ni||(ni=["red","yellow","green"].map(t.color));e=ni.slice()}else e=Tt.createColorScheme();return e}function Ct(t){if(!e.object.is(t)){var i=this.option("Position");t=(new zt).setSize(t,{singleProp:Tt.BasePanel.orthogonalLength[i]})}return t}function kt(e){var t=this.option("Position");return Tt.parseAlign(t,e)}function Dt(e){return(new zt).setSize(e,{singleProp:"width"})}function Pt(e){return e.dataPartValue}function It(e){if("trend"===this.name)return null; var t=this.option("TrendType");!t&&e&&(t=e.type);if(!t||"none"===t)return null;e=e?Object.create(e):{};var i=Tt.trends.get(t);e.info=i;e.type=t;var n=this.option("TrendLabel");e.label=null!=n?String(n):i.dataPartAtom.f;return e}function Rt(e,t){return{resolveV1:function(i){if(0===this.globalIndex){this._specifyChartOption(i,"show"+e)||i.defaultValue(t);return!0}}}}function Mt(e){return{resolveV1:function(t){this._specifyChartOption(t,"show"+e);return!0}}}Array.prototype.every||(Array.prototype.every=function(e){if(null==this)throw new TypeError;var t=Object(this),i=t.length>>>0;if("function"!=typeof e)throw new TypeError;for(var n=arguments.length>=2?arguments[1]:void 0,a=0;i>a;a++)if(a in t&&!e.call(n,t[a],a,t))return!1;return!0});var Tt=e.globalSpace("pvc",{debug:0});!function(){if("undefined"!=typeof window&&window.location){var e=function(e){return e&&/\bdebug=true\b/.test(e)?e:null},t=e(window.location.href);if(!t)try{t=e(window.top.location.href)}catch(i){}if(t){var n=/\bdebugLevel=(\d+)/.exec(t); Tt.debug=n?+n[1]:3}}}();var At=t.Mark;Tt.invisibleFill="rgba(127,127,127,0.00001)";Tt.logSeparator="------------------------------------------";var Lt=Array.prototype.slice;Tt.setDebug=function(e){e=+e;Tt.debug=isNaN(e)?0:e;i();n();return Tt.debug};Tt.setDebug(Tt.debug);Tt.defaultCompatVersion=function(e){var t=Tt.BaseChart.prototype.defaults;return null!=e?t.compatVersion=e:t.compatVersion};Tt.cloneMatrix=function(e){return e.map(function(e){return e.slice()})};Tt.normAngle=t.Shape.normalizeAngle;Tt.stringify=function(t,i){var n=e.get(i,"maxLevel")||5,a=[];Tt.stringifyRecursive(a,t,n,i);return a.join("")};Tt.stringifyRecursive=function(t,i,n,a){if(n>0){n--;switch(typeof i){case"undefined":return t.push("undefined");case"object":if(!i){t.push("null");return!0}if(e.fun.is(i.stringify))return i.stringify(t,n,a);if(i instanceof Array){t.push("[");i.forEach(function(e,i){i&&t.push(", ");Tt.stringifyRecursive(t,e,n,a)||t.pop()});t.push("]")}else{var r=e.get(a,"ownOnly",!0);if(i===e.global){t.push(""); return!0}if(e.fun.is(i.cloneNode)){t.push("");return!0}if(n>1&&i.constructor!==Object){n=1;r=!0}t.push("{");var s=!0;for(var o in i)if(!r||e.hasOwnProp.call(i,o)){s||t.push(", ");t.push(o+": ");if(Tt.stringifyRecursive(t,i[o],n,a))s&&(s=!1);else{t.pop();s||t.pop()}}if(s){var l=""+i;"[object Object]"!==l&&t.push("{"+l+"}")}t.push("}")}return!0;case"number":t.push(""+Math.round(1e5*i)/1e5);return!0;case"boolean":t.push(""+i);return!0;case"string":t.push(JSON.stringify(i));return!0;case"function":if(e.get(a,"funs",!1)){t.push(JSON.stringify(i.toString().substr(0,13)+"..."));return!0}return!1}t.push("'new ???'");return!0}};Tt.orientation={vertical:"vertical",horizontal:"horizontal"};Tt.extensionTag="extension";Tt.extendType=function(t,i,n){if(i){var a,r=t.prototype._vars,s=function(t,i){if(void 0!==t){a||(a={});r&&r[i]&&(i="_"+i+"EvalCore");a[i]=e.fun.to(t)}};n?n.forEach(function(e){s(i[e],e)}):e.each(s);a&&t.add(a)}};t.Color.prototype.stringify=function(e,t,i){return Tt.stringifyRecursive(e,this.key,t,i) };At.prototype.hasDelegateValue=function(e,t){var i=this.$propertiesMap[e];return i?!t||i.tag===t:this.proto?this.proto.hasDelegateValue(e,t):!1};Tt.defaultColorScheme=null;Tt.brighterColorTransform=function(e){return(e.rgb?e:t.color(e)).brighter(.6)};Tt.setDefaultColorScheme=function(e){return Tt.defaultColorScheme=Tt.colorScheme(e)};Tt.defaultColor=t.Colors.category10()("?");Tt.colorScheme=function(i){if(null==i)return null;if("function"==typeof i){if(!i.hasOwnProperty("range"))return i;i=i.range()}else i=e.array.as(i);return i.length?function(){var e=t.colors(i);e.domain.apply(e,arguments);return e}:null},Tt.createColorScheme=function(e){return Tt.colorScheme(e)||Tt.defaultColorScheme||t.Colors.category10};Tt.toGrayScale=function(e,i,n,a){e=t.color(e);var r=.299*e.r+.587*e.g+.114*e.b;void 0===n?n=200:null==n&&(n=255);void 0===a?a=30:null==a&&(a=0);var s=n-a;r=0>=s?n:a+r/255*s;null==i?i=e.opacity:0>i&&(i=-i*e.opacity);r=Math.round(r);return t.rgb(r,r,r,i)};Tt.removeTipsyLegends=function(){try{$(".tipsy").remove() }catch(e){}};Tt.createDateComparer=function(e,i){i||(i=t.identity);return function(t,n){return e.parse(i(t))-e.parse(i(n))}};Tt.time={intervals:{y:31536e6,m:2592e6,d30:2592e6,w:6048e5,d7:6048e5,d:864e5,h:36e5,M:6e4,s:1e3,ms:1},withoutTime:function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())},weekday:{previousOrSelf:function(e,t){var i=e.getDay(),n=i-t;if(n){var a=0>n?7+n:n;e=new Date(e-a*Tt.time.intervals.d)}return e},nextOrSelf:function(e,t){var i=e.getDay(),n=i-t;if(n){var a=n>0?7-n:-n;e=new Date(e+a*Tt.time.intervals.d)}return e},closestOrSelf:function(e,t){var i=e.getDay(),n=i-t;if(n){var a=Tt.time.intervals.d,r=n>0?1:-1;n=Math.abs(n);e=new Date(n>=4?e.getTime()+r*(7-n)*a:e.getTime()-r*n*a)}return e}}};t.Format.createParser=function(t){function i(i){return i instanceof Date?i:e.number.is(i)?new Date(i):t.parse(i)}return i};t.Format.createFormatter=function(e){function t(t){return null!=t?e.format(t):""}return t};Tt.buildTitleFromName=function(t){return e.firstUpperCase(t).replace(/([a-z\d])([A-Z])/,"$1 $2") };Tt.buildIndexedId=function(e,t){return t>0?e+""+(t+1):e};Tt.splitIndexedId=function(e){var t=/^(.*?)(\d*)$/.exec(e),i=null;if(t[2]){i=Number(t[2]);1>=i?i=1:i--}return[t[1],i]};var Ot=[null];Tt.makeExtensionAbsId=function(t,i){if(!t)return i;var n=[];i=e.array.to(i)||Ot;t=e.array.to(t);for(var a=0,s=i.length;s>a;a++)for(var o=0,l=t.length;l>o;o++){var u=r(t[o],i[a]);u&&n.push(u)}return n};Tt.makeEnumParser=function(t,i,n){if(e.array.is(i)){var a={};i.forEach(function(e){e&&(a[e.toLowerCase()]=e)});i=function(t){return e.hasOwn(a,t)}}n&&(n=n.toLowerCase());return function(e){e&&(e=(""+e).toLowerCase());if(!i(e)){e&&Tt.debug>=2&&Tt.warn("Invalid '"+t+"' value: '"+e+"'. Assuming '"+n+"'.");e=n}return e}};Tt.parseDistinctIndexArray=function(t,i,n){t=e.array.as(t);if(null==t)return null;null==i&&(i=0);null==n&&(n=1/0);var a=e.query(t).select(function(e){return+e}).where(function(e){return!isNaN(e)&&e>=i&&n>=e}).distinct().array();return a.length?a:null};Tt.parseValuesOverflow=Tt.makeEnumParser("valuesOverflow",["show","trim","hide"],"hide"); Tt.parseMultiChartOverflow=Tt.makeEnumParser("multiChartOverflow",["grow","fit","clip"],"grow");Tt.parseLegendClickMode=Tt.makeEnumParser("legendClickMode",["toggleSelected","toggleVisible","none"],"toggleVisible");Tt.parseTooltipAutoContent=Tt.makeEnumParser("tooltipAutoContent",["summary","value"],"value");Tt.parseSelectionMode=Tt.makeEnumParser("selectionMode",["rubberBand","focusWindow"],"rubberBand");Tt.parseClearSelectionMode=Tt.makeEnumParser("clearSelectionMode",["emptySpaceClick","manual"],"emptySpaceClick");Tt.parseSunburstSliceOrder=Tt.makeEnumParser("sliceOrder",["bySizeAscending","bySizeDescending","none"],"bySizeDescending");Tt.parseShape=Tt.makeEnumParser("shape",t.Scene.hasSymbol,null);Tt.parseTreemapColorMode=Tt.makeEnumParser("colorMode",["byParent","bySelf"],"byParent");Tt.parseTreemapLayoutMode=Tt.makeEnumParser("layoutMode",["squarify","slice-and-dice","slice","dice"],"squarify");Tt.parseContinuousColorScaleType=function(e){if(e){e=(""+e).toLowerCase();switch(e){case"linear":case"normal":case"discrete":break; default:Tt.debug>=2&&Tt.log("[Warning] Invalid 'ScaleType' option value: '"+e+"'.");e=null}}return e};Tt.parseDomainScope=function(t,i){if(t){t=(""+t).toLowerCase();switch(t){case"cell":case"global":break;case"section":if(!i)throw e.error.argumentRequired("orientation");t="y"===i?"row":"column";break;case"column":case"row":if(i&&i!==("row"===t?"y":"x")){t="section";Tt.debug>=2&&Tt.log("[Warning] Invalid 'DomainScope' option value: '"+t+"' for the orientation: '"+i+"'.")}break;default:Tt.debug>=2&&Tt.log("[Warning] Invalid 'DomainScope' option value: '"+t+"'.");t=null}}return t};Tt.parseDomainRoundingMode=function(e){if(e){e=(""+e).toLowerCase();switch(e){case"none":case"nice":case"tick":break;default:Tt.debug>=2&&Tt.log("[Warning] Invalid 'DomainRoundMode' value: '"+e+"'.");e=null}}return e};Tt.parseOverlappedLabelsMode=function(e){if(e){e=(""+e).toLowerCase();switch(e){case"leave":case"hide":case"rotatethenhide":break;default:Tt.debug>=2&&Tt.log("[Warning] Invalid 'OverlappedLabelsMode' option value: '"+e+"'."); e=null}}return e};Tt.castNumber=function(e){if(null!=e){e=+e;isNaN(e)&&(e=null)}return e};Tt.castPositiveNumber=function(e){e=Tt.castNumber(e);null==e||e>0||(e=null);return e};Tt.castNonNegativeNumber=function(e){e=Tt.castNumber(e);null!=e&&0>e&&(e=null);return e};Tt.parseWaterDirection=function(e){if(e){e=(""+e).toLowerCase();switch(e){case"up":case"down":return e}Tt.debug>=2&&Tt.log("[Warning] Invalid 'WaterDirection' value: '"+e+"'.")}};Tt.parseTrendType=function(e){if(e){e=(""+e).toLowerCase();if("none"===e)return e;if(Tt.trends.has(e))return e;Tt.debug>=2&&Tt.log("[Warning] Invalid 'TrendType' value: '"+e+"'.")}};Tt.parseNullInterpolationMode=function(e){if(e){e=(""+e).toLowerCase();switch(e){case"none":case"linear":case"zero":return e}Tt.debug>=2&&Tt.log("[Warning] Invalid 'NullInterpolationMode' value: '"+e+"'.")}};Tt.parseAlign=function(t,i){i&&(i=(""+i).toLowerCase());var n,a;if("left"===t||"right"===t){n=i&&Tt.BasePanel.verticalAlign[i];if(!n){n="middle";a=!!i}}else{n=i&&Tt.BasePanel.horizontalAlign[i]; if(!n){n="center";a=!!i}}a&&Tt.debug>=2&&Tt.log(e.format("Invalid alignment value '{0}'. Assuming '{1}'.",[i,n]));return n};Tt.parseAnchor=function(t){if(t){t=(""+t).toLowerCase();switch(t){case"top":case"left":case"center":case"bottom":case"right":return t}Tt.debug>=2&&Tt.log(e.format("Invalid anchor value '{0}'.",[t]))}};Tt.parseAnchorWedge=function(t){if(t){t=(""+t).toLowerCase();switch(t){case"outer":case"inner":case"center":case"start":case"end":return t}Tt.debug>=2&&Tt.log(e.format("Invalid wedge anchor value '{0}'.",[t]))}};Tt.unionExtents=function(e,t){if(e){if(t){t.mine.max&&(e.max=t.max)}}else{if(!t)return null;e={min:t.min,max:t.max}}return e};var Vt=Tt.Sides=function(e){null!=e&&this.setSides(e)};Vt.hnames="left right".split(" ");Vt.vnames="top bottom".split(" ");Vt.names="left right top bottom".split(" ");Vt.namesSet=t.dict(Vt.names,e.retTrue);Tt.parsePosition=function(t,i){if(t){t=(""+t).toLowerCase();if(!e.hasOwn(Vt.namesSet,t)){var n=i||"left"; Tt.debug>=2&&Tt.log(e.format("Invalid position value '{0}. Assuming '{1}'.",[t,n]));t=n}}return t||i||"left"};Vt.as=function(e){null==e||e instanceof Vt||(e=(new Vt).setSides(e));return e};Vt.to=function(e){null!=e&&e instanceof Vt||(e=(new Vt).setSides(e));return e};Vt.prototype.stringify=function(t,i,n){return Tt.stringifyRecursive(t,e.copyOwn(this),i,n)};Vt.prototype.setSides=function(e){if("string"==typeof e){var t=e.split(/\s+/).map(function(e){return Nt.parse(e)});switch(t.length){case 1:this.set("all",t[0]);return this;case 2:this.set("top",t[0]);this.set("left",t[1]);this.set("right",t[1]);this.set("bottom",t[0]);return this;case 3:this.set("top",t[0]);this.set("left",t[1]);this.set("right",t[1]);this.set("bottom",t[2]);return this;case 4:this.set("top",t[0]);this.set("right",t[1]);this.set("bottom",t[2]);this.set("left",t[3]);return this;case 0:return this}}else{if("number"==typeof e){this.set("all",e);return this}if("object"==typeof e){if(e instanceof Nt)this.set("all",e);else{this.set("all",e.all); this.set("width",e.width);this.set("height",e.height);for(var i in e)Vt.namesSet.hasOwnProperty(i)&&this.set(i,e[i])}return this}}Tt.debug&&Tt.log("Invalid 'sides' value: "+Tt.stringify(e));return this};Vt.prototype.set=function(t,i){i=Nt.parse(i);if(null!=i)switch(t){case"all":Vt.names.forEach(function(e){this[e]=i},this);break;case"width":this.left=this.right=Nt.divide(i,2);break;case"height":this.top=this.bottom=Nt.divide(i,2);break;default:e.hasOwn(Vt.namesSet,t)&&(this[t]=i)}};Vt.prototype.resolve=function(e,t){if("object"==typeof e){t=e.height;e=e.width}var i={};Vt.names.forEach(function(n){var a=0,r=this[n];null!=r&&(a="number"==typeof r?r:r.resolve("left"===n||"right"===n?e:t));i[n]=a},this);return Vt.updateSize(i)};Vt.updateSize=function(e){e.width=(e.left||0)+(e.right||0);e.height=(e.bottom||0)+(e.top||0);return e};Vt.resolvedMax=function(e,t){var i={};Vt.names.forEach(function(n){i[n]=Math.max(e[n]||0,t[n]||0)});return i};Vt.inflate=function(e,t){var i={};Vt.names.forEach(function(n){i[n]=(e[n]||0)+t });return Vt.updateSize(i)};var Nt=Tt.PercentValue=function(e){this.percent=e};Nt.prototype.resolve=function(e){return this.percent*e};Nt.prototype.divide=function(e){return new Nt(this.percent/e)};Nt.divide=function(e,t){return e instanceof Nt?e.divide(t):e/t};Nt.parse=function(t){if(null!=t&&""!==t){switch(typeof t){case"number":return t;case"string":var i=t.match(/^(.+?)\s*(%)?$/);if(i){var n=+i[1];if(!isNaN(n)){if(!i[2])return n;if(n>=0)return new Nt(n/100)}}break;case"object":if(t instanceof Nt)return t}Tt.debug&&Tt.log(e.format("Invalid margins component '{0}'",[""+t]))}};Nt.resolve=function(e,t){return e instanceof Nt?e.resolve(t):e};var Bt=At.prototype.zOrder;At.prototype.zOrder=function(e){var t=this.borderPanel;return t&&t!==this?Bt.call(t,e):Bt.call(this,e)};At.prototype.wrapper=function(e){this._wrapper=e;return this};At.prototype.wrap=function(t,i){if(t&&e.fun.is(t)&&this._wrapper&&!t._cccWrapped){t=this._wrapper(t,i);t._cccWrapped=!0}return t};t.Mark.prototype.call=function(e){e.call(this,this) };At.prototype.lock=function(e,t){void 0!==t&&this[e](t);(this._locked||(this._locked={}))[e]=!0;return this};At.prototype.isIntercepted=function(e){return this._intercepted&&this._intercepted[e]};At.prototype.isLocked=function(e){return this._locked&&this._locked[e]};At.prototype.ensureEvents=function(e){var t=this.propertyValue("events",!0);t&&"none"!==t||this.events(e||"all");return this};At.prototype.addMargin=function(i,n){if(0!==n){var a=e.nullyTo(this.propertyValue(i),0),r=t.functor(a);this[i](function(){return n+r.apply(this,Lt.call(arguments))})}return this};At.prototype.addMargins=function(t){var i=e.get(t,"all",0);this.addMargin("left",e.get(t,"left",i));this.addMargin("right",e.get(t,"right",i));this.addMargin("top",e.get(t,"top",i));this.addMargin("bottom",e.get(t,"bottom",i));return this};At.prototype.eachInstanceWithData=function(e,t){this.eachInstance(function(i,n,a){i.mark.sign&&i[n].data&&e.call(t,i,n,a)})};At.prototype.eachSceneWithDataOnRect=function(e,t,i,n){function a(n,a){if(n.intersectsRect(e)){var r=a.data; r&&r.datum&&t.call(i,r)}}var r=this,s=r.sign;if(!s||s.selectable()){null==n&&(n=r.rubberBandSelectionMode||"partial");var o="center"===n;r.eachInstanceWithData(function(e,t,i){var n=r.getShape(e,t,.15);n=(o?n.center():n).apply(i);a(n,e[t],t)})}};At.prototype.eachDatumOnRect=function(e,t,i,n){function a(n,a){if(n.intersectsRect(e)){var r=a.data;r&&r.datum&&r.datums().each(function(e){e.isNull||t.call(i,e)})}}var r=this,s=r.sign;if(!s||s.selectable()){null==n&&(n=r.rubberBandSelectionMode||"partial");var o="center"===n;r.eachInstanceWithData(function(e,t,i){var n=r.getShape(e,t,.15);n=(o?n.center():n).apply(i);a(n,e[t],t)})}};t.Transform.prototype.transformHPosition=function(e){return this.x+this.k*e};t.Transform.prototype.transformVPosition=function(e){return this.y+this.k*e};t.Transform.prototype.transformLength=function(e){return this.k*e};var zt=e.type("pvc.Size").init(function(e,t){if(1===arguments.length)null!=e&&this.setSize(e);else{null!=e&&(this.width=e);null!=t&&(this.height=t)}}).add({stringify:function(t,i,n){return Tt.stringifyRecursive(t,e.copyOwn(this),i,n) },setSize:function(t,i){if("string"==typeof t){var n=t.split(/\s+/).map(function(e){return Nt.parse(e)});switch(n.length){case 1:this.set(e.get(i,"singleProp","all"),n[0]);return this;case 2:this.set("width",n[0]);this.set("height",n[1]);return this;case 0:return this}}else{if("number"==typeof t){this.set(e.get(i,"singleProp","all"),t);return this}if("object"==typeof t){if(t instanceof Nt)this.set(e.get(i,"singleProp","all"),t);else{this.set("all",t.all);for(var a in t)"all"!==a&&this.set(a,t[a])}return this}}Tt.debug&&Tt.log("Invalid 'size' value: "+Tt.stringify(t));return this},set:function(t,i){if(null!=i&&("all"===t||e.hasOwn(zt.namesSet,t))){i=Nt.parse(i);null!=i&&("all"===t?zt.names.forEach(function(e){this[e]=i},this):this[t]=i)}return this},clone:function(){return new zt(this.width,this.height)},intersect:function(e){return new zt(Math.min(this.width,e.width),Math.min(this.height,e.height))},resolve:function(e){var t={};zt.names.forEach(function(i){var n=this[i];if(null!=n)if("number"==typeof n)t[i]=n; else if(e){var a=e[i];null!=a&&(t[i]=n.resolve(a))}},this);return t}});zt.names=["width","height"];zt.namesSet=t.dict(zt.names,e.retTrue);zt.toOrtho=function(e,t){if(null!=e){var i;t&&(i=Tt.BasePanel.orthogonalLength[t]);e=zt.to(e,{singleProp:i});t&&delete e[Tt.BasePanel.oppositeLength[i]]}return e};zt.to=function(e,t){null==e||e instanceof zt||(e=(new zt).setSize(e,t));return e};var Ft=e.type("pvc.Offset").init(function(e,t){if(1===arguments.length)null!=e&&this.setOffset(e);else{null!=e&&(this.x=e);null!=t&&(this.y=t)}}).add({stringify:function(t,i,n){return Tt.stringifyRecursive(t,e.copyOwn(this),i,n)},setOffset:function(t,i){if("string"==typeof t){var n=t.split(/\s+/).map(function(e){return Nt.parse(e)});switch(n.length){case 1:this.set(e.get(i,"singleProp","all"),n[0]);return this;case 2:this.set("x",n[0]);this.set("y",n[1]);return this;case 0:return this}}else{if("number"==typeof t){this.set(e.get(i,"singleProp","all"),t);return this}if("object"==typeof t){this.set("all",t.all);for(var a in t)"all"!==a&&this.set(a,t[a]); return this}}Tt.debug&&Tt.log("Invalid 'offset' value: "+Tt.stringify(t));return this},set:function(t,i){if(null!=i&&e.hasOwn(Ft.namesSet,t)){i=Nt.parse(i);null!=i&&("all"===t?Ft.names.forEach(function(e){this[e]=i},this):this[t]=i)}},resolve:function(e){var t={};zt.names.forEach(function(i){var n=Ft.namesSizeToOffset[i],a=this[n];if(null!=a)if("number"==typeof a)t[n]=a;else if(e){var r=e[i];null!=r&&(t[n]=a.resolve(r))}},this);return t}});Ft.addStatic({names:["x","y"]}).addStatic({namesSet:t.dict(Ft.names,e.retTrue),namesSizeToOffset:{width:"x",height:"y"},namesSidesToOffset:{left:"x",right:"x",top:"y",bottom:"y"},as:function(e){null==e||e instanceof Ft||(e=(new Ft).setOffset(e));return e}});null==$.support.svg&&($.support.svg=document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1"));Tt.text={getFitInfo:function(e,i,n,a,r){if(""===n)return{h:!0,v:!0,d:!0};var s=t.Text.measureWidth(n,a);return{h:e>=s,v:i>=s,d:s<=Math.sqrt(e*e+i*i)-r}},trimToWidthB:function(e,i,n,a,r){var s=t.Text.measureWidth(a,n),o=1.5*s; return Tt.text.trimToWidth(e,i,n,a,r,o)},trimToWidth:function(e,i,n,a,r,s){if(""===i)return i;var o=t.Text.measureWidth(i,n);if(e>=o)return i;if(o>1.5*e)return Tt.text.trimToWidthBin(e,i,n,a,r,s);e-=t.Text.measureWidth(a,n);for(;o>e;){i=r?i.slice(1):i.slice(0,i.length-1);o=t.Text.measureWidth(i,n)}return s&&s>=o?"":r?a+i:i+a},trimToWidthBin:function(e,i,n,a,r,s){e-=t.Text.measureWidth(a,n);for(var o,l,u=i.length,c=u-2,h=0;c>=h&&c>0;){o=Math.ceil((h+c)/2);var d=r?i.slice(u-o):i.slice(0,o);l=t.Text.measureWidth(d,n);if(l>e)c=o-1;else{if(!(t.Text.measureWidth(r?i.slice(u-o-1):i.slice(0,o+1),n)=l?"":r?a+d:d+a;h=o+1}}i=r?i.slice(u-c):i.slice(0,c);l=i.length;return s&&s>=l?"":r?a+i:i+a},justify:function(e,i,n){var a=[];if(ii){s&&a.push(s);s=o}else s=l}}s&&a.push(s);return a},getLabelBBox:function(e,i,n,a,r,s){var o=t.Label.getPolygon(e,i,n,a,r,s),l=o.bbox(); l.source=o;l.sourceAngle=r;l.sourceAlign=n;l.sourceTextWidth=e;return l}};Tt.color={scale:l,scales:o,toGray:Tt.toGrayScale,isGray:s};e.type("pvc.color.ScalesBuild").init(function(i){this.keyArgs=i;this.data=i.data||e.fail.argumentRequired("keyArgs.data");this.domainDimName=i.colorDimension||e.fail.argumentRequired("keyArgs.colorDimension");this.domainDim=this.data.dimensions(this.domainDimName);var n=this.domainDim.type;if(n.isComparable)this.domainComparer=function(e,t){return n.compare(e,t)};else{this.domainComparer=null;Tt.log("Color value dimension should be comparable. Generated color scale may be invalid.")}this.nullRangeValue=i.colorMissing?t.color(i.colorMissing):t.Color.transparent;this.domainRangeCountDif=0}).add({build:function(){this.range=this._getRange();this.desiredDomainCount=this.range.length+this.domainRangeCountDif;var e=this._getDomain();return this._createScale(e)},buildMap:function(){this.range=this._getRange();this.desiredDomainCount=this.range.length+this.domainRangeCountDif; var t;if(this.keyArgs.normPerBaseCategory)t=function(e){var t=this._ensureDomain(null,!1,e);return this._createScale(t)};else{var i=this._getDomain(),n=this._createScale(i);t=e.fun.constant(n)}return this._createCategoryScalesMap(t)},_createScale:e.method({isAbstract:!0}),_createCategoryScalesMap:function(e){return this.data.children().object({name:function(e){return e.absKey},value:e,context:this})},_getRange:function(){var e=this.keyArgs,i=e.colors||["red","yellow","green"];null!=e.colorMin&&null!=e.colorMax?i=[e.colorMin,e.colorMax]:null!=e.colorMin?i.unshift(e.colorMin):null!=e.colorMax&&i.push(e.colorMax);return i.map(function(e){return t.color(e)})},_getDataExtent:function(e){var t=e.dimensions(this.domainDimName).extent({visible:!0});if(!t)return null;var i=t.min.value,n=t.max.value;n==i&&(n>=1?i=n-1:n=i+1);return{min:i,max:n}},_getDomain:function(){var e=this.keyArgs.colorDomain;if(null!=e){e=e.slice();this.domainComparer&&e.sort(this.domainComparer);e.length>this.desiredDomainCount&&(e=e.slice(0,this.desiredDomainCount)) }else e=[];return this._ensureDomain(e,!0,this.data)},_ensureDomain:function(i,n,a){var r;if(i&&n){var s=this.desiredDomainCount-i.length;if(s>0){r=this._getDataExtent(a);if(r)switch(s){case 1:this.domainComparer?e.array.insert(i,r.max,this.domainComparer):i.push(r.max);break;case 2:if(this.domainComparer){e.array.insert(i,r.min,this.domainComparer);e.array.insert(i,r.max,this.domainComparer)}else{i.unshift(r.min);i.push(r.max)}break;default:Tt.debug>=2&&Tt.log("Ignoring option 'colorDomain' due to unsupported length."+e.format(" Should have '{0}', but instead has '{1}'.",[this.desiredDomainCount,i.length]));i=null}}}if(!i){r||(r=this._getDataExtent(a));if(r){var o=r.min,l=r.max,u=(l-o)/(this.desiredDomainCount-1);i=t.range(o,l+u,u)}}return i}});e.type("pvc.color.LinearScalesBuild",Tt.color.ScalesBuild).add({_createScale:function(e){var i=t.Scale.linear();e&&i.domain.apply(i,e);i.range.apply(i,this.range);return i}});e.type("pvc.color.DiscreteScalesBuild",Tt.color.ScalesBuild).init(function(e){this.base(e); this.domainRangeCountDif=1}).add({_createScale:function(i){function n(e){if(null==e)return s;for(var t=0;a>t;t++)if(e<=i[t+1])return r[t];return r[o]}var a=i.length-1,r=this.range,s=this.nullRangeValue,o=r.length-1;e.copy(n,t.Scale.common);n.domain=function(){return i};n.range=function(){return r};return n}});e.space("pvc.trends",function(t){var i={};e.set(t,"define",function(t,n){t||e.fail.argumentRequired("type");n||e.fail.argumentRequired("trendSpec");e.object.is(n)||e.fail.argumentInvalid("trendSpec","Must be a trend specification object.");t=(""+t).toLowerCase();Tt.debug>=2&&e.hasOwn(i,t)&&Tt.log(e.format("[WARNING] A trend type with the name '{0}' is already defined.",[t]));var a=n.label||e.fail.argumentRequired("trendSpec.label"),r=n.model||e.fail.argumentRequired("trendSpec.model");e.fun.is(r)||e.fail.argumentInvalid("trendSpec.mode","Must be a function.");var s={dataPartAtom:{v:"trend",f:a},type:t,label:a,model:r};i[t]=s},"get",function(t){t||e.fail.argumentRequired("type");return e.getOwn(i,t)||e.fail.operationInvalid("Undefined trend type '{0}'.",[t]) },"has",function(t){return e.hasOwn(i,t)},"types",function(){return e.ownKeys(i)});t.define("linear",{label:"Linear trend",model:function(t){for(var i=e.get(t,"rows"),n=e.get(t,"x"),a=e.get(t,"y"),r=0,s=0,o=0,l=0,u=0,c=0,h=function(e){return null!=e?+e:0/0};i.next();){var d=i.item,f=n?h(n(d)):r;if(!isNaN(f)){var v=h(a(d));if(!isNaN(v)){s++;o+=f;l+=v;u+=f*v;c+=f*f}}r++}var p,m;if(s>=2){var g=o/s,b=l/s,_=u/s,y=c/s,x=y-g*g;m=0===x?0:(_-g*b)/x;p=b-m*g;return{alpha:p,beta:m,reset:e.noop,sample:function(e){return p+m*+e}}}}});t.define("moving-average",{label:"Moving average",model:function(t){var i=Math.max(+(e.get(t,"periods")||3),2),n=0,a=[];return{reset:function(){n=0;a.length=0},sample:function(e,t){var r=i;if(null!=t){a.unshift(t);n+=t;r=a.length;if(r>i){n-=a.pop();r=i}}return n/r}}}});t.define("weighted-moving-average",{label:"Weighted Moving average",model:function(t){var i=Math.max(+(e.get(t,"periods")||3),2),n=0,a=0,r=[],s=0,o=0;return{reset:function(){n=a=o=s=0;r.length=0},sample:function(e,t){if(null!=t)if(i>s){r.push(t); s++;o+=s;a+=s*t;n+=t}else{a+=s*t-n;n+=t-r[0];for(var l=1;i>l;l++)r[l-1]=r[l];r[i-1]=t}return a/o}}}})});u.resolvers=c;u.constant=h;u.specify=d;u.defaultValue=f;Tt.options=u;var Et=e.type().init(function(t,i,n,a){this.name=t;this.option=i;this._dv=this.value=e.get(a,"value");this._resolve=e.get(a,"resolve");var r=!this._resolve;this.isResolved=r;this.isSpecified=!1;this._setCalled=!1;this._context=n;this._cast=e.get(a,"cast");this._getDefault=r?null:e.get(a,"getDefault");this.data=e.get(a,"data")}).add({resolve:function(){if(!this.isResolved){this.isResolved=!0;this._setCalled=!1;this._getFunProp("_resolve").call(this._context,this);if(!this._setCalled){this.isSpecified=!1;var e=this._dynDefault();null!=e&&(this.value=this._dv=e)}}return this},specify:function(e){return this.set(e,!1)},defaultValue:function(e){arguments.length&&this.set(e,!0);return this._dv},cast:function(e){if(null!=e){var t=this._getFunProp("_cast");t&&(e=t.call(this._context,e,this))}return e},set:function(e,t){this._setCalled=!0; null!=e&&(e=this.cast(e));if(null==e){e=this._dynDefault();if(null==e){if(!this.isSpecified)return this;e=this._dv}t=!0}if(t){this._dv=e;this.isSpecified||(this.value=e)}else{this.isResolved=this.isSpecified=!0;this.value=e}return this},_dynDefault:function(){var e=this._getFunProp("_getDefault");return e&&this.cast(e.call(this._context,this))},_getFunProp:function(e){var t=this[e];if(t){var i=this._context;i&&"string"==typeof t&&(t=i[t])}return t}});e.global.NoDataException=function(){};e.global.InvalidDataException=function(e){this.message=e?e:"Invalid Data."};Tt.data={visibleKeyArgs:{visible:!0}};e.type("pvc.data.DimensionType").init(function(i,n,a){this.complexType=i;this.name=n;this.label=e.get(a,"label")||Tt.buildTitleFromName(n);var r=Tt.splitIndexedId(n);this.group=r[0];this.groupLevel=e.nullyTo(r[1],0);this.label.indexOf("{")>=0&&(this.label=e.format(this.label,[this.groupLevel+1]));this.playedVisualRoles=new e.Map;this.isHidden=!!e.get(a,"isHidden");var s=e.get(a,"valueType")||null,o=Tt.data.DimensionType.valueTypeName(s),l=e.getOwn(Tt.data.DimensionType.cast,o,null); this.valueType=s;this.valueTypeName=o;this.cast=l;this.isDiscreteValueType=this.valueType!==Number&&this.valueType!==Date;this.isDiscrete=e.get(a,"isDiscrete");if(null==this.isDiscrete)this.isDiscrete=this.isDiscreteValueType;else{this.isDiscrete=!!this.isDiscrete;if(!this.isDiscrete&&this.isDiscreteValueType)throw e.error.argumentInvalid("isDiscrete","The only supported continuous value types are Number and Date.")}this._converter=e.get(a,"converter")||null;if(!this._converter){var u=e.get(a,"rawFormat");if(u)switch(this.valueType){case Date:this._converter=t.Format.createParser(t.Format.date(u))}}this._key=e.get(a,"key")||null;this._comparer=e.get(a,"comparer");if(void 0===this._comparer)switch(this.valueType){case Number:case Date:this._comparer=e.compare;break;default:this._comparer=null}this.isComparable=null!=this._comparer;this._formatter=e.get(a,"formatter")||null;if(!this._formatter)switch(this.valueType){case Number:this._formatter=t.Format.createFormatter(t.Format.number().fractionDigits(0,2)); break;case Date:var c=e.get(a,"format");if(!c){c=e.get(a,"rawFormat");c&&(c=c.replace(/-/g,"/"))}c||(c="%Y/%m/%d");this._formatter=t.Format.createFormatter(t.Format.date(c))}}).add({isCalculated:!1,compare:function(e,t){return null==e?null==t?0:-1:null==t?1:this._comparer.call(null,e,t)},comparer:function(e){if(!this.isComparable)return null;var t=this;return e?this._reverseComparer||(this._reverseComparer=function(e,i){return t.compare(i,e)}):this._directComparer||(this._directComparer=function(e,i){return t.compare(e,i)})},atomComparer:function(e){return e?this._reverseAtomComparer||(this._reverseAtomComparer=this._createReverseAtomComparer()):this._directAtomComparer||(this._directAtomComparer=this._createDirectAtomComparer())},_toDiscrete:function(){this.isDiscrete=!0},_toCalculated:function(){this.isCalculated=!0},_createReverseAtomComparer:function(){function e(e,i){return e===i?0:t.compare(i.value,e.value)}if(!this.isComparable)return S;var t=this;return e},_createDirectAtomComparer:function(){function e(e,i){return e===i?0:t.compare(e.value,i.value) }if(!this.isComparable)return x;var t=this;return e},formatter:function(){return this._formatter},converter:function(){return this._converter},playingPercentVisualRole:function(){return e.query(this.playedVisualRoles.values()).any(function(e){return e.isPercent})}});Tt.data.DimensionType.cast={Date:function(e){return e instanceof Date?e:new Date(e)},Number:function(e){e=Number(e);return isNaN(e)?null:e},String:String,Boolean:Boolean,Object:Object,Any:null};Tt.data.DimensionType.dimensionGroupName=function(e){return e.replace(/^(.*?)(\d*)$/,"$1")};Tt.data.DimensionType.valueTypeName=function(t){if(null==t)return"Any";switch(t){case Boolean:return"Boolean";case Number:return"Number";case String:return"String";case Object:return"Object";case Date:return"Date";default:throw e.error.argumentInvalid("valueType","Invalid valueType function: '{0}'.",[t])}};Tt.data.DimensionType.extendSpec=function(t,i,n){var a=Tt.data.DimensionType.dimensionGroupName(t),r=e.get(n,"dimensionGroups");if(r){var s=r[a]; s&&(i=e.create(s,i))}i||(i={});switch(a){case"category":var o=e.get(n,"isCategoryTimeSeries",!1);o&&void 0===i.valueType&&(i.valueType=Date);break;case"value":void 0===i.valueType&&(i.valueType=Number);i.valueType===Number&&(void 0!==i.formatter||i.format||(i.formatter=e.get(n,"valueNumberFormatter")))}void 0!==i.converter||i.valueType!==Date||i.rawFormat||(i.rawFormat=e.get(n,"timeSeriesFormat"));return i};e.type("pvc.data.ComplexType").init(function(e){this._dims={};this._dimsList=[];this._dimsNames=[];this._calculations=[];this._calculatedDimNames={};this._dimsIndexByName=null;this._dimsByGroup={};this._dimsNamesByGroup={};if(e)for(var t in e)this.addDimension(t,e[t])}).add({describe:function(){var e=["COMPLEX TYPE INFORMATION",Tt.logSeparator];this._dimsList.forEach(function(t){var i=[];i.push(t.valueTypeName);t.isComparable&&i.push("comparable");t.isDiscrete||i.push("continuous");t.isHidden&&i.push("hidden");e.push(" "+t.name+" ("+i.join(", ")+")")});return e.join("\n")},dimensions:function(t,i){if(null==t)return this._dims; var n=e.getOwn(this._dims,t,null);if(!n&&e.get(i,"assertExists",!0))throw e.error.argumentInvalid("name","Undefined dimension '{0}'",[t]);return n},dimensionsList:function(){return this._dimsList},calculatedDimensionsList:function(){return this._calcDimsList},dimensionsNames:function(){return this._dimsNames},groupDimensions:function(t,i){var n=e.getOwn(this._dimsByGroup,t);if(!n&&e.get(i,"assertExists",!0))throw e.error.operationInvalid("There is no dimension type group with name '{0}'.",[t]);return n},groupDimensionsNames:function(t,i){var n=e.getOwn(this._dimsNamesByGroup,t);if(!n&&e.get(i,"assertExists",!0))throw e.error.operationInvalid("There is no dimension type group with name '{0}'.",[t]);return n},addDimension:function(t,i){t||e.fail.argumentRequired("name");!e.hasOwn(this._dims,t)||e.fail.operationInvalid("A dimension type with name '{0}' is already defined.",[t]);var n=new Tt.data.DimensionType(this,t,i);this._dims[t]=n;this._dimsIndexByName=null;var a,r=n.group;if(r){var s,o=e.getOwn(this._dimsByGroup,r); if(o)s=this._dimsNamesByGroup[r];else{o=this._dimsByGroup[r]=[];s=this._dimsNamesByGroup[r]=[]}a=e.array.insert(s,t,e.compare);a=~a;e.array.insertAt(o,a,n)}var l,u=this._dimsList.length;if(r){a=n.groupLevel;for(var c=0;u>c;c++){var h=this._dimsList[c];if(h.group===r){if(h.groupLevel>a){l=c;break}l=c+1}}null==l&&(l=u)}else l=u;e.array.insertAt(this._dimsList,l,n);e.array.insertAt(this._dimsNames,l,t);if(n._calculate){l=e.array.binarySearch(this._calcDimsList,n._calculationOrder,e.compare,function(e){return e._calculationOrder});l>=0?l++:l=~l;e.array.insertAt(this._calcDimsList,l,n)}this._isPctRoleDimTypeMap=null;return n},addCalculation:function(t,i){t||e.fail.argumentRequired("calcSpec");var n=t.calculation||e.fail.argumentRequired("calculations[i].calculation"),a=t.names;a="string"==typeof a?a.split(/\s*\,\s*/):e.array.as(a);if(a&&a.length){var r=this._calculatedDimNames;a.forEach(function(t){if(t){t=t.replace(/^\s*(.+?)\s*$/,"$1");!e.hasOwn(r,t)||e.fail.argumentInvalid("calculations[i].names","Dimension name '{0}' is already being calculated.",[t]); var n=this._dims[t];if(!n){var a=Tt.data.DimensionType.extendSpec(t,null,i);this.addDimension(t,a)}r[t]=!0;n._toCalculated()}},this)}this._calculations.push(n)},isCalculated:function(t){return e.hasOwn(this._calculatedDimNames,t)},_calculate:function(e){var t=this._calculations,i=t.length;if(i){for(var n={},a=0;i>a;a++){var r=t[a];r(e,n)}return n}},getPlayingPercentVisualRoleDimensionMap:function(){var t=this._isPctRoleDimTypeMap;t||(t=this._isPctRoleDimTypeMap=new e.Map(e.query(e.own(this._dims)).where(function(e){return e.playingPercentVisualRole()}).object({name:function(e){return e.name}})));return t},sortDimensionNames:function(t,i){var n=this._dimsIndexByName;if(!n){n=e.query(this._dimsList).object({name:function(e){return e.name},value:function(e,t){return t}});this._dimsIndexByName=n}t.sort(function(t,a){return e.compare(n[i?i(t):t],n[i?i(a):a])});return t}});e.type("pvc.data.ComplexTypeProject").init(function(e){this._dims={};this._dimList=[];this._dimGroupsDims={};this._dimGroupSpecs=e||{}; this._calcList=[]}).add({_ensureDim:function(t,i){t||e.fail.argumentInvalid("name","Invalid dimension name '{0}'.",[t]);var n=e.getOwn(this._dims,t);if(n)i&&e.setUDefaults(n.spec,i);else{n=this._dims[t]=this._createDim(t,i);this._dimList.push(n);var a=e.array.lazy(this._dimGroupsDims,n.groupName);e.array.insert(a,t,e.compare)}return n},hasDim:function(t){return e.hasOwn(this._dims,t)},setDim:function(t,i){var n=this._ensureDim(t).spec;i&&e.copy(n,i);return this},setDimDefaults:function(t,i){e.setUDefaults(this._ensureDim(t).spec,i);return this},_createDim:function(t,i){var n=Tt.data.DimensionType.dimensionGroupName(t),a=this._dimGroupSpecs[n];a&&(i=e.create(a,i));return{name:t,groupName:n,spec:i||{}}},readDim:function(t,i){var n=this._ensureDim(t,i);if(n.isRead)throw e.error.operationInvalid("Dimension '{0}' already is the target of a reader.",[t]);if(n.isCalc)throw e.error.operationInvalid("Dimension '{0}' is being calculated, so it cannot be the target of a reader.",[t]);n.isRead=!0},calcDim:function(t,i){var n=this._ensureDim(t,i); if(n.isCalc)throw e.error.operationInvalid("Dimension '{0}' already is being calculated.",[t]);if(n.isRead)throw e.error.operationInvalid("Dimension '{0}' is the target of a reader, so it cannot be calculated.",[t]);n.isCalc=!0},isReadOrCalc:function(t){if(t){var i=e.getOwn(this._dims,t);if(i)return i.isRead||i.isCalc}return!1},groupDimensionsNames:function(e){return this._dimGroupsDims[e]},setCalc:function(t){t||e.fail.argumentRequired("calculations[i]");t.calculation||e.fail.argumentRequired("calculations[i].calculation");var i=t.names;i="string"==typeof i?i.split(/\s*\,\s*/):e.array.as(i);i&&i.length&&i.forEach(this.calcDim,this);this._calcList.push(t)},configureComplexType:function(e,t){this._dimList.forEach(function(i){var n=i.name,a=i.spec;a=Tt.data.DimensionType.extendSpec(n,a,t);e.addDimension(n,a)});this._calcList.forEach(function(t){e.addCalculation(t)})}});e.type("pvc.data.TranslationOper").init(function(t,i,n,a,r){this.chart=t;this.complexTypeProj=i;this.source=n||e.fail.argumentRequired("source"); this.metadata=a||e.fail.argumentRequired("metadata");this.options=r||{};this._initType();if(Tt.debug>=4){this._logItems=!0;this._logItemCount=0}}).add({_logItems:!1,logSource:e.method({isAbstract:!0}),logVItem:e.method({isAbstract:!0}),_translType:"Unknown",logTranslatorType:function(){return this._translType+" data source translator"},virtualItemSize:function(){return this.metadata.length},freeVirtualItemSize:function(){return this.virtualItemSize()-this._userUsedIndexesCount},setSource:function(t){if(!t)throw e.error.argumentRequired("source");this.source=t},defReader:function(t){t||e.fail.argumentRequired("readerSpec");var i;i=e.string.is(t)?t:t.names;i=e.string.is(i)?i.split(/\s*\,\s*/):e.array.as(i);var n=e.array.as(t.indexes);n&&n.forEach(this._userUseIndex,this);var a=!(!i||!i.length),r=t.reader;if(r){a||e.fail.argumentRequired("reader.names","Required argument when a reader function is specified.");this._userRead(r,i)}else{if(a)return this._userCreateReaders(i,n);n&&n.forEach(function(e){this._userIndexesToSingleDim[e]=null },this)}return n},configureType:function(){this._configureTypeCore()},_configureTypeCore:e.method({isAbstract:!0}),_initType:function(){this._userDimsReaders=[];this._userDimsReadersByDim={};this._userItem=[];this._userUsedIndexes={};this._userUsedIndexesCount=0;this._userIndexesToSingleDim=[];var e=this.options.readers;e&&e.forEach(this.defReader,this);var t=Tt.parseDistinctIndexArray(this.options.multiChartIndexes);t&&(this._multiChartIndexes=this.defReader({names:"multiChart",indexes:t}))},_userUseIndex:function(t){t=+t;if(0>t)throw e.error.argumentInvalid("index","Invalid reader index: '{0}'.",[t]);if(e.hasOwn(this._userUsedIndexes,t))throw e.error.argumentInvalid("index","Virtual item index '{0}' is already assigned.",[t]);this._userUsedIndexes[t]=!0;this._userUsedIndexesCount++;this._userItem[t]=!0;return t},_userCreateReaders:function(t,i){i?i.forEach(function(e,t){i[t]=+e}):i=[];var n,a=i.length,r=t.length;if(r>a){var s=a>0?i[a-1]+1:0;do{s=this._nextAvailableItemIndex(s);i[a]=s; this._userUseIndex(s);a++}while(r>a)}for(var o,l=a===r?r:r-1,u=0;l>u;u++){n=t[u];o=i[u];this._userIndexesToSingleDim[o]=n;this._userRead(this._propGet(n,o),n)}if(r>l)for(var c=Tt.splitIndexedId(t[r-1]),h=c[0],d=e.nullyTo(c[1],0),f=l;a>f;f++,d++){n=Tt.buildIndexedId(h,d);o=i[f];this._userIndexesToSingleDim[o]=n;this._userRead(this._propGet(n,o),n)}return i},_userRead:function(t,i){e.fun.is(t)||e.fail.argumentInvalid("reader","Reader must be a function.");e.array.is(i)?i.forEach(function(e){this._readDim(e,t)},this):this._readDim(i,t);this._userDimsReaders.push(t)},_readDim:function(e,t){var i,n,a=this._userIndexesToSingleDim.indexOf(e);if(a>=0){i=this._itemInfos[a];if(i&&!this.options.ignoreMetadataLabels){var r=i.label||i.name;r&&(n={label:r})}}this.complexTypeProj.readDim(e,n);this._userDimsReadersByDim[e]=t},execute:function(e){this.data=e;return this._executeCore()},_executeCore:function(){var t=this._getDimensionsReaders();return e.query(this._getItems()).select(function(e){return this._readItem(e,t) },this)},_getItems:function(){return this.source},_getDimensionsReaders:function(){return this._userDimsReaders},_readItem:function(t,i){var n=this._logItems;if(n){var a=this._logItemCount;if(10>a){Tt.log("virtual item ["+this._logItemCount+"]: "+Tt.stringify(t));this._logItemCount++}else{Tt.log("...");n=this._logItems=!1}}for(var r=0,s=i.length,o=this.data,l={};s>r;)i[r++].call(o,t,l);if(n){var u={};for(var c in l){var h=l[c];e.object.is(h)&&(h="v"in h?h.v:"value"in h?h.value:"...");u[c]=h}Tt.log("-> read: "+Tt.stringify(u))}return l},_propGet:function(e,t){function i(i,n){n[e]=i[t]}return i},_nextAvailableItemIndex:function(t,i){null==t&&(t=0);null==i&&(i=1/0);for(;i>t&&e.hasOwn(this._userItem,t);)t++;return i>t?t:-1},_getUnboundRoleDefaultDimNames:function(e,t,i,n){var a=this.chart.visualRoles[e];if(a&&!a.isPreBound()){var r=a.defaultDimensionName;if(r){r=r.match(/^(.*?)(\*)?$/)[1];i||(i=[]);null==n&&(n=0);null==t&&(t=1);for(;t--;){var s=Tt.buildIndexedId(r,n++);this.complexTypeProj.isReadOrCalc(s)||i.push(s) }return i.length?i:null}}},collectFreeDiscreteAndConstinuousIndexes:function(e,t){this._itemInfos.forEach(function(i,n){if(!this._userUsedIndexes[n]){var a=1===i.type?t:e;a&&a.push(n)}},this)}});e.type("pvc.data.MatrixTranslationOper",Tt.data.TranslationOper).add({_initType:function(){this.J=this.metadata.length;this.I=this.source.length;this._processMetadata();this.base()},setSource:function(e){this.base(e);this.I=this.source.length},_knownContinuousColTypes:{numeric:1,number:1,integer:1},_processMetadata:function(){for(var t=this._knownContinuousColTypes,i=e.query(this.metadata).select(function(e,t){e.colIndex=t;return e}).where(function(e){var i=e.colType;return!i||1!==t[i.toLowerCase()]}).select(function(e){return e.colIndex}).array(),n=e.array.create(this.J,1),a=this.I,r=this.source,s=i.length,o=0;a>o&&s>0;o++)for(var l=r[o],u=0;s>u;){var c=i[u],h=l[c];if(null!=h){n[c]=this._getSourceValueType(h);i.splice(u,1);s--}else u++}this._columnTypes=n},_buildItemInfoFromMetadata:function(e){var t=this.metadata[e]; return{type:this._columnTypes[e],name:t.colName,label:t.colLabel}},_getSourceValueType:function(e){switch(typeof e){case"number":return 1;case"object":if(e instanceof Date)return 1}return 0},logSource:function(){var t=["DATA SOURCE SUMMARY",Tt.logSeparator,"ROWS ("+Math.min(10,this.I)+"/"+this.I+")"];e.query(this.source).take(10).each(function(e,i){t.push(" ["+i+"] "+Tt.stringify(e))});this.I>10&&t.push(" ...");t.push("COLS ("+this.J+")");var i=this._columnTypes;this.metadata.forEach(function(e,n){t.push(" ["+n+"] '"+e.colName+"' (type: "+e.colType+", inspected: "+(i[n]?"number":"string")+(e.colLabel?", label: '"+e.colLabel+"'":"")+")")});t.push("");return t.join("\n")},_logVItem:function(t,i){var n=["VIRTUAL ITEM ARRAY",Tt.logSeparator],a=4,r=5,s=9;this._itemInfos.forEach(function(e,t){a=Math.max(a,(e.name||"").length);r=Math.max(r,(e.label||"").length);var i=this._userIndexesToSingleDim[t];i&&(s=Math.max(s,i.length))},this);n.push("Index | Kind | Type | "+e.string.padRight("Name",a)+" | "+e.string.padRight("Label",r)+" > Dimension","------+------+--------+-"+e.string.padRight("",a,"-")+"-+-"+e.string.padRight("",r,"-")+"-+-"+e.string.padRight("",s,"-")+"-"); var o=0;t.forEach(function(t){for(var s=0,l=i[t];l>s;s++){var u=this._itemInfos[o],c=this._userIndexesToSingleDim[o];void 0===c&&(c="");n.push(" "+o+" | "+t+" | "+(u.type?"number":"string")+" | "+e.string.padRight(u.name||"",a)+" | "+e.string.padRight(u.label||"",r)+" | "+c);o++}},this);n.push("");return n.join("\n")},_createPlot2SeriesKeySet:function(t,i){var n=null,a=i.length;e.query(t).each(function(t){var r=+t;if(isNaN(r))throw e.error.argumentInvalid("plot2DataSeriesIndexes","Element is not a number '{0}'.",[t]);if(0>r){if(-a>=r)throw e.error.argumentInvalid("plot2DataSeriesIndexes","Index is out of range '{0}'.",[r]);r=a+r}else if(r>=a)throw e.error.argumentInvalid("plot2DataSeriesIndexes","Index is out of range '{0}'.",[r]);n||(n={});n[i[r]]=!0});return n},_dataPartGet:function(t,i){function n(n,h){if(!a){r=t();a=l.data.dimensions(u);Tt.debug>=3&&r&&Tt.log("Second axis series values: "+Tt.stringify(e.keys(r)))}var d;i(n,c);var f=c.series;null!=f&&null!=f.v&&(f=f.v);d=e.hasOwn(r,f)?o||(o=a.intern("1")):s||(s=a.intern("0")); h[u]=d}var a,r,s,o,l=this,u=this.options.dataPartDimName,c={};return n}});e.type("pvc.data.CrosstabTranslationOper",Tt.data.MatrixTranslationOper).add({_translType:"Crosstab",virtualItemSize:function(){return this.R+this.C+this.M},_executeCore:function(){function t(e,t){for(var i=r[e],n=0,o=s[e];o-->0;)a[i++]=t[n++]}function i(e,t){for(var i=r.M,n=s._colGroupsIndexes[t],o=s.M,l=0;o>l;l++){var u=n[l];a[i++]=null!=u?e[u]:null}}if(!this.metadata.length)return e.query();var n=this._getDimensionsReaders(),a=new Array(this.virtualItemSize()),r=this._itemCrossGroupIndex,s=this,o=e.query(this.source);if(this._colGroups&&this._colGroups.length){var l=function(r){t("R",r);return e.query(this._colGroups).select(function(e,s){t("C",e);i(r,s);return this._readItem(a,n)},this)};return o.selectMany(l,this)}return o.select(function(e){t("R",e);return this._readItem(a,n)},this)},_processMetadata:function(){this.base();this._separator=this.options.separator||"~";var t=this.R=1;this.C=1;this.M=1;this.measuresDirection=null; var i,n=this.options.seriesInRows,a=this.metadata;i=a.map(n?function(e){return e.colName}:this.options.compatVersion<=1?function(e){return{v:e.colName}}:function(e){return{v:e.colName,f:e.colLabel}});var r=this._itemCrossGroupInfos={};if(this.options.isMultiValued){var s=e.get(this.options,"measuresInColumns",!0);if(s||null==this.options.measuresIndex){t=this.R=this._getCategoriesCount();var o=i.slice(t),l=o.length;if(l>0){if(s){this.measuresDirection="columns";this._processEncodedColGroups(o)}else{this._colGroups=o;this._colGroupsIndexes=[];this._colGroups.forEach(function(e,t){this._colGroups[t]=this._splitEncodedColGroupCell(e);this._colGroupsIndexes[t]=[this.R+t]},this);r.M=[this._buildItemInfoFromMetadata(t)]}this.C=this._colGroups[0].length;r.C=e.range(0,this.C).select(function(){return{type:0}}).array()}else{this.C=this.M=0;r.M=[];r.C=[]}}else{this.measuresDirection="rows";this.R=+this.options.measuresIndex;var u=this.options.measuresCount;null==u&&(u=1);this.M=u;this._colGroups=i.slice(this.R+1); this._colGroups.forEach(function(e,t){this._colGroups[t]=[e]},this)}}else{t=this.R=this._getCategoriesCount();this._colGroups=i.slice(t);this._colGroupsIndexes=new Array(this._colGroups.length);this._colGroups.forEach(function(e,i){this._colGroups[i]=[e];this._colGroupsIndexes[i]=[t+i]},this);r.C=[{type:0}];r.M=[{type:this._columnTypes[t]}]}r.R=e.range(0,this.R).select(this._buildItemInfoFromMetadata,this).array();var c=this._itemCrossGroupIndex={C:n?this.R:0,R:n?0:this.C,M:this.C+this.R},h=this._itemInfos=new Array(this.virtualItemSize());e.eachOwn(c,function(e,t){r[t].forEach(function(t,i){h[e+i]=t})});this._itemLogicalGroup={series:n?this.R:this.C,category:n?this.C:this.R,value:this.M};this._itemLogicalGroupIndex={series:0,category:this._itemLogicalGroup.series,value:this.C+this.R}},logVItem:function(){return this._logVItem(["C","R","M"],{C:this.C,R:this.R,M:this.M})},_getCategoriesCount:function(){var t=this.options.categoriesCount;null!=t&&(!isFinite(t)||0>t)&&(t=null);if(null==t){t=e.query(this._columnTypes).whayl(function(e){return 0===e }).count();t||(t=1)}return t},_splitEncodedColGroupCell:function(e){var t,i=e.v;if(null==i)i=[];else{i=i.split(this._separator);t=e.f;t&&(t=t.split(this._separator))}return i.map(function(e,i){return{v:e,f:t&&t[i]}})},_processEncodedColGroups:function(t){for(var i,n=t.length||e.assert("Must have columns"),a=this.R,r=[],s={},o=[],l=0;n>l;l++){var u,c,h,d,f=t[l],v=f.v,p=f.f,m=v.lastIndexOf(this._separator);if(0>m){u=v;c=p;v="";h=[]}else{u=v.substring(m+1);v=v.substring(0,m);h=v.split(this._separator);if(null!=p){d=p.split(this._separator);c=d.pop()}h.forEach(function(e,t){var i=d&&d[t];h[t]={v:e,f:i}})}if(i&&i.encValues===v)i.measureNames.push(u);else{i={startIndex:l,encValues:v,values:h,measureNames:[u]};r.push(i)}var g=l-i.startIndex,b=e.getOwn(s,u);if(b)g>b.groupIndex&&(b.groupIndex=g);else{s[u]=b={name:u,label:c,type:this._columnTypes[a+l],groupIndex:g,index:l};o.push(b)}}o.sort(function(t,i){return e.compare(t.groupIndex,i.groupIndex)||e.compare(t.index,i.index)});o.forEach(function(e,t){e.groupIndex=t });var _=r.length,y=new Array(_),x=new Array(_),S=o.length;r.map(function(e,t){y[t]=e.values;var i=e.startIndex,n=x[t]=new Array(S);e.measureNames.forEach(function(e,t){var r=s[e].groupIndex;n[r]=a+i+t})});this._colGroups=y;this._colGroupsIndexes=x;this._itemCrossGroupInfos.M=o;this.M=S},configureType:function(){if("rows"===this.measuresDirection)throw e.error.notImplemented();this.base()},_configureTypeCore:function(){function t(e,t,n){for(var o=a[e]+n;n>0;){var l=Tt.buildIndexedId(e,t);if(!i.complexTypeProj.isReadOrCalc(l)){r=i._nextAvailableItemIndex(r);if(r>=o)return;s.push({names:l,indexes:r});r++;n--}t++}}var i=this,n=i._itemLogicalGroup,a=i._itemLogicalGroupIndex,r=0,s=[],o=this.options.dataPartDimName;if(o&&1===this.C&&!this.complexTypeProj.isReadOrCalc(o)){var l=this.options.plot2DataSeriesIndexes;if(null!=l){var u=this._colGroups.map(function(e){return""+e[0].v});this._plot2SeriesKeySet=this._createPlot2SeriesKeySet(l,u)}}["series","category","value"].forEach(function(e){var i=n[e]; i>0&&t(e,0,i)});s&&s.forEach(this.defReader,this);if(this._plot2SeriesKeySet){var c=this._userDimsReadersByDim.series;if(c){var h=e.fun.constant(this._plot2SeriesKeySet);this._userRead(this._dataPartGet(h,c),o)}}}});e.type("pvc.data.RelationalTranslationOper",Tt.data.MatrixTranslationOper).add({M:0,C:0,S:0,_translType:"Relational",_processMetadata:function(){this.base();var t=this.metadata,i=this.J,n=this.options.categoriesCount;null!=n&&(!isFinite(n)||0>n)&&(n=0);var a,r,s;if(this.options.isMultiValued){r=Tt.parseDistinctIndexArray(this.options.measuresIndexes,0,i-1);s=r?r.length:0}var o;if(null==s)if(i>0&&3>=i&&(null==n||1===n)&&null==a){s=1;r=[i-1];n=i>=2?1:0;a=i>=3?1:0;o=n+a}else if(null!=n&&n>=i){o=i;n=i;a=0;s=0}else{var l=null!=n?i-n:1/0;r=e.query(t).where(function(e,t){return 0!==this._columnTypes[t]},this).select(function(e){return e.colIndex}).take(l).array();s=r.length}if(null==o){o=i-s;if(0===o)a=n=0;else if(null!=n)if(n>o){n=o;a=0}else a=o-n;else{a=o>1?1:0;n=o-a}}var u=this.options.seriesInRows,c=[]; if(o){a&&!u&&c.push({name:"S",count:a});n&&c.push({name:"C",count:n});a&&u&&c.push({name:"S",count:a})}s&&c.push({name:"M",count:s});var h=e.range(0,i).array();r&&r.forEach(function(e){h.splice(e,1)});var d={};c.forEach(function(e){var t=e.count,i=e.name;d[i]=e;e.indexes=r&&"M"===i?r:h.splice(0,t)});this.M=s;this.S=a;this.C=n;var f=[];["S","C","M"].forEach(function(t){var i=d[t];i&&e.array.append(f,i.indexes)});this._itemInfos=f.map(this._buildItemInfoFromMetadata,this);this._itemCrossGroupIndex={S:0,C:this.S,M:this.S+this.C};this._itemPerm=f},logVItem:function(){return this._logVItem(["S","C","M"],{S:this.S,C:this.C,M:this.M})},_configureTypeCore:function(){function e(e,a,r,s){for(var o=t._itemCrossGroupIndex[a]+s;s>0;){var l=Tt.buildIndexedId(e,r);if(!t.complexTypeProj.isReadOrCalc(l)){i=t._nextAvailableItemIndex(i);if(i>=o)return;n.push({names:l,indexes:i});i++;s--}r++}}var t=this,i=0,n=[];this.S>0&&e("series","S",0,this.S);this.C>0&&e("category","C",0,this.C);this.M>0&&e("value","M",0,this.M); n&&n.forEach(this.defReader,this);var a=this.options.dataPartDimName;if(a&&!this.complexTypeProj.isReadOrCalc(a)){var r=this.options.plot2DataSeriesIndexes;if(null!=r){var s=this._userDimsReadersByDim.series;s&&this._userRead(y.call(this,r,s),a)}}},_executeCore:function(){var i=this._getDimensionsReaders(),n=this._itemPerm;return e.query(this._getItems()).select(function(e){e=t.permute(e,n);return this._readItem(e,i)},this)}});e.type("pvc.data.Atom").init(function(t,i,n,a,r){this.dimension=t;this.id=null==i?-e.nextId():e.nextId();this.value=i;this.label=n;void 0!==a&&(this.rawValue=a);this.key=r}).add({isVirtual:!1,rawValue:void 0,toString:function(){var e=this.label;if(null!=e)return e;e=this.value;return null!=e?""+e:""}});var Wt=1;e.type("pvc.data.Complex").init(function(t,i,n,a,r,s){var o=this;o.id=Wt++;var l;if(t){l=t.owner;a||(a=t.atoms)}o.owner=l=l||o;var u=l.type||e.fail.argumentRequired("owner.type");o.atoms=a?Object.create(a):{};var c=!!n;n||(n=u._dimsNames);var h,d,f=o.atoms,v=n.length; if(i){var p=l._dimensions,m=function(e){var t=i[e],n=p[e].intern(t);null==t||a&&n===a[e]||(f[e]=n)};if(c){h=v;for(;h--;)m(n[h])}else for(d in i)m(d);if(s){i=u._calculate(o);for(d in i)e.hasOwnProp.call(f,d)||m(d)}}var g;if(v)if(1===v){g=f[n[0]];o.value=g.value;o.rawValue=g.rawValue;o.key=g.key;r&&(o.label=g.label)}else{var b,_,y,x=l.keySep,S=l.labelSep;for(h=0;v>h;h++){g=f[n[h]];h?b+=x+g.key:b=g.key;r&&(y=g.label)&&(_?_+=S+y:_=y)}o.value=o.rawValue=o.key=b;r&&(o.label=_)}else{o.value=null;o.key="";r&&(o.label="")}}).add({labelSep:" ~ ",keySep:"~",value:null,label:null,rawValue:void 0,ensureLabel:function(){var t=this.label;if(null==t){t="";var i=this.owner.labelSep;e.eachOwn(this.atoms,function(e){var n=e.label;n&&(t?t+=i+n:t=n)});this.label=t}return t},view:function(e){return new Tt.data.ComplexView(this,e)},toString:function(){var e=[""+this.constructor.typeName];null!=this.index&&e.push("#"+this.index);this.owner.type.dimensionsNames().forEach(function(t){e.push(t+": "+Tt.stringify(this.atoms[t].value)) },this);return e.join(" ")},rightTrimKeySep:function(e){return e&&Tt.data.Complex.rightTrimKeySep(e,this.owner.keySep)},absKeyTrimmed:function(){return this.rightTrimKeySep(this.absKey)},keyTrimmed:function(){return this.rightTrimKeySep(this.key)}});Tt.data.Complex.rightTrimKeySep=function(e,t){if(e&&t)for(var i,n=t.length;e.lastIndexOf(t)===(i=e.length-n)&&i>=0;)e=e.substr(0,i);return e};Tt.data.Complex.values=function(e,t){var i=e.atoms;return t.map(function(e){return i[e].value})};Tt.data.Complex.compositeKey=function(e,t){var i=e.atoms;return t.map(function(e){return i[e].key}).join(e.owner.keySep)};Tt.data.Complex.labels=function(e,t){var i=e.atoms;return t.map(function(e){return i[e].label})};var qt=e.propGet("id");e.type("pvc.data.ComplexView",Tt.data.Complex).init(function(e,t){this.source=e;this.viewDimNames=t;this.base(e,e.atoms,t,e.owner.atoms,!0)}).add({values:function(){return Tt.data.Complex.values(this,this.viewDimNames)},labels:function(){return Tt.data.Complex.labels(this,this.viewDimNames) }});e.type("pvc.data.Datum",Tt.data.Complex).init(function(e,t){this.base(e,t,null,null,!1,!0)}).add({isSelected:!1,isVisible:!0,isNull:!1,isVirtual:!1,isTrend:!1,trend:null,isInterpolated:!1,interpolation:null,setSelected:function(e){if(this.isNull)return!1;e=null==e||!!e;var t=this.isSelected!==e;if(t){e?this.isSelected=!0:delete this.isSelected;Z.call(this.owner,this,e)}return t},toggleSelected:function(){return this.setSelected(!this.isSelected)},setVisible:function(e){if(this.isNull)return!1;e=null==e||!!e;var t=this.isVisible!==e;if(t){this.isVisible=e;X.call(this.owner,this,e)}return t},toggleVisible:function(){return this.setVisible(!this.isVisible)}});var Gt=e.propGet("isSelected");e.type("pvc.data.TrendDatum",Tt.data.Datum).init(function(e,t,i){this.base(e,t);this.trend=i}).add({isVirtual:!0,isTrend:!0});e.type("pvc.data.InterpolationDatum",Tt.data.Datum).init(function(e,t,i){this.base(e,t);this.interpolation=i}).add({isVirtual:!0,isInterpolated:!0});e.type("pvc.data.Dimension").init(function(t,i){this.data=t; this.type=i;this.root=this;this.owner=this;var n=i.name;this.name=n;this._atomComparer=i.atomComparer();this._atomsByKey={};if(t.isOwner()){this._atoms=[];V.call(this)}else{var a,r=t.parent;if(r){a=r._dimensions[n];F.call(a,this);this.root=t.parent.root}else{r=t.linkParent;r||e.assert("Data must have a linkParent");a=r._dimensions[n];E.call(a,this)}this._nullAtom=this.owner._nullAtom;this._lazyInit=function(){this._lazyInit=null;for(var t=this.data._datums,i=t.length,r=this._atomsByKey,s=0;i>s;s++){var o=t[s].atoms[n];r[o.key]=o}this._atoms=a.atoms().filter(function(t){return e.hasOwnProp.call(r,t.key)})}}}).add({parent:null,linkParent:null,_linkChildren:null,_atomsByKey:null,_atomVisibleDatumsCount:null,_disposed:!1,_nullAtom:null,_virtualNullAtom:null,_visibleAtoms:null,_visibleIndexes:null,_atomComparer:null,_atoms:null,_sumCache:null,count:function(){this._lazyInit&&this._lazyInit();return this._atoms.length},isVisible:function(t){this._lazyInit&&this._lazyInit();e.hasOwn(this._atomsByKey,t.key)||e.assert("Atom must exist in this dimension."); return q.call(this)[t.key]>0},atoms:function(t){this._lazyInit&&this._lazyInit();var i=e.get(t,"visible");if(null==i)return this._atoms;i=!!i;this._visibleAtoms||(this._visibleAtoms={});return this._visibleAtoms[i]||(this._visibleAtoms[i]=H.call(this,i))},indexes:function(i){this._lazyInit&&this._lazyInit();var n=e.get(i,"visible");if(null==n)return t.range(0,this._atoms.length);n=!!n;this._visibleIndexes||(this._visibleIndexes={});return this._visibleIndexes[n]||(this._visibleIndexes[n]=G.call(this,n))},atom:function(e){if(null==e||""===e)return this._nullAtom;if(e instanceof Tt.data.Atom)return e;this._lazyInit&&this._lazyInit();var t=this.type._key,i=t?t.call(null,e):e;return this._atomsByKey[i]||null},getDistinctAtoms:function(e){var t=[],i=e?e.length:0;if(i)for(var n={},a=0;i>a;a++){var r,s=this.atom(e[a]);if(s&&!n[r="\x00"+s.key]){n[r]=s;t.push(s)}}return t},extent:function(t){var i=this.atoms(t),n=i.length;if(!n)return void 0;var a=this._nullAtom&&null==i[0].value?1:0,r=n-a;if(r>0){var s,o=i[a],l=i[n-1]; if(o!==l&&e.get(t,"abs",!1)){var u=o.value<0?-1:1,c=l.value<0?-1:1;if(u===c){if(0>c){s=l;l=o;o=s}}else if(r>2){l.value<-o.value&&(l=o);var h=e.array.binarySearch(i,0,this.type.comparer(),function(e){return e.value});if(0>h){h=~h;var d=i[h-1],f=i[h];o=-d.valuen?t[n]:void 0},max:function(e){var t=this.atoms(e),i=t.length;return i&&null!=t[i-1].value?t[i-1]:void 0},sumAbs:function(t){return this.sum(e.create(t,{abs:!0}))},value:function(t){return this.sum(t&&t.abs?e.create(t,{abs:!1}):t)},valueAbs:function(e){var t=this.value(e);return t?Math.abs(t):t},sum:function(t){var i=!!e.get(t,"abs",!1),n=e.get(t,"zeroIfNone",!0),a=L(t)+":"+i,r=e.getOwn(this._sumCache,a);if(void 0===r){var s=this.name;r=this.data.datums(null,t).reduce(function(e,t){var n=t.atoms[s].value;i&&0>n&&(n=-n); return null!=e?e+n:n},null);(this._sumCache||(this._sumCache={}))[a]=r}return n?r||0:r},percent:function(e,t){var i=e instanceof Tt.data.Atom?e.value:e;if(!i)return 0;var n=this.sumAbs(t);return n?Math.abs(i)/n:0},valuePercent:function(e){var t=this.valueAbs(e);if(!t)return 0;var i=this.data.parent;if(!i)return 1;var n=i.dimensionsSumAbs(this.name,e);return t/n},percentOverParent:function(e){return this.valuePercent(e)},format:function(e,t){return""+(this.type._formatter?this.type._formatter.call(null,e,t):"")},intern:function(t,i){if(null==t||""===t)return this._nullAtom||O.call(this,t);if(t instanceof Tt.data.Atom){if(t.dimension!==this)throw e.error.operationInvalid("Atom is of a different dimension.");return t}var n,a,r=this.type;if("object"==typeof t&&"v"in t){a=t.f;t=t.v;if(null==t||""===t)return this._nullAtom||O.call(this)}if(i)n=t;else{var s=r._converter;if(s){n=s(t);if(null==n||""===n)return this._nullAtom||O.call(this,t)}else n=t}var o=r.cast;if(o){n=o(n);if(null==n||""===n)return this._nullAtom||O.call(this) }var l=r._key,u=""+(l?l(n):n);u||e.fail.operationInvalid("Only a null value can have an empty key.");var c=this._atomsByKey[u];if(c){!i&&c.isVirtual&&delete c.isVirtual;return c}return T.call(this,r,t,u,n,a,i)},read:function(e,t){if(null==e||""===e)return null;var i,n=this.type;if("object"==typeof e&&"v"in e){t=e.f;e=e.v;if(null==e||""===e)return null}var a=n._converter;i=a?a(e):e;if(null==i||""===i)return null;var r=n.cast;if(r){i=r(i);if(null==i||""===i)return null}var s=n._key,o=""+(s?s(i):i),l=this._atomsByKey[o];if(l)return{rawValue:e,key:o,value:l.value,label:""+(null==t?l.label:t)};if(null==t){var u=n._formatter;t=u?u(i,e):i}t=""+t;return{rawValue:e,key:o,value:i,label:t}},dispose:function(){var e=this;if(!e._disposed){v(e.childNodes,"parent");v(e._linkChildren,"linkParent");var t;(t=e.parent)&&m(t,"childNodes",e,"parent");(t=e.linkParent)&&m(t,"_linkChildren",e,"linkParent");z.call(e);e._lazyInit=e._atoms=e._nullAtom=e._virtualNullAtom=null;e._disposed=!0}}});e.type("pvc.data.Data",Tt.data.Complex).init(function(i){i||e.fail.argumentRequired("keyArgs"); this._visibleNotNullDatums=new e.Map;var n,a,r,s,o,l,u=this.parent=i.parent||null;if(u){this.root=u.root;this.depth=u.depth+1;this.type=u.type;o=i.datums||e.fail.argumentRequired("datums");n=u.owner;a=i.atoms||e.fail.argumentRequired("atoms");s=i.atomsDimNames||e.fail.argumentRequired("atomsDimNames");r=u.atoms}else{this.root=this;s=[];var c=i.linkParent||null;if(c){n=c.owner;this.type=n.type;o=i.datums||e.fail.argumentRequired("datums");this._leafs=[];this._wherePred=i.where||null;r=c.atoms;l=e.get(i,"index",null);U.call(c,this,l)}else{n=this;r={};i.labelSep&&(this.labelSep=i.labelSep);i.keySep&&(this.keySep=i.keySep);this.type=i.type||e.fail.argumentRequired("type");this._selectedNotNullDatums=new e.Map}}o&&et.call(this,o);this.owner=n;this._atomsBase=r;this._dimensions={};this._dimensionsList=[];this.type.dimensionsList().forEach(this._initDimension,this);this.base(n,a,s,r,!0);t.Dom.Node.call(this);if(u){l=e.get(i,"index",null);j.call(u,this,l);this.absLabel=u.absLabel?e.string.join(n.labelSep,u.absLabel,this.label):this.label; this.absKey=u.absKey?e.string.join(n.keySep,u.absKey,this.key):this.key}else{this.absLabel=this.label;this.absKey=this.key}}).add(t.Dom.Node).add({parent:null,linkParent:null,_dimensions:null,_dimensionsList:null,_freeDimensionNames:null,_linkChildren:null,_leafs:null,_childrenByKey:null,_visibleNotNullDatums:null,_selectedNotNullDatums:null,_groupByCache:null,_sumAbsCache:null,treeHeight:null,_groupOper:null,_wherePred:null,_groupSpec:null,_groupLevel:null,_datums:null,_datumsById:null,_datumsByKey:null,depth:0,label:"",absLabel:"",_disposed:!1,_isFlattenGroup:!1,_isDegenerateFlattenGroup:!1,_initDimension:function(e){var t=new Tt.data.Dimension(this,e);this._dimensions[e.name]=t;this._dimensionsList.push(t)},dimensions:function(t,i){if(null==t)return this._dimensions;var n=e.getOwn(this._dimensions,t);if(!n&&e.get(i,"assertExists",!0))throw e.error.argumentInvalid("name","Undefined dimension '{0}'.",[t]);return n},dimensionsList:function(){return this._dimensionsList},freeDimensionsNames:function(){var e=this._freeDimensionNames; e||(this._freeDimensionNames=e=this.type.dimensionsNames().filter(function(e){var t=this.atoms[e];return!(t instanceof Tt.data.Atom)||null==t.value},this));return e},isOwner:function(){return this.owner===this},children:function(){var t=this.childNodes;return t.length?e.query(t):e.query()},child:function(t){return e.getOwn(this._childrenByKey,t,null)},childCount:function(){return this.childNodes.length},leafs:function(){return e.query(this._leafs)},count:function(){return this._datums.length},firstDatum:function(){return this._datums.length?this._datums[0]:null},firstAtoms:function(){return(this.firstDatum()||this).atoms},singleDatum:function(){var e=this._datums;return 1===e.length?e[0]:null},dispose:function(){var e=this;if(!e._disposed){Q.call(e);var t;(t=e._selectedNotNullDatums)&&t.clear();e._visibleNotNullDatums.clear();t=e._dimensionsList;for(var i=0,n=t.length;n>i;i++)t[i].dispose();e._dimensions=null;e._dimensionsLIst=null;if(t=e.parent){t.removeChild(e);e.parent=null}(t=e.linkParent)&&K.call(t,e); e._disposed=!0}},disposeChildren:function(){Q.call(this)}});Tt.data.Data.add({selectedCount:function(){return this.isOwner()?this._selectedNotNullDatums.count:this.datums(null,{selected:!0}).count()},selectedDatums:function(){return this.isOwner()?this._selectedNotNullDatums.values():this.datums(null,{selected:!0}).array()},selectedDatumMap:function(){if(!this.isOwner()){var t=this.datums(null,{selected:!0}).object({name:e.propGet("id")});return new e.Set(t)}return this._selectedNotNullDatums.clone()},visibleCount:function(){return this._visibleNotNullDatums.count},replaceSelected:function(t){e.array.is(t)||(t=t.array());var i=e.query(t).where(Gt).object({name:qt}),n=this.owner.clearSelected(function(t){return!e.hasOwn(i,t.id)});n|=Tt.data.Data.setSelected(t,!0);return n},clearSelected:function(e){if(this.owner!==this)return this.owner.clearSelected(e);if(!this._selectedNotNullDatums.count)return!1;var t;if(e){t=!1;this._selectedNotNullDatums.values().filter(e).forEach(function(e){t=!0; w.call(e);this._selectedNotNullDatums.rem(e.id)},this)}else{t=!0;this._selectedNotNullDatums.values().forEach(function(e){w.call(e)});this._selectedNotNullDatums.clear()}return t}});Tt.data.Data.setSelected=function(t,i){var n=0;t&&e.query(t).each(function(e){n|=e.setSelected(i)});return!!n};Tt.data.Data.toggleSelected=function(t,i){e.array.isLike(t)||(t=e.query(t).array());var n=e.query(t),a=i?n.any(Gt):n.all(C);return this.setSelected(t,!a)};Tt.data.Data.setVisible=function(t,i){var n=0;t&&e.query(t).each(function(e){n|=e.setVisible(i)});return!!n};Tt.data.Data.toggleVisible=function(t){e.array.isLike(t)||(t=e.query(t).array());var i=e.query(t).all(e.propGet("isVisible"));return Tt.data.Data.setVisible(t,!i)};e.space("pvc.data").FlatteningMode=e.set(e.makeEnum(["DfsPre","DfsPost"]),"None",0);e.type("pvc.data.GroupingSpec").init(function(t,i,n){this.type=i||null;var a=[];this.hasCompositeLevels=!1;var r=[];this.levels=e.query(t||void 0).where(function(e){return e.dimensions.length>0}).select(function(t){a.push(t.id); e.array.append(r,t.dimensionNames());!this.hasCompositeLevels&&t.dimensions.length>1&&(this.hasCompositeLevels=!0);t._setAccDimNames(r.slice(0));return t},this).array();this._dimNames=r;this.depth=this.levels.length;this.isSingleLevel=1===this.depth;this.isSingleDimension=this.isSingleLevel&&!this.hasCompositeLevels;this.firstDimension=this.depth>0?this.levels[0].dimensions[0]:null;this.rootLabel=e.get(n,"rootLabel")||"";this.flatteningMode=e.get(n,"flatteningMode")||Tt.data.FlatteningMode.None;this._cacheKey=this._calcCacheKey();this.id=this._cacheKey+"##"+a.join("||")}).add({_calcCacheKey:function(t){return[e.get(t,"flatteningMode")||this.flatteningMode,e.get(t,"reverse")||"false",e.get(t,"isSingleLevel")||this.isSingleLevel,e.get(t,"rootLabel")||this.rootLabel].join("#")},bind:function(t){this.type=t||e.fail.argumentRequired("type");this.levels.forEach(function(e){e.bind(t)})},dimensions:function(){return e.query(this.levels).prop("dimensions").selectMany()},dimensionNames:function(){return this._dimNames },view:function(e){return e.view(this.dimensionNames())},isDiscrete:function(){var e;return!this.isSingleDimension||!!(e=this.firstDimension)&&e.type.isDiscrete},firstDimensionType:function(){var e=this.firstDimension;return e&&e.type},firstDimensionName:function(){var e=this.firstDimensionType();return e&&e.name},firstDimensionValueType:function(){var e=this.firstDimensionType();return e&&e.valueType},isNull:function(){return!this.levels.length},ensure:function(t){var i;if(t){var n=this._calcCacheKey(t);if(n!==this._cacheKey){var a=e.lazy(this,"_groupingCache");i=e.getOwn(a,n);i||(i=a[n]=this._ensure(t))}}return i||this},_ensure:function(t){var i=this;if(e.get(t,"isSingleLevel")&&!i.isSingleLevel)return i._singleLevelGrouping(t);if(e.get(t,"reverse"))return i._reverse(t);var n=e.get(t,"flatteningMode")||i.flatteningMode,a=e.get(t,"rootLabel")||i.rootLabel;return n!==i.flatteningMode||a!==i.rootLabel?new Tt.data.GroupingSpec(i.levels,i.type,{flatteningMode:n,rootLabel:a}):i},_singleLevelGrouping:function(t){var i=!!e.get(t,"reverse"),n=this.dimensions().select(function(e){return i?new Tt.data.GroupingDimensionSpec(e.name,!e.reverse,e.type.complexType):e }),a=new Tt.data.GroupingLevelSpec(n,this.type);return new Tt.data.GroupingSpec([a],this.type,{flatteningMode:null,rootLabel:e.get(t,"rootLabel")||this.rootLabel})},_reverse:function(t){var i=e.query(this.levels).select(function(t){var i=e.query(t.dimensions).select(function(e){return new Tt.data.GroupingDimensionSpec(e.name,!e.reverse,e.type.complexType)});return new Tt.data.GroupingLevelSpec(i,this.type)});return new Tt.data.GroupingSpec(i,this.type,{flatteningMode:e.get(t,"flatteningMode")||this.flatteningMode,rootLabel:e.get(t,"rootLabel")||this.rootLabel})},toString:function(){return e.query(this.levels).select(function(e){return""+e}).array().join(", ")}});e.type("pvc.data.GroupingLevelSpec").init(function(t,i){var n=[],a=[];this.dimensions=e.query(t).select(function(e){n.push(e.id);a.push(e.name);return e}).array();this._dimNames=a;this.dimensionsInDefOrder=this.dimensions.slice(0);i&&this._sortDimensions(i);this.id=n.join(",");this.depth=this.dimensions.length;var r=this;this.comparer=function(e,t){return r.compare(e,t) }}).add({_sortDimensions:function(e){e.sortDimensionNames(this.dimensionsInDefOrder,function(e){return e.name})},_setAccDimNames:function(e){this._accDimNames=e},accDimensionNames:function(){return this._accDimNames},dimensionNames:function(){return this._dimNames},bind:function(e){this._sortDimensions(e);this.dimensions.forEach(function(t){t.bind(e)})},compare:function(e,t){for(var i=this.dimensions,n=this.depth,a=0;n>a;a++){var r=i[a].compareDatums(e,t);if(r)return r}return 0},key:function(e){for(var t="",i=this._dimNames,n=this.depth,a=e.owner.keySep,r=e.atoms,s=0;n>s;s++){var o=r[i[s]].key;s?t+=a+o:t=o}return t},atomsInfo:function(e){for(var t={},i=this._dimNames,n=this.depth,a=e.atoms,r=(e.owner.keySep,0);n>r;r++){var s=i[r];t[s]=a[s]}return{atoms:t,dimNames:i}},toString:function(){return e.query(this.dimensions).select(function(e){return""+e}).array().join("|")}});e.type("pvc.data.GroupingDimensionSpec").init(function(e,t,i){this.name=e;this.reverse=!!t;this.id=e+":"+(t?"0":"1");i&&this.bind(i) }).add({type:null,comparer:null,bind:function(t){t||e.fail.argumentRequired("type");this.type=t.dimensions(this.name);this.comparer=this.type.atomComparer(this.reverse)},compareDatums:function(e,t){if(this.type.isComparable){var i=this.name;return this.comparer(e.atoms[i],t.atoms[i])}return this.reverse?t.id-e.id:e.id-t.id},toString:function(){return this.name+(this.reverse?" desc":"")}});Tt.data.GroupingSpec.parse=function(t,i){if(!t)return new Tt.data.GroupingSpec(null,i);var n;e.array.is(t)?n=t:e.string.is(t)&&(n=t.split(/\s*,\s*/));var a=e.query(n).select(function(e){var t=J(e,i);return new Tt.data.GroupingLevelSpec(t,i)});return new Tt.data.GroupingSpec(a,i)};var Ht=/^\s*(.+?)(?:\s+(asc|desc))?\s*$/i;e.type("pvc.data.DataOper").init(function(t){t||e.fail.argumentRequired("linkParent");this._linkParent=t}).add({key:null,execute:e.method({isAbstract:!0})});e.type("pvc.data.GroupingOper",Tt.data.DataOper).init(function(t,i,n){i||e.fail.argumentRequired("groupingSpecs");this.base(t,n); this._where=e.get(n,"where");this._visible=e.get(n,"visible",null);this._selected=e.get(n,"selected",null);var a=this._isNull=e.get(n,"isNull",null);this._postFilter=null!=a?function(e){return e.isNull===a}:null;var r=null==this._selected,s="";if(this._where){s=e.get(n,"whereKey");if(!s)if(n&&null!==s){s=""+e.nextId("dataOperWhereKey");n.whereKey=s}else r=!1}var o=[];this._groupSpecs=e.array.as(i).map(function(i){if(i instanceof Tt.data.GroupingSpec){if(i.type!==t.type)throw e.error.argumentInvalid("groupingSpecText","Invalid associated complex type.")}else i=Tt.data.GroupingSpec.parse(i,t.type);o.push(i.id);return i});r&&(this.key=o.join("!!")+"||visible:"+this._visible+"||isNull:"+this._isNull+"||where:"+s)}).add({execute:function(){var t=rt(e.query(this._linkParent._datums),{visible:this._visible,selected:this._selected,where:this._where}),i=this._group(t);return this._generateData(i,null,this._linkParent)},executeAdd:function(t,i){var n=rt(e.query(i),{visible:this._visible,selected:this._selected,where:this._where}),a=this._group(n); this._generateData(a,null,this._linkParent,t);return a.datums},_group:function(t){var i={isRoot:!0,treeHeight:e.query(this._groupSpecs).select(function(e){var t=e.levels.length;return t?e.flatteningMode?1:t:0}).reduce(e.add,0),datums:[]};i.treeHeight>0&&this._groupSpecRecursive(i,e.query(t).array(),0);return i},_groupSpecRecursive:function(e,t,i){var n=this._groupSpecs[i];n.flatteningMode?this._groupSpecRecursiveFlattened(e,t,n,i):this._groupSpecRecursiveNormal(e,t,n,i)},_groupSpecRecursiveNormal:function(t,i,n,a){function r(t,i,u){var c=s[u],h=u===o-1,d=l&&h;t.groupSpec=n;t.groupLevelSpec=c;for(var f=t.children=this._groupLevelDatums(c,t,i,!1),v=0,p=f.length;p>v;v++){var m=f[v];if(!d){var g=m.datums;m.datums=[];h?this._groupSpecRecursive(m,g,a+1):r.call(this,m,g,u+1)}e.array.append(t.datums,m.datums)}}var s=n.levels,o=s.length,l=a===this._groupSpecs.length-1;t.isRoot&&(t.label=n.rootLabel);r.call(this,t,i,0)},_groupSpecRecursiveFlattened:function(t,i,n,a){function r(t,i,n){for(var d=o[n],v=n===l-1,p=u&&v,m=this._groupLevelDatums(d,t,i,!0),g=u?t.datums:[],b=0,_=m.length;_>b;b++){var y=m[b],x=y.datums; e.array.lazy(t,"_children").push(y);if(e.hasOwn(h,y.key))e.array.append(g,x);else{var S=c.length;if(!s){f(y);t.isFlattenGroup=!0}if(!p){y.datums=[];v?this._groupSpecRecursive(y,x,a+1):r.call(this,y,x,n+1)}e.array.append(g,y.datums);if(s){if(e.hasOwn(h,y.key)){y.isFlattenGroup||e.assert("Must be a parent for duplicate keys to exist.");if(1===y._children.length){c.splice(S,c.length-S);y.isDegenerateFlattenGroup=!0}}f(y);t.isFlattenGroup=!0}}}u||this._groupSpecRecursive(t,g,a+1)}var s=n.flatteningMode===Tt.data.FlatteningMode.DfsPost,o=n.levels,l=o.length,u=a===this._groupSpecs.length-1,c=[],h={};t.children=c;t.childrenByKey=h;var d={key:"",absKey:"",atoms:{},datums:[],label:n.rootLabel,dimNames:[]},f=function(e){c.push(e);h[e.key]=e};s||f(d);r.call(this,d,i,0);s&&f(d);t.datums=d.datums},_groupLevelDatums:function(t,i,n,a){for(var r,s=[],o={},l=this._postFilter,u=t.comparer,c=function(e,t){return u(e.firstDatum,t.firstDatum)},h=0,d=n.length;d>h;h++){var f=n[h],v=t.key(f),p=e.hasOwnProp.call(o,v)&&o[v]; if(p)(!l||l(f))&&p.datums.push(f);else{p=t.atomsInfo(f);p.key=v;p.firstDatum=f;p.datums=!l||l(f)?[f]:[];if(a){r||(r=f.owner.keySep);this._onNewChildNodeFlattened(v,r,p,t,i)}e.array.insert(s,p,c);o[v]=p}}if(l){h=s.length;for(;h--;)s[h].datums.length||s.splice(h,1)}return s},_onNewChildNodeFlattened:function(t,i,n,a,r){e.copy(n.atoms,r.atoms);n.dimNames=a.accDimensionNames();if(r.dimNames.length){var s=r.absKey+i+t;n.absKey=s;n.key=Tt.data.Complex.rightTrimKeySep(s,i)}else n.absKey=t},_generateData:function(t,i,n,a){var r,s;if(t.isRoot)if(a){r=a;nt.call(r,t.datums)}else{s=!0;r=new Tt.data.Data({linkParent:n,datums:t.datums});r.treeHeight=t.treeHeight;r._groupOper=this}else{if(a){r=n.child(t.key);r&&it.call(r,t.datums)}if(!r){s=!0;var o,l;a&&(l=n.childNodes)&&(o=~e.array.binarySearch(l,t.datums[0],i.groupLevelSpec.comparer));r=new Tt.data.Data({parent:n,atoms:t.atoms,atomsDimNames:t.dimNames,datums:t.datums,index:o})}}if(s){if(t.isFlattenGroup){r._isFlattenGroup=!0;r._isDegenerateFlattenGroup=!!t.isDegenerateFlattenGroup }var u=t.label;if(u){r.label+=u;r.absLabel+=u}}var c=t.children,h=c&&c.length;if(h){if(s){r._groupSpec=t.groupSpec;r._groupLevelSpec=t.groupLevelSpec}for(var d=0;h>d;d++)this._generateData(c[d],t,r,a)}else if(s&&!t.isRoot){var f=r.root._leafs;r.leafIndex=f.length;f.push(r)}return r}});e.type("pvc.data.LinearInterpolationOper").init(function(t,i,n,a,r,s,o){this._newDatums=[];this._data=n;var l=a.flatten(t).children(),u=r.isBound()?r.flatten(i,{visible:!0,isNull:!1}).children().array():[null];this._isCatDiscrete=a.grouping.isDiscrete();this._firstCatDim=this._isCatDiscrete?null:t.owner.dimensions(a.firstDimensionName());this._stretchEnds=o;var c=this._valDim=t.owner.dimensions(s.firstDimensionName()),h={visible:!0,zeroIfNone:!1};this._catInfos=l.select(function(e,t){var i=n.child(e.key),a={data:i||e,value:e.value,isInterpolated:!1,serInfos:null,index:t};a.serInfos=u.map(function(e){var t=i;t&&e&&(t=t.child(e.key));var n=t?t.dimensions(c.name).value(h):null;return{data:e,group:t,value:n,isNull:null==n,catInfo:a} });return a}).array();this._serCount=u.length;this._serStates=e.range(0,this._serCount).select(function(e){return new Tt.data.LinearInterpolationOperSeriesState(this,e)},this).array()}).add({interpolate:function(){for(var e;e=this._catInfos.shift();)e.serInfos.forEach(this._visitSeries,this);var t=this._newDatums;t.length&&this._data.owner.add(t)},_visitSeries:function(e,t){this._serStates[t].visit(e)},nextUnprocessedNonNullCategOfSeries:function(e){for(var t=0,i=this._catInfos.length;i>t;){var n=this._catInfos[t++],a=n.serInfos[e];if(!a.isNull)return a}}});e.type("pvc.data.LinearInterpolationOperSeriesState").init(function(e,t){this.interpolation=e;this.index=t;this._lastNonNull(null)}).add({visit:function(e){e.isNull?this._interpolate(e):this._lastNonNull(e)},_lastNonNull:function(e){if(arguments.length){this.__lastNonNull=e;this.__nextNonNull=void 0}return this.__lastNonNull},_nextNonNull:function(){return this.__nextNonNull},_initInterpData:function(){if(void 0===this.__nextNonNull){var t=this.__lastNonNull,i=this.__nextNonNull=this.interpolation.nextUnprocessedNonNullCategOfSeries(this.index)||null; if(i&&t){var n=t.value,a=i.value,r=a-n;if(this.interpolation._isCatDiscrete){var s=i.catInfo.index-t.catInfo.index;s>=2||e.assert("Must have at least one interpolation point.");this._stepValue=r/s;this._middleIndex=~~(s/2);var o=s-1;this._isOdd=o%2>0}else{var l=+t.catInfo.value,u=+i.catInfo.value,c=u-l;this._steep=r/c;this._middleCat=(u+l)/2}}}},_interpolate:function(t){this._initInterpData();var i=this.__nextNonNull,n=this.__lastNonNull,a=i||n;if(a){var r,s,o=this.interpolation,l=t.catInfo;if(i&&n)if(o._isCatDiscrete){var u=l.index-n.catInfo.index;r=n.value+this._stepValue*u;s=this._isOdd?ut;){var n=this._catInfos[t++],a=n.serInfos[e];if(!a.isNull)return a}}});e.type("pvc.data.ZeroInterpolationOperSeriesState").init(function(e,t){this.interpolation=e;this.index=t;this._lastNonNull(null)}).add({visit:function(e){e.isNull?this._interpolate(e):this._lastNonNull(e)},_lastNonNull:function(e){if(arguments.length){this.__lastNonNull=e;this.__nextNonNull=void 0}return this.__lastNonNull},_nextNonNull:function(){return this.__nextNonNull},_initInterpData:function(){if(void 0===this.__nextNonNull){var t=this.__lastNonNull,i=this.__nextNonNull=this.interpolation.nextUnprocessedNonNullCategOfSeries(this.index)||null;if(i&&t){{t.value,i.value}if(this.interpolation._isCatDiscrete){var n=i.catInfo.index-t.catInfo.index;n>=2||e.assert("Must have at least one interpolation point.");this._middleIndex=~~(n/2); var a=n-1;this._isOdd=a%2>0}else{var r=+t.catInfo.value,s=+i.catInfo.value;this._middleCat=(s+r)/2}}}},_interpolate:function(t){this._initInterpData();var i=this.__nextNonNull,n=this.__lastNonNull,a=i||n;if(a){var r,s=this.interpolation,o=t.catInfo;if(i&&n)if(s._isCatDiscrete){var l=o.index-n.catInfo.index;r=this._isOdd?lo;){var u=t[o];if(u.isVirtual){var c=u.id,h=u.key;t.splice(o,1);delete s[c];delete r[h];a&&u.isSelected&&a.rem(c);u.isVisible&&n.rem(c);l--;i=!0}else o++}if(i){if(!t.length&&this.parent){this.dispose();return}var d=this.childNodes;if(d){o=0;l=d.length;for(;l>o;){var f=d[o];f.clearVirtuals();f.parent?o++:l--}}this._linkChildren&&this._linkChildren.forEach(function(e){e.clearVirtuals()})}}e.eachOwn(this._dimensions,function(e){B.call(e)})},add:function(e){Y.call(this);et.call(this,e,{isAdditive:!0,doAtomGC:!0})},groupBy:function(e,t){var i,n,a=new Tt.data.GroupingOper(this,e,t),r=a.key;if(r){i=this._groupByCache;n=i&&i[r]}if(n)Tt.debug>=7&&Tt.log("[GroupBy] Cache key hit '"+r+"'");else{Tt.debug>=7&&Tt.log("[GroupBy] "+(r?"Cache key not found: '"+r+"'":"No Cache key"));n=a.execute();r&&((i||(this._groupByCache={}))[r]=n)}return n},where:function(t,i){var n; if(t){t=at.call(this,t,i);n=lt.call(this,t,i)}else{if(!i)return e.query(this._datums);n=rt(e.query(this._datums),i)}var a=st(t,i);return new Tt.data.Data({linkParent:this,datums:n,where:a})},datums:function(t,i){if(!t)return i?rt(e.query(this._datums),i):e.query(this._datums);t=at.call(this,t,i);return lt.call(this,t,i)},datum:function(t,i){t||e.fail.argumentRequired("whereSpec");t=at.call(this,t,i);return lt.call(this,t,i).first()||null},dimensionsSumAbs:function(t,i){var n=t+":"+L(i),a=e.getOwn(this._sumAbsCache,n);if(null==a){a=this.children().where(function(e){return!e._isFlattenGroup||e._isDegenerateFlattenGroup}).select(function(e){return e.dimensions(t).valueAbs(i)||0},this).reduce(e.add,0);(this._sumAbsCache||(this._sumAbsCache={}))[n]=a}return a}});Tt.data.Data.add({getInfo:function(){var t=["DATA SUMMARY",Tt.logSeparator," Dimension",Tt.logSeparator];e.eachOwn(this.dimensions(),function(e,i){var n=e.count(),a=e.type,r=[];r.push('"'+a.label+'"');r.push(a.valueTypeName);a.isComparable&&r.push("comparable"); a.isDiscrete||r.push("continuous");a.isHidden&&r.push("hidden");t.push(" "+i+" ("+r.join(", ")+") ("+n+")\n "+e.atoms().slice(0,10).map(function(e){return e.label}).join(", ")+(n>10?"...":""))});return t.join("\n")},getValues:function(){return t.range(0,this.getCategoriesSize()).map(function(e){return this._getValuesForCategoryIndex(e)},this)},_getDimensionValues:function(e){return this.dimensions(e).atoms().map(function(e){return e.value})},_getDimensionVisibleValues:function(e){return this.dimensions(e).atoms({visible:!0}).map(function(e){return e.value})},getSeries:function(){return this._getDimensionValues("series")},getVisibleSeriesIndexes:function(){return this.dimensions("series").indexes({visible:!0})},getVisibleCategoriesIndexes:function(){return this.dimensions("category").indexes({visible:!0})},getVisibleSeries:function(){return this._getDimensionVisibleValues("series")},getCategories:function(){return this._getDimensionValues("category")},getVisibleCategories:function(){return this._getDimensionVisibleValues("category") },_getValuesForCategoryIndex:function(t){var i=this.dimensions("category").atoms()[t],n=this.datums({category:i}).uniqueIndex(function(e){return e.atoms.series.key});return this.dimensions("series").atoms().map(function(t){var i=e.getOwn(n,t.key);return i?i.atoms.value.value:null})},getSeriesSize:function(){var e=this.dimensions("series",{assertExists:!1});return e?e.count():0},getCategoriesSize:function(){var e=this.dimensions("category",{assertExists:!1});return e?e.count():0}});e.scope(function(){var t=e.makeEnum(["Interactive","ShowsActivity","ShowsSelection","ShowsTooltip","Selectable","Unselectable","Hoverable","Clickable","DoubleClickable","SelectableByClick","SelectableByRubberband","SelectableByFocusWindow","Animatable"]);t.ShowsInteraction=t.ShowsActivity|t.ShowsSelection;t.Actionable=t.Hoverable|t.Clickable|t.DoubleClickable|t.SelectableByClick;t.HandlesEvents=t.Actionable|t.ShowsTooltip;t.HandlesClickEvent=t.Clickable|t.SelectableByClick;e.type("pvc.visual.Interactive").addStatic(t).addStatic({ShowsAny:t.ShowsInteraction|t.ShowsTooltip,SelectableAny:t.Selectable|t.SelectableByClick|t.SelectableByRubberband|t.SelectableByFocusWindow}).add({_ibits:-1}).add(e.query(e.ownKeys(t)).object({name:e.firstLowerCase,value:function(e){var i=t[e]; return function(){return!!(this._ibits&i)}}}))});e.type("pvc.visual.Scene").init(function(i,n){Tt.debug>=4&&(this.id=e.nextId("scene"));this._renderId=0;this.renderState={};t.Dom.Node.call(this,null);this.parent=i||null;if(i){this.root=i.root;var a=e.get(n,"index",null);i.insertAt(this,a)}else{this.root=this;this._active=null;this._panel=e.get(n,"panel")||e.fail.argumentRequired("panel","Argument is required on root scene.")}var r,s,o,l,u,c,h,d=e.array.to(e.get(n,"source"));if(d&&d.length){this.source=d;r=d[0];if(r instanceof Tt.data.Data){s=r;u=d;o=s.firstDatum()||e.query(u).select(function(e){return e.firstDatum()}).first(e.notNully)}else{r instanceof Tt.data.Datum||e.assert("not a datum");o=r;l=d}c=r.atoms;h=o&&o.atoms||r.atoms}else c=h=i?Object.create(i.atoms):{};this.atoms=c;this.firstAtoms=h;u&&(this.groups=u);s&&(this.group=s);l&&(this._datums=l);o&&(this.datum=o);(!r||r.isNull)&&(this.isNull=!0);this.vars=i?Object.create(i.vars):{}}).add(t.Dom.Node).add(Tt.visual.Interactive).add({source:null,groups:null,group:null,_datums:null,datum:null,isNull:!1,get:function(e,t){var i=this.vars[e]; return i&&i[t||"value"]},getSeries:function(){return this.get("series")},getCategory:function(){return this.get("category")},getValue:function(){return this.get("value")},getTick:function(){return this.get("tick")},getX:function(){return this.get("x")},getY:function(){return this.get("y")},getSeriesLabel:function(){return this.get("series","label")},getCategoryLabel:function(){return this.get("category","label")},getValueLabel:function(){return this.get("value","label")},getTickLabel:function(){return this.get("tick","label")},getXLabel:function(){return this.get("x","label")},getYLabel:function(){return this.get("y","label")},data:function(){var e=this.group;if(!e){for(var t=this;!e&&(t=t.parent);)e=t.group;e||(e=this.panel.data)}return e},datums:function(){return this.groups?e.query(this.groups).selectMany(function(e){return e.datums()}):this._datums?e.query(this._datums):e.query()},format:function(t){return e.format(t,this._formatScope,this)},_formatScope:function(t){if("#"===t.charAt(0)){t=t.substr(1).split("."); if(t.length>2)throw e.error.operationInvalid("Scene format mask is invalid.");var i=this.firstAtoms[t[0]];if(i){if(t.length>1)switch(t[1]){case"value":return i.value;case"label":break;default:throw e.error.operationInvalid("Scene format mask is invalid.")}return i}return null}return e.getPath(this.vars,t)},isRoot:function(){return this.root===this},panel:function(){return this.root._panel},chart:function(){return this.root._panel.chart},compatVersion:function(){return this.root._panel.compatVersion()},children:function(){var t=this.childNodes;return t.length?e.query(t):e.query()},leafs:function(){function t(e){for(;e.childNodes.length;)e=e.childNodes[0];return e}var i=this;return e.query(function(e){if(!e){var n=t(i);if(n===i)return 0;this.item=n;return 1}var a=this.item.nextSibling;if(a){this.item=a;return 1}for(var r=this.item;r!==i&&(r=r.parentNode);)if(a=r.nextSibling){this.item=t(a);return 1}return 0})},anyInteraction:function(){return!!this.root._active||this.anySelected()},isActive:!1,setActive:function(e){e=!!e; this.isActive!==e&&ht.call(this.root,this.isActive?null:this)},clearActive:function(){return ht.call(this.root,null)},anyActive:function(){return!!this.root._active},active:function(){return this.root._active},activeSeries:function(){var e,t=this.active();return t&&(e=t.vars.series)&&e.value},isActiveSeries:function(){if(this.isActive)return!0;var e=this.renderState.isActiveSeries;if(null==e){var t;e=null!=(t=this.activeSeries())&&t===this.vars.series.value;this.renderState.isActiveSeries=e}return e},isActiveDatum:function(){return this.isActive?!0:!1},isActiveDescendantOrSelf:function(){return this.isActive?!0:e.lazy(this.renderState,"isActiveDescOrSelf",this._calcIsActiveDescOrSelf,this)},_calcIsActiveDescOrSelf:function(){var e=this.active();if(e)for(;e=e.parent;)if(e===this)return!0;return!1},isVisible:function(){return this._visibleInfo().is},anyVisible:function(){return this._visibleInfo().any},_visibleInfo:function(){return e.lazy(this.renderState,"visibleInfo",this._createVisibleInfo,this) },_createVisibleInfo:function(){var t=this.chart().data.owner.visibleCount()>0,i=t&&this.datums().any(e.propGet("isVisible"));return{any:t,is:i}},isSelected:function(){return this._selectedInfo().is},anySelected:function(){return this._selectedInfo().any},_selectedInfo:function(){return e.lazy(this.renderState,"selectedInfo",this._createSelectedInfo,this)},_createSelectedInfo:function(){var e=this.chart().data.owner.selectedCount()>0,t=e&&this.datums().any(Gt);return{any:e,is:t}},select:function(t){var i=this,n=i.datums().array();if(n.length){var a=i.chart();a._updatingSelections(function(){n=a._onUserSelection(n);n&&n.length&&(a.options.ctrlSelectMode&&e.get(t,"replace",!0)?a.data.replaceSelected(n):Tt.data.Data.toggleSelected(n))})}},isSelectedDescendantOrSelf:function(){return this.isSelected()?!0:e.lazy(this.renderState,"isSelectedDescOrSelf",this._calcIsSelectedDescOrSelf,this)},_calcIsSelectedDescOrSelf:function(){var e=this.firstChild;if(e)do if(e.isSelectedDescendantOrSelf())return!0; while(e=e.nextSibling);return!1},toggleVisible:function(){Tt.data.Data.toggleVisible(this.datums())&&this.chart().render(!0,!0,!1)}});Tt.visual.Scene.prototype.variable=function(t,i){var n,a=this;if(a._vars&&a._vars[t])void 0!==i&&(n=e.set({},"_"+t+"EvalCore",e.fun.to(i)));else{a.hasOwnProperty("_vars")||(a._vars=e.create(a._vars));a._vars[t]=!0;n={};var r="_"+t+"Eval";n[t]=ft(t,r);var s=r+"Core";e.hasOwn(a,r)||(n[r]=e.methodCaller(s));e.hasOwn(a,s)||(n[s]=e.fun.to(void 0===i?null:i))}n&&a.constructor.add(n);return a};var jt=Tt.visual.ValueLabelVar=function(e,t,i,n){this.value=e;this.label=t;void 0!==i&&(this.rawValue=i);void 0!==n&&(this.absLabel=n)};e.set(jt.prototype,"rawValue",void 0,"absLabel",void 0,"setValue",function(e){this.value=e;return this},"setLabel",function(e){this.label=e;return this},"clone",function(){return new jt(this.value,this.label,this.rawValue)},"toString",function(){var e=this.label||this.value;return null==e?"":"string"!=typeof e?""+e:e});jt.fromComplex=function(e){return e?new jt(e.value,e.label,e.rawValue,e.absLabel):new jt(null,"",null) };jt.fromAtom=jt.fromComplex;e.type("pvc.visual.Context").init(function(e,t,i){this.chart=e.chart;this.panel=e;vt.call(this,t,i)}).add({isPinned:!1,pin:function(){this.isPinned=!0;return this},compatVersion:function(){return this.panel.compatVersion()},finished:function(e){return this.sign.finished(e)},delegate:function(e){return this.sign.delegate(e)},getV1Series:function(){var t;return e.nullyTo(this.scene.firstAtoms&&(t=this.scene.firstAtoms[this.panel._getV1DimName("series")])&&t.rawValue,"Series")},getV1Category:function(){var e;return this.scene.firstAtoms&&(e=this.scene.firstAtoms[this.panel._getV1DimName("category")])&&e.rawValue},getV1Value:function(){var e;return this.scene.firstAtoms&&(e=this.scene.firstAtoms[this.panel._getV1DimName("value")])&&e.value},getV1Datum:function(){return this.panel._getV1Datum(this.scene)},get:function(e,t){return this.scene.get(e,t)},getSeries:function(){return this.scene.get("series")},getCategory:function(){return this.scene.get("category")},getValue:function(){return this.scene.get("value") },getTick:function(){return this.scene.get("tick")},getX:function(){return this.scene.get("x")},getY:function(){return this.scene.get("y")},getSeriesLabel:function(){return this.scene.get("series","label")},getCategoryLabel:function(){return this.scene.get("category","label")},getValueLabel:function(){return this.scene.get("value","label")},getTickLabel:function(){return this.scene.get("tick","label")},getXLabel:function(){return this.scene.get("x","label")},getYLabel:function(){return this.scene.get("y","label")},select:function(e){return this.scene.select(e)},toggleVisible:function(){return this.scene.toggleVisible()},click:function(){var e=this;e.clickable()&&e.panel._onClick(e);if(e.selectableByClick()){var t=e.event;e.select({replace:!t||!t.ctrlKey})}},doubleClick:function(){this.doubleClickable()&&this.panel._onDoubleClick(this)},clickable:function(){var e=this;return(e.sign?e.sign.clickable():e.panel.clickable())&&(!e.scene||e.scene.clickable())},selectableByClick:function(){var e=this; return(e.sign?e.sign.selectableByClick():e.panel.selectableByClick())&&(!e.scene||e.scene.selectableByClick())},doubleClickable:function(){var e=this;return(e.sign?e.sign.doubleClickable():e.panel.doubleClickable())&&(!e.scene||e.scene.doubleClickable())},hoverable:function(){var e=this;return(e.sign?e.sign.hoverable():e.panel.hoverable())&&(!e.scene||e.scene.hoverable())}});if(Object.defineProperty)try{Object.defineProperty(Tt.visual.Context.prototype,"parent",{get:function(){throw e.error.operationInvalid("The 'this.parent.index' idiom has no equivalent in this version. Please try 'this.pvMark.parent.index'.")}})}catch(Ut){}e.space("pvc.visual").TraversalMode=e.makeEnum(["Tree","FlattenedSingleLevel","FlattenDfsPre","FlattenDfsPost"]);e.type("pvc.visual.Role").init(function(t,i){this.name=t;this.label=e.get(i,"label")||Tt.buildTitleFromName(t);this.index=e.get(i,"index")||0;this.dimensionDefaults=e.get(i,"dimensionDefaults")||{};e.get(i,"isRequired",!1)&&(this.isRequired=!0);e.get(i,"autoCreateDimension",!1)&&(this.autoCreateDimension=!0); var n=e.get(i,"defaultSourceRole");n&&(this.defaultSourceRoleName=n);var a=e.get(i,"defaultDimension");a&&(this.defaultDimensionName=a);if(!a&&this.autoCreateDimension)throw e.error.argumentRequired("defaultDimension");var r,s=e.get(i,"requireIsDiscrete");null!=s&&(s||(r=!0));if(null!=r){r=e.get(i,"requireSingleDimension",!1);if(r){if(e.get(i,"isMeasure",!1)){this.isMeasure=!0;e.get(i,"isPercent",!1)&&(this.isPercent=!0)}var o=e.get(i,"valueType",null);if(o!==this.valueType){this.valueType=o;this.dimensionDefaults.valueType=o}}}r!==this.requireSingleDimension&&(this.requireSingleDimension=r);if(s!=this.requireIsDiscrete){this.requireIsDiscrete=!!s;this.dimensionDefaults.isDiscrete=this.requireIsDiscrete}var l=e.get(i,"traversalMode");null!=l&&l!==this.traversalMode&&(this.traversalMode=l)}).add({isRequired:!1,requireSingleDimension:!1,valueType:null,requireIsDiscrete:null,isMeasure:!1,isPercent:!1,defaultSourceRoleName:null,defaultDimensionName:null,grouping:null,traversalMode:Tt.visual.TraversalMode.FlattenedSingleLevel,rootLabel:"",autoCreateDimension:!1,isReversed:!1,label:null,sourceRole:null,isDefaultSourceRole:!1,firstDimensionType:function(){var e=this.grouping; return e&&e.firstDimensionType()},firstDimensionName:function(){var e=this.grouping;return e&&e.firstDimensionName()},firstDimensionValueType:function(){var e=this.grouping;return e&&e.firstDimensionValueType()},isDiscrete:function(){var e=this.grouping;return e&&e.isDiscrete()},setSourceRole:function(e,t){this.sourceRole=e;this.isDefaultSourceRole=!!t},setIsReversed:function(e){e?this.isReversed=!0:delete this.isReversed},setTraversalMode:function(t){var i=Tt.visual.TraversalMode;t=e.nullyTo(t,i.FlattenedSingleLevel);t!==this.traversalMode&&(t===i.FlattenedSingleLevel?delete this.traversalMode:this.traversalMode=t)},setRootLabel:function(e){if(e!==this.rootLabel){e?this.rootLabel=e:delete this.rootLabel;this.grouping&&this._updateBind(this.grouping)}},flatten:function(t,i){var n=this.flattenedGrouping(i)||e.fail.operationInvalid("Role is unbound.");return t.groupBy(n,i)},flattenedGrouping:function(e){var t=this.grouping;if(t){e=e?Object.create(e):{};var i=e.flatteningMode;null==i&&(i=e.flatteningMode=this._flatteningMode()); null!=e.isSingleLevel||i||(e.isSingleLevel=!0);return t.ensure(e)}},_flatteningMode:function(){var e=Tt.visual.TraversalMode,t=Tt.data.FlatteningMode;switch(this.traversalMode){case e.FlattenDfsPre:return t.DfsPre;case e.FlattenDfsPost:return t.DfsPost}return e.None},select:function(t,i){var n=this.grouping;if(n){e.setUDefaults(i,"flatteningMode",Tt.data.FlatteningMode.None);return t.groupBy(n.ensure(i),i)}},view:function(e){var t=this.grouping;return t?t.view(e):void 0},preBind:function(e){this.__grouping=e;return this},isPreBound:function(){return!!this.__grouping},preBoundGrouping:function(){return this.__grouping},isBound:function(){return!!this.grouping},postBind:function(e){var t=this.__grouping;if(t){delete this.__grouping;t.bind(e);this.bind(t)}return this},bind:function(e){e=this._validateBind(e);this._updateBind(e);return this},_validateBind:function(t){if(t)if(t.isNull())t=null;else{if(this.requireSingleDimension&&!t.isSingleDimension)throw e.error.operationInvalid("Role '{0}' only accepts a single dimension.",[this.name]); var i=this.valueType,n=this.requireIsDiscrete;t.dimensions().each(function(t){var a=t.type;if(i&&a.valueType!==i)throw e.error.operationInvalid("Role '{0}' cannot be bound to dimension '{1}'. \nIt only accepts dimensions of type '{2}' and not of type '{3}'.",[this.name,a.name,Tt.data.DimensionType.valueTypeName(i),a.valueTypeName]);if(null!=n&&a.isDiscrete!==n){if(!n)throw e.error.operationInvalid("Role '{0}' cannot be bound to dimension '{1}'. \nIt only accepts {2} dimensions.",[this.name,a.name,n?"discrete":"continuous"]);a._toDiscrete()}},this)}return t},_updateBind:function(e){this.grouping&&this.grouping.dimensions().each(function(e){e.type&&b.call(e.type,this)},this);this.grouping=e;if(this.grouping){this.grouping=this.grouping.ensure({reverse:this.isReversed,rootLabel:this.rootLabel});this.grouping.dimensions().each(function(e){g.call(e.type,this)},this)}}});e.type("pvc.visual.RoleVarHelper").init(function(t,i,n){var a=e.get(n,"hasPercentSubVar",!1),r=e.get(n,"roleVar"),s=this.grouping=i&&i.grouping; if(s){this.role=i;this.sourceRoleName=i.sourceRole&&i.sourceRole.name;var o=t.panel();this.panel=o;if(!s.isDiscrete()){this.rootContDim=o.data.owner.dimensions(s.firstDimensionName());a&&(this.percentFormatter=o.chart.options.percentValueFormat)}}if(!r){if(!i)throw e.error.operationInvalid("Role is not defined, so the roleVar argument is required.");r=i.name}if(!s){var l=t.vars[r]=new jt(null,"");a&&(l.percent=new jt(null,""))}this.roleVarName=r;t["is"+e.firstUpperCase(r)+"Bound"]=!!s;e.get(n,"allowNestedVars")&&(this.allowNestedVars=!0)}).add({allowNestedVars:!1,isBound:function(){return!!this.grouping},onNewScene:function(t,i){if(this.grouping){var n=this.roleVarName;if(this.allowNestedVars?!e.hasOwnProp.call(t.vars,n):!t.vars[n]){var a=this.sourceRoleName;if(a){var r=e.getOwn(t.vars,a);if(r){t.vars[n]=r.clone();return}}if(i){var s,o=this.rootContDim;if(o){var l,u,c=t.group,h=c?c.singleDatum():t.datum;if(h){if(!h.isNull){s=jt.fromAtom(h.atoms[o.name]);if(null!=s.value&&this.percentFormatter)if(c){u=c.dimensions(o.name); l=u.valuePercent({visible:!0})}else l=t.data().dimensions(o.name).percent(s.value)}}else if(c){u=c.dimensions(o.name);var d=u.value({visible:!0,zeroIfNone:!1});if(null!=d){var f=o.format(d);s=new jt(d,f,d);this.percentFormatter&&(l=u.valuePercent({visible:!0}))}}s&&this.percentFormatter&&(s.percent=null==s.value?new jt(null,""):new jt(l,this.percentFormatter.call(null,l)))}else{var v=t.datum;if(v&&!v.isNull){var p=this.grouping.view(v);s=jt.fromComplex(p)}}if(!s){s=new jt(null,"");this.percentFormatter&&(s.percent=new jt(null,""))}t.vars[n]=s}}}}});At.prototype.getSign=function(){return this.sign||pt(this)};At.prototype.getScene=function(){return this.getSign().scene()};At.prototype.getContext=function(){return this.getSign().context()};At.prototype.preBuildInstance=function(e){var t=e.data;t instanceof Tt.visual.Scene&&ct.call(t,this.renderId())};e.type("pvc.visual.BasicSign").init(function(t,i){this.chart=t.chart;this.panel=t;!i.sign||e.assert("Mark already has an attached Sign.");this.pvMark=i; i.sign=this}).add({compatVersion:function(){return this.chart.compatVersion()},localProperty:function(e,t){this.pvMark.localProperty(e,t);return this},lock:function(e,t){return this.lockMark(e,this._bindWhenFun(t,e))},optional:function(e,t,i){return this.optionalMark(e,this._bindWhenFun(t,e),i)},lockMark:function(e,t){return this.pvMark.lock(e,t),this},optionalMark:function(e,t,i){return this.pvMark[e](t,i),this},delegate:function(e,t){return this.pvMark.delegate(e,t)},delegateExtension:function(e){return this.pvMark.delegate(e,Tt.extensionTag)},delegateNotExtension:function(e){return this.pvMark.delegateExcept(e,Tt.extensionTag)},hasDelegate:function(e){return this.pvMark.hasDelegate(e)},_createPropInterceptor:function(e,t){var i=this;return function(){var n=this.sign;return n&&n===i?t.apply(i,arguments):i._getPvSceneProp(e,this.index)}},_getPvSceneProp:function(t,i){var n=this.pvMark,a=n.scene;if(a){var r=n.hasOwnProperty("index")?n.index:Math.min(i,a.length-1);if(null!=r)return a[r][t] }throw e.error.operationInvalid("Cannot evaluate inherited property.")},_bindWhenFun:function(t,i){if(e.fun.is(t)){var n=this;return n._createPropInterceptor(i,function(e){return t.call(n,e)})}return t},_lockDynamic:function(e,t){var i=this;return i.lockMark(e,i._createPropInterceptor(e,function(e){return i[t].call(i,e)}))},scene:function(){var e=this.pvMark.instance(),t=e&&e.data;return t instanceof Tt.visual.Scene?t:null},instanceState:function(e){return this.pvMark.instanceState(e)},context:function(e,t){var i;return t||!(i=this.instanceState())?this._createContext(e):i.cccContext||(i.cccContext=this._createContext(e))},_createContext:function(e){return new Tt.visual.Context(this.panel,this.pvMark,e)}});e.type("pvc.visual.Sign",Tt.visual.BasicSign).init(function(t,i,n){var a=this;a.base(t,i,n);a._ibits=t._ibits;var r=e.get(n,"extensionId");null!=r&&(a.extensionAbsIds=e.array.to(t._makeExtensionAbsId(r)));a.isActiveSeriesAware=e.get(n,"activeSeriesAware",!0);if(a.isActiveSeriesAware){var s=t.visualRoles,o=s&&s.series; o&&o.isBound()||(a.isActiveSeriesAware=!1)}i.wrapper(e.get(n,"wrapper")||a.createDefaultWrapper());e.get(n,"freeColor",!0)||a._bindProperty("fillStyle","fillColor","color")._bindProperty("strokeStyle","strokeColor","color")}).postInit(function(e,t,i){this._addInteractive(i);e._addSign(this)}).add({createDefaultWrapper:function(){var e=this;return function(t){return function(i){return t.call(e.context(),i)}}},property:function(t){var i=e.firstUpperCase(t),n="base"+i,a="default"+i,r="normal"+i,s="interactive"+i,o={};o[t]=function(e,t){this._finished=!1;this._arg=t;var i=this[n](e,t);if(null==i)return null;if(this._finished)return i;i=this.showsInteraction()&&e.anyInteraction()?this[s](e,i,t):this[r](e,i,t);this._arg=null;return i};o[n]=function(){return this.delegateExtension()};o[a]=function(){};o[r]=function(e,t){return t};o[s]=function(e,t){return t};this.constructor.add(o);return this},anyInteraction:function(e){return e.anyInteraction()},finished:function(e){this._finished=!0;return e },applyExtensions:function(){if(!this._extended){this._extended=!0;var e=this.extensionAbsIds;e&&e.forEach(function(e){this.panel.extendAbs(this.pvMark,e)},this)}return this},intercept:function(e,t){var i=this._createPropInterceptor(e,t);return this._intercept(e,i)},lockDimensions:function(){this.pvMark.lock("left").lock("right").lock("top").lock("bottom").lock("width").lock("height");return this},_extensionKeyArgs:{tag:Tt.extensionTag},_bindProperty:function(t,i,n){var a=this;n||(n=i);var r="default"+e.firstUpperCase(n);if(e.fun.is(a[r])&&!a.pvMark.hasDelegateValue(t,Tt.extensionTag)){var s=function(e){return a[r](e,a._arg)};a.pvMark.intercept(t,s,a._extensionKeyArgs)}var o=this._createPropInterceptor(t,function(e){return a[i](e)});return a._intercept(t,o)},_intercept:function(t,i){var n=this.pvMark,a=this.extensionAbsIds;a&&e.query(a).select(function(e){return this.panel._getExtensionAbs(e,t)},this).where(e.notUndef).each(function(e){e=n.wrap(e,t);n.intercept(t,e,this._extensionKeyArgs) },this);(n._intercepted||(n._intercepted={}))[t]=!0;n.intercept(t,i);return this}}).prototype.property("color").constructor.add(Tt.visual.Interactive).add({extensionAbsIds:null,_addInteractive:function(t){var i=this,n=e.get;if(i.interactive()){var a=i._ibits,r=Tt.visual.Interactive;n(t,"noTooltip")&&(a&=~r.ShowsTooltip);n(t,"noHover")&&(a&=~r.Hoverable);n(t,"noClick")&&(a&=~r.Clickable);n(t,"noDoubleClick")&&(a&=~r.DoubleClickable);if(n(t,"noSelect"))a&=~r.SelectableAny;else if(this.selectable()){n(t,"noClickSelect")&&(a&=~r.SelectableByClick);n(t,"noRubberSelect")&&(a&=~r.SelectableByRubberband)}if(i.showsInteraction()){n(t,"showsInteraction")===!1&&(a&=~r.ShowsInteraction);i.showsActivity()&&n(t,"showsActivity")===!1&&(a&=~r.ShowsActivity);i.showsSelection()&&n(t,"showsSelection")===!1&&(a&=~r.ShowsSelection)}i._ibits=a}if(i.handlesEvents()){i.showsTooltip()&&i._addPropTooltip(n(t,"tooltipArgs"));i.hoverable()&&i._addPropHoverable();i.handlesClickEvent()&&i._addPropClick();i.doubleClickable()&&i._addPropDoubleClick() }else i.pvMark.events("none")},fillColor:function(e){return this.color(e,"fill")},strokeColor:function(e){return this.color(e,"stroke")},defaultColor:function(e){return this.defaultColorSceneScale()(e)},dimColor:function(e,t){return"text"===t?Tt.toGrayScale(e,-.75,null,null):Tt.toGrayScale(e,-.3,null,null)},defaultColorSceneScale:function(){return e.lazy(this,"_defaultColorSceneScale",this._initDefColorScale,this)},_initDefColorScale:function(){var t=this.panel.axes.color;return t?t.sceneScale({sceneVarName:"color"}):e.fun.constant(Tt.defaultColor)},mayShowActive:function(e,t){return this.showsActivity()?e.isActive||!t&&this.isActiveSeriesAware&&e.isActiveSeries()||e.isActiveDatum():!1},mayShowNotAmongSelected:function(e){return this.mayShowAnySelected(e)&&!e.isSelected()},mayShowSelected:function(e){return this.showsSelection()&&e.isSelected()},mayShowAnySelected:function(e){return this.showsSelection()&&e.anySelected()},_addPropTooltip:function(i){if(!this.pvMark.hasTooltip){var n=e.create(this.chart._tooltipOptions,e.get(i,"options")); n.isLazy=e.get(i,"isLazy",!0);var a=e.get(i,"buildTooltip")||this._getTooltipFormatter(n);if(a){n.isEnabled=this._isTooltipEnabled.bind(this);var r=e.get(i,"tipsyEvent");r||(r="mouseover");this.pvMark.localProperty("tooltip").tooltip(this._createTooltipProp(a,n.isLazy)).title(e.fun.constant("")).ensureEvents().event(r,t.Behavior.tipsy(n)).hasTooltip=!0}}},_getTooltipFormatter:function(e){return this.panel._getTooltipFormatter(e)},_isTooltipEnabled:function(){return this.panel._isTooltipEnabled()},_createTooltipProp:function(e,t){var i,n=this;i=t?function(t){var i,a=n.context(t,!0);return function(){if(a){i=e(a);a=null}return i}}:function(t){var i=n.context(t);return e(i)};return function(e){return e&&!e.isIntermediate&&e.showsTooltip()?i(e):void 0}},_addPropHoverable:function(){var e,t,i=this.panel;e="mouseover";t="mouseout";this.pvMark.ensureEvents().event(e,function(e){if(e.hoverable()&&!i.selectingByRubberband()&&!i.animating()){e.setActive(!0);i.renderInteractive()}}).event(t,function(e){!e.hoverable()||i.selectingByRubberband()||i.animating()||e.clearActive()&&i.renderInteractive() })},_ignoreClicks:0,_propCursorClick:function(e){var t=this._ibits&e._ibits,i=Tt.visual.Interactive;return t&i.HandlesClickEvent||t&i.DoubleClickable?"pointer":null},_addPropClick:function(){var e=this;e.pvMark.cursor(e._propCursorClick.bind(e)).ensureEvents().event("click",e._handleClick.bind(e))},_addPropDoubleClick:function(){var e=this;e.pvMark.cursor(e._propCursorClick.bind(e)).ensureEvents().event("dblclick",e._handleDoubleClick.bind(e))},_handleClick:function(){var e=this,i=e.pvMark,n=i.instance(),a=n.data,r=e.doubleClickable()&&a.doubleClickable();if(r){var s=i.scene,o=i.index,l=t.event;window.setTimeout(function(){if(e._ignoreClicks)e._ignoreClicks--;else try{t.event=l;i.context(s,o,function(){e._handleClickCore()})}catch(n){t.error(n)}finally{delete t.event}},e.chart.options.doubleClickMaxDelay||300)}else e._ignoreClicks?e._ignoreClicks--:e._handleClickCore()},_handleClickCore:function(){this._onClick(this.context())},_handleDoubleClick:function(){var e=this,t=e.scene();if(t&&t.doubleClickable()){e._ignoreClicks=2; e._onDoubleClick(e.context(t))}},_onClick:function(e){e.click()},_onDoubleClick:function(e){e.doubleClick()}});e.type("pvc.visual.Panel",Tt.visual.Sign).init(function(i,n,a){var r=e.get(a,"panel");if(!r){var s=e.get(a,"panelType")||t.Panel;r=n.add(s)}this.base(i,r,a)}).add({_addInteractive:function(t){var i=!0;t=e.setDefaults(t,"noSelect",i,"noHover",i,"noTooltip",i,"noClick",i,"noDoubleClick",i);this.base(t)}});e.type("pvc.visual.Label",Tt.visual.Sign).init(function(e,i,n){var a=i.add(t.Label);this.base(e,a,n)}).add({_addInteractive:function(t){var i=!0;t=e.setDefaults(t,"noSelect",i,"noHover",i,"noTooltip",i,"noClick",i,"noDoubleClick",i,"showsInteraction",!1);this.base(t)},defaultColor:e.fun.constant(t.Color.names.black)});var Kt=t.Color.names.white;e.type("pvc.visual.ValueLabel",Tt.visual.Label).init(function(t,i,n){this.valuesFont=e.get(n,"valuesFont")||t.valuesFont;this.valuesMask=e.get(n,"valuesMask")||t.valuesMask;this.valuesOptimizeLegibility=e.get(n,"valuesOptimizeLegibility",t.valuesOptimizeLegibility); this.valuesOverflow=e.get(n,"valuesOverflow",t.valuesOverflow);this.hideOverflowed="hide"===this.valuesOverflow;this.trimOverflowed=!this.hideOverflowed&&"trim"===this.valuesOverflow;this.hideOrTrimOverflowed=this.hideOverflowed||this.trimOverflowed;var a;a=e.get(n,"noAnchor",!1)?i:i.anchor(t.valuesAnchor);n&&null==n.extensionId&&(n.extensionId="label");this.base(t,a,n);this.pvMark.font(this.valuesFont);this._bindProperty("text","text")._bindProperty("textStyle","textColor","color").intercept("visible",this.visible)}).prototype.property("text").property("textStyle").constructor.addStatic({maybeCreate:function(e,t,i){return e.valuesVisible&&e.valuesMask?new Tt.visual.ValueLabel(e,t,i):null},isNeeded:function(e){return e.valuesVisible&&e.valuesMask}}).add({_addInteractive:function(t){t=e.setDefaults(t,"showsInteraction",!0,"noSelect",!0,"noTooltip",!0,"noClick",!0,"noDoubleClick",!0,"noHover",!0);this.base(t)},visible:function(e){var t=this.getAnchoredToMark();if(t&&!t.visible())return!1; if(!this.hideOrTrimOverflowed)return this.delegate(!0);var i;if(this.hasDelegate(Tt.extensionTag)){i=this.delegateExtension();if(null!=i)return i}i=this.delegateNotExtension();if(i===!1)return!1;if(e.isActive&&this.showsActivity())return!0;var n=this.textFitInfo(e);return!(n&&n.hide)},textFitInfo:function(e){var t=e.renderState,i=t.textFitInfo;return void 0!==i?i:t.textFitInfo=this.calcTextFitInfo(e,this._evalBaseText())||null},calcTextFitInfo:function(){return null},_evalBaseText:function(){var e=this.pvMark,t=e.binds.properties.text.proto;return e.evalInPropertyContext(this.baseText.bind(this),t)},baseText:function(e){var t=e.renderState,i=t.baseText;return void 0!==i?i:this.base(e)},defaultText:function(e){return e.format(this.valuesMask)},normalText:function(e,t){var i;return this.trimOverflowed&&(i=this.textFitInfo(e))?this.trimText(e,t,i):t},interactiveText:function(e,t){var i;return!this.trimOverflowed||e.isActive&&this.showsActivity()||!(i=this.textFitInfo(e))?t:this.trimText(e,t,i) },trimText:function(e,t,i){var n=i&&i.widthMax;return null!=n?Tt.text.trimToWidthB(n,t,this.pvMark.font(),".."):t},textColor:function(e){return this.color(e,"text")},backgroundColor:function(t,i){var n=this.instanceState();if(!n)return this.calcBackgroundColor(t,i);var a=e.lazy(n,"cccBgColorCache"),r=e.getOwn(a,i);r||(r=a[i]=this.calcBackgroundColor(t,i));return r},calcBackgroundColor:function(e){var t=this.getAnchoredToMark();if(t){var i=t.fillStyle();if(i&&i!==Kt&&this.isAnchoredInside(e,t))return i}return Kt},getAnchoredToMark:function(){return this.pvMark.target||this.pvMark.parent},isAnchoredInside:function(e,i){if(!i&&!(i=this.getAnchoredToMark()))return!1;var n,a=this.pvMark,r=a.text(),s=t.Text.measure(r,a.font()),o=a.left(),l=a.top();if(null==o){n=a.parent;o=n.width()-(a.right()||0)}if(null==l){n||(n=a.parent);l=n.height()-(a.bottom()||0)}var u=t.Label.getPolygon(s.width,s.height,a.textAlign(),a.textBaseline(),a.textAngle(),a.textMargin()).center().plus(o,l),c=i.getShape(i.scene,a.index); return c.containsPoint(u)},maybeOptimizeColorLegibility:function(e,t,i){if(this.valuesOptimizeLegibility){var n=this.backgroundColor(e,i);return n&&n!==Kt&&n.isDark()===t.isDark()?t.complementary().alpha(.9):t}return t},normalColor:function(e,t,i){return this.maybeOptimizeColorLegibility(e,t,i)},interactiveColor:function(e,t,i){return!this.mayShowActive(e)&&this.mayShowNotAmongSelected(e)?this.dimColor(t,i):this.maybeOptimizeColorLegibility(e,t,i)}});e.type("pvc.visual.Dot",Tt.visual.Sign).init(function(i,n,a){var r=n.add(t.Dot),s=e.get(a,"proto");s&&r.extend(s);a=e.setDefaults(a,"freeColor",!1);this.base(i,r,a);if(!e.get(a,"freePosition",!1)){var o=i.isOrientationVertical()?"left":"bottom",l=i.anchorOrtho(o);this._lockDynamic(o,"x")._lockDynamic(l,"y")}this._bindProperty("shape","shape")._bindProperty("shapeRadius","radius")._bindProperty("shapeSize","size");this.optional("strokeDasharray",void 0).optional("lineWidth",1.5)}).prototype.property("size").property("shape").constructor.add({y:e.fun.constant(0),x:e.fun.constant(0),radius:function(){this.instanceState().cccRadius=this.delegateExtension() },baseSize:function(t){var i=this.instanceState().cccRadius;return null!=i?e.sqr(i):this.base(t)},defaultSize:e.fun.constant(12),interactiveSize:function(e,t){return this.mayShowActive(e,!0)?2.5*Math.max(t,5):t},interactiveColor:function(e,t,i){if(this.mayShowActive(e,!0)){if("stroke"===i)return t.brighter(1)}else if(this.mayShowNotAmongSelected(e)){if(this.mayShowActive(e))return t.alpha(.8);switch(i){case"fill":return this.dimColor(t,i);case"stroke":return t.alpha(.45)}}return this.base(e,t,i)}});e.type("pvc.visual.DotSizeColor",Tt.visual.Dot).init(function(e,i,n){this.base(e,i,n);var a=this.compatVersion()<=1;this._bindProperty("lineWidth","strokeWidth").intercept("visible",function(e){if(!this.canShow(e))return!1;var t=this.delegateExtension();null==t&&(t=a||this.defaultVisible(e));return t});this._initColor();this._initSize();if(this.isSizeBound){var r=e.axes.size;if(r.scaleUsesAbs()){this.isSizeAbs=!0;var s=this._sceneDefColor;this._sceneDefColor=function(e,i){return"stroke"===i&&e.vars.size.value<0?t.Color.names.black:s.call(this,e,i) };this.pvMark.lineCap("round").strokeDasharray(function(e){return e.vars.size.value<0?"dash":null})}}}).prototype.property("strokeWidth").constructor.add({isColorBound:!1,isColorDiscrete:!1,isSizeBound:!1,isSizeAbs:!1,canShow:function(e){return!e.isIntermediate},defaultVisible:function(e){return!e.isNull&&(!this.isSizeBound&&!this.isColorBound||this.isSizeBound&&null!=e.vars.size.value||this.isColorBound&&(this.isColorDiscrete||null!=e.vars.color.value))},_initColor:function(){var t,i,n=this.panel,a=n.visualRoles.color;if(a){this.isColorDiscrete=a.isDiscrete();var r=n.axes.color;if(a.isBound()){this.isColorBound=!0;i=r.sceneScale({sceneVarName:"color"})}else r&&(t=r.option("Unbound"))}i||(i=e.fun.constant(t||Tt.defaultColor));this._sceneDefColor=i},_initSize:function(){var t,i,n=this.panel,a=n.plot,r=a.option("Shape"),s=a.option("NullShape"),o=n.visualRoles.size;if(o){var l=n.axes.size,u=l&&l.scale,c=!!u&&o.isBound();if(c){this.isSizeBound=!0;var h=u.min+.05*(u.max-u.min);this.nullSizeShapeHasStrokeOnly="cross"===s; i=function(e){return null!=e.vars.size.value?r:s};t=function(e){var t=e.vars.size.value;return null!=t?u(t):s?h:0}}}if(!t){i=e.fun.constant(r);t=function(e){return this.base(e)}}this._sceneDefSize=t;this._sceneDefShape=i},defaultColor:function(e,t){return this._sceneDefColor(e,t)},normalColor:function(e,t,i){return"stroke"===i?t.darker():this.base(e,t,i)},interactiveColor:function(e,t,i){if(this.mayShowActive(e,!0))switch(i){case"fill":return this.isSizeBound?t.alpha(.75):t;case"stroke":return t.darker()}else if(this.showsSelection()){var n=e.isSelected(),a=!n&&e.anySelected();if(a){if(this.mayShowActive(e))return t.alpha(.8);switch(i){case"fill":return this.dimColor(t,i);case"stroke":return t.alpha(.45)}}if(n&&s(t)){"stroke"===i&&(t=t.darker(3));return t.darker(2)}}return"stroke"===i?t.darker():t},defaultSize:function(e){return this._sceneDefSize(e)},defaultShape:function(e){return this._sceneDefShape(e)},interactiveSize:function(t,i){if(!this.mayShowActive(t,!0))return i;var n=Math.sqrt(i),a=Math.max(1,Math.min(1.1*n,2)); return e.sqr(n+a)},defaultStrokeWidth:function(e){return this.nullSizeShapeHasStrokeOnly&&null==e.vars.size.value?1.8:1},interactiveStrokeWidth:function(e,t){return this.mayShowActive(e,!0)?2*t:this.mayShowSelected(e)?1.5*t:t}});t.LineInterm=function(){t.Line.call(this)};t.LineInterm.prototype=t.extend(t.Line);t.LineInterm.prototype.getNearestInstanceToMouse=function(e,i){var n=t.Line.prototype.getNearestInstanceToMouse.call(this,e,i),a=e[n];a&&a.data&&a.data.isIntermediate&&n+1i;i++)if(t[i].call(this,e))return!0; return!1},_resolveFixed:Tt.options.specify(function(e){return this._fixed?this._fixed[e.name]:void 0}),_resolveByV1OnlyLogic:function(e){var t,i=e.data;return i&&(t=i.resolveV1)?t.call(this,e):void 0},_resolveByName:Tt.options.specify(function(t){return this.name?this._chartOption(this.name+e.firstUpperCase(t.name)):void 0}),_resolveByOptionId:Tt.options.specify(function(t){return this._chartOption(this.optionId+e.firstUpperCase(t.name))}),_resolveByNaked:Tt.options.specify(function(t){return this.index?void 0:this._chartOption(e.firstLowerCase(t.name))}),_resolveDefault:function(e){var t,i=e.data;if(i&&(t=i.resolveDefault)&&t.call(this,e))return!0;if(this._defaults){var n=this._defaults[e.name];if(void 0!==n){e.defaultValue(n);return!0}}},_specifyChartOption:function(e,t){var i=this._chartOption(t);if(null!=i){e.specify(i);return!0}}});e.type("pvc.visual.MultiChart",Tt.visual.OptionsBase).init(function(e){this.base(e,"multiChart",0,{byV1:!1,byNaked:!1})}).add({_getOptionsDefinition:function(){return Tt.visual.MultiChart.optionsDef }}).addStatic({optionsDef:{Max:{resolve:"_resolveFull",cast:Tt.castPositiveNumber,value:1/0},ColumnsMax:{resolve:"_resolveFull",cast:Tt.castPositiveNumber,value:3},SingleRowFillsHeight:{resolve:"_resolveFull",cast:Boolean,value:!0},SingleColFillsHeight:{resolve:"_resolveFull",cast:Boolean,value:!0},Overflow:{resolve:"_resolveFull",cast:Tt.parseMultiChartOverflow,value:"grow"}}});e.type("pvc.visual.SmallChart",Tt.visual.OptionsBase).init(function(e){this.base(e,"small",0,{byV1:!1,byNaked:!1})}).add({_getOptionsDefinition:function(){return Tt.visual.SmallChart.optionsDef}}).addStatic({optionsDef:{Width:{resolve:"_resolveFull",cast:Nt.parse,value:null},Height:{resolve:"_resolveFull",cast:Nt.parse,value:null},AspectRatio:{resolve:"_resolveFull",cast:Tt.castPositiveNumber,getDefault:function(){return this.chart instanceof Tt.PieChart?10/7:5/4}},Margins:{resolve:"_resolveFull",cast:Vt.as,value:new Vt(new Nt(.02))},Paddings:{resolve:"_resolveFull",cast:Vt.as,value:0}}});var Qt=e.type("pvc.visual.Axis",Tt.visual.OptionsBase).init(function(e,t,i,n){this.base(e,t,i,n); e._addAxis(this)}).add({scaleTreatsNullAs:function(){return"null"},scaleNullRangeValue:function(){return null},scaleUsesAbs:e.retFalse,scaleSumNormalized:e.retFalse,domainVisibleOnly:e.retTrue,domainIgnoreNulls:e.retFalse,domainGroupOperator:function(){return"flatten"},domainItemValueProp:function(){return"value"},bind:function(t){var i=this;t||e.fail.argumentRequired("dataCells");!i.dataCells||e.fail.operationInvalid("Axis is already bound.");i.dataCells=e.array.to(t);i.dataCell=i.dataCells[0];i.role=i.dataCell&&i.dataCell.role;i.scaleType=gt(i.role.grouping);i._domainData=null;i._domainValues=null;i._domainItems=null;i._checkRoleCompatibility();return this},domainData:function(){this.isBound()||e.fail.operationInvalid("Axis is not bound.");var t=this._domainData;if(!t){var i=this.dataCells.map(Pt),n=this.chart.partData(i);this._domainData=t=this._createDomainData(n)}return t},domainCellData:function(e){var t=this.dataCells;if(1===t.length)return this.domainData();var i=t[e],n=this.chart.partData(i.dataPartValue); return this._createDomainData(n)},domainCellItems:function(e){var t=this.dataCells;if(1===t.length)return this.domainItems();var i;i="number"==typeof e?this.domainCellData(e):e;return this._selectDomainItems(i).array()},domainValues:function(){var e=this._domainValues;if(!e){this._calcDomainItems();e=this._domainValues}return e},domainItems:function(){var e=this._domainItems;if(!e){this._calcDomainItems();e=this._domainItems}return e},domainItemValue:function(t){return e.nullyTo(t[this.domainItemValueProp()],"")},isDiscrete:function(){return!!this.role&&this.role.isDiscrete()},isBound:function(){return!!this.role},setScale:function(t,i){this.isBound()||e.fail.operationInvalid("Axis is not bound.");this.scale=t?i?t:this._wrapScale(t):null;return this},_wrapScale:function(t){t.type=this.scaleType;var i;if("discrete"!==t.type){var n=this.scaleUsesAbs(),a=this.scaleTreatsNullAs();if(a&&"null"!==a){var r="min"===a;i=n?function(e){return t(null==e?r?t.domain()[0]:0:0>e?-e:e)}:function(e){return t(null==e?r?t.domain()[0]:0:e) }}else{var s=this.scaleNullRangeValue();i=n?function(e){return null==e?s:t(0>e?-e:e)}:function(e){return null==e?s:t(e)}}}else i=function(e){return t(null==e?"":e)};return e.copy(i,t)},sceneScale:function(t){var i=e.get(t,"sceneVarName")||this.role.name,n=this.role.grouping;if(n.isSingleDimension&&n.firstDimensionValueType()===Number){var a=this.scale,r=e.get(t,"nullToZero",!0),s=function(e){var t=e.vars[i].value;if(null==t){if(!r)return t;t=0}return a(t)};e.copy(s,a);return s}return this.scale.by1(function(e){return e.vars[i].value})},_checkRoleCompatibility:function(){var t=this.dataCells.length;if(t>1){var i,n,a=this._getBoundRoleGrouping(this.role);if("discrete"===this.scaleType)for(n=1;t>n;n++){i=this._getBoundRoleGrouping(this.dataCells[n].role);if(a.id!==i.id)throw e.error.operationInvalid("Discrete roles on the same axis must have equal groupings.")}else{if(!a.firstDimensionType().isComparable)throw e.error.operationInvalid("Continuous roles on the same axis must have 'comparable' groupings."); for(n=1;t>n;n++){i=this._getBoundRoleGrouping(this.dataCells[n].role);if(this.scaleType!==gt(i))throw e.error.operationInvalid("Continuous roles on the same axis must have scales of the same type.")}}}},_getBoundRoleGrouping:function(t){var i=t.grouping;if(!i)throw e.error.operationInvalid("Axis' role '"+t.name+"' is unbound.");return i},_createDomainData:function(e){var t={visible:this.domainVisibleOnly()?!0:null,isNull:this.chart.options.ignoreNulls||this.domainIgnoreNulls()?!1:null};return this.role[this.domainGroupOperator()](e,t)},_selectDomainItems:function(e){return e.children()},_calcDomainItems:function(){var t=e.hasOwnProp,i={},n=[],a=[],r=(this.domainItemValueProp(),this.domainData());this._selectDomainItems(r).each(function(e){var r=this.domainItemValue(e);if(!t.call(i,r)){i[r]=1;n.push(r);a.push(e)}},this);this._domainItems=a;this._domainValues=n},_getOptionsDefinition:function(){return Yt}}),Yt={},Zt=e.type("pvc.visual.CartesianAxis",Qt).init(function(e,t,i,n){var a=e.options; this.orientation=Zt.getOrientation(t,a.orientation);this.orientedId=Zt.getOrientedId(this.orientation,i);e._allowV1SecondAxis&&1===i&&(this.v1SecondOrientedId="second"+this.orientation.toUpperCase());this.base(e,t,i,n);var r=this.extensionPrefixes=[this.id+"Axis",this.orientedId+"Axis"];this.v1SecondOrientedId&&r.push(this.v1SecondOrientedId+"Axis");this._extPrefAxisPosition=r.length;r.push("axis")}).add({bind:function(e){this.base(e);this._syncExtensionPrefixes();return this},_syncExtensionPrefixes:function(){var e=this.extensionPrefixes;e.length=this._extPrefAxisPosition;var t=this.scaleType;if(t){e.push(t+"Axis");"discrete"!==t&&e.push("continuousAxis")}e.push("axis")},setScale:function(e){var t=this.scale;this.base(e);if(t){delete this.domain;delete this.ticks;delete this._roundingPaddings}if(e&&!e.isNull&&"discrete"!==this.scaleType){this.domain=e.domain();this.domain.minLocked=!!e.minLocked;this.domain.maxLocked=!!e.maxLocked;var i=this.option("DomainRoundMode");"nice"===i&&e.nice(); var n=this.option("TickFormatter");n&&e.tickFormatter(n)}return this},setTicks:function(t){var i=this.scale;i&&!i.isNull||e.fail.operationInvalid("Scale must be set and non-null.");this.ticks=t;if("discrete"!==i.type&&"tick"===this.option("DomainRoundMode")){delete this._roundingPaddings;var n=t&&t.length;n?this.scale.domain(t[0],t[n-1]):this.scale.domain(this.domain[0],this.domain[1])}},setScaleRange:function(e){var t=this.scale;t.min=0;t.max=e;t.size=e;if("discrete"===t.type){if(t.domain().length>0){var i=this.chart.options.panelSizeRatio||.8;t.splitBandedCenter(t.min,t.max,i)}}else t.range(t.min,t.max);return t},getScaleRoundingPaddings:function(){var t=this._roundingPaddings;if(!t){t={begin:0,end:0,beginLocked:!1,endLocked:!1};var i=this.scale;if(i&&!i.isNull&&"discrete"!==i.type){var n=this.domain;t.beginLocked=n.minLocked;t.endLocked=n.maxLocked;if("numeric"===i.type&&"none"!==this.option("DomainRoundMode")){var a=i.domain(),r=this.domain||e.assert("Original domain must be set"),s=a[1]-a[0]; if(s){var o=r[0]-a[0];o>0&&(t.begin=o/s);o=a[1]-r[1];o>0&&(t.end=o/s)}}}this._roundingPaddings=t}return t},calcContinuousTicks:function(e){null==e&&(e=this.option("DesiredTickCount"));return this.scale.ticks(e,{roundInside:"tick"!==this.option("DomainRoundMode"),numberExponentMin:this.option("TickExponentMin"),numberExponentMax:this.option("TickExponentMax")})},_getOptionsDefinition:function(){return ei},_buildOptionId:function(){return this.id+"Axis"},_registerResolversNormal:function(e){this.chart.compatVersion()<=1&&e.push(this._resolveByV1OnlyLogic);e.push(this._resolveByOptionId,this._resolveByOrientedId);1===this.index&&e.push(this._resolveByV1OptionId);e.push(this._resolveByScaleType,this._resolveByCommonId)},_resolveByOrientedId:Tt.options.specify(function(e){return this._chartOption(this.orientedId+"Axis"+e.name)}),_resolveByV1OptionId:Tt.options.specify(function(e){return this._chartOption("secondAxis"+e.name)}),_resolveByScaleType:Tt.options.specify(function(e){var t=this.scaleType; if(t){var i=e.name,n=this._chartOption(t+"Axis"+i);void 0===n&&"discrete"!==t&&(n=this._chartOption("continuousAxis"+i));return n}}),_resolveByCommonId:Tt.options.specify(function(e){return this._chartOption("axis"+e.name)})});Zt.getOrientation=function(e,t){return"base"===e==("vertical"===t)?"x":"y"};Zt.getOrientedId=function(e,t){return 0===t?e:e+(t+1)};var $t={resolve:"_resolveFull",data:{resolveV1:function(e){this.index||"ortho"!==this.type||this._specifyChartOption(e,this.id+e.name);return!0}}},Xt={resolveV1:function(e){if(this.index){if(this._resolveByV1OptionId(e))return!0}else if(this._resolveByOrientedId(e))return!0;this._resolveDefault(e);return!0}},Jt=Tt.options.defaultValue(function(){if(!this.typeIndex)return"x"===this.orientation?"bottom":"left";var e=this.chart.axesByType[this.type].first,t=e.option("Position");return Tt.BasePanel.oppositeAnchor[t]}),ei=e.create(Yt,{Visible:{resolve:"_resolveFull",data:{resolveV1:function(t){if(this.index<=1){var i=0===this.index?e.firstUpperCase(this.orientation):"Second"; this._specifyChartOption(t,"show"+i+"Scale")}return!0}},cast:Boolean,value:!0},Composite:{resolve:function(e){if(this.index>0){e.specify(!1);return!0}return this._resolveFull(e)},data:{resolveV1:function(e){this._specifyChartOption(e,"useCompositeAxis");return!0}},cast:Boolean,value:!1},Size:{resolve:"_resolveFull",data:Xt,cast:yt},SizeMax:{resolve:"_resolveFull",cast:yt},Position:{resolve:"_resolveFull",data:{resolveV1:Xt.resolveV1,resolveDefault:Jt},cast:_t},FixedMin:$t,FixedMax:$t,OriginIsZero:{resolve:"_resolveFull",data:{resolveV1:function(e){switch(this.index){case 0:this._specifyChartOption(e,"originIsZero");break;case 1:this.chart._allowV1SecondAxis&&this._specifyChartOption(e,"secondAxisOriginIsZero")}return!0}},cast:Boolean,value:!0},DomainScope:{resolve:"_resolveFull",cast:bt,value:"global"},Offset:{resolve:"_resolveFull",data:{resolveV1:function(e){switch(this.index){case 0:this._specifyChartOption(e,"axisOffset");break;case 1:if(this.chart._allowV1SecondAxis){this._specifyChartOption(e,"secondAxisOffset"); break}}return!0}},cast:Tt.castNumber},LabelSpacingMin:{resolve:"_resolveFull",cast:Tt.castNumber},OverlappedLabelsMode:{resolve:"_resolveFull",cast:Tt.parseOverlappedLabelsMode,value:"rotatethenhide"},Grid:{resolve:"_resolveFull",data:{resolveV1:function(e){this.index||this._specifyChartOption(e,this.orientation+"AxisFullGrid");return!0}},cast:Boolean,value:!1},GridCrossesMargin:{resolve:"_resolveFull",cast:Boolean,value:!0},EndLine:{resolve:"_resolveFull",cast:Boolean},ZeroLine:{resolve:"_resolveFull",cast:Boolean,value:!0},RuleCrossesMargin:{resolve:"_resolveFull",cast:Boolean,value:!0},Ticks:{resolve:"_resolveFull",cast:Boolean},DesiredTickCount:{resolve:"_resolveFull",data:{resolveV1:Xt.resolveV1,resolveDefault:function(e){if(this.chart.compatVersion()<=1){e.defaultValue(5);return!0}}},cast:Tt.castNumber},MinorTicks:{resolve:"_resolveFull",data:Xt,cast:Boolean,value:!0},TickFormatter:{resolve:"_resolveFull",cast:e.fun.as},DomainRoundMode:{resolve:"_resolveFull",data:{resolveV1:Xt.resolveV1,resolveDefault:function(e){if(this.chart.compatVersion()<=1){e.defaultValue("none"); return!0}}},cast:Tt.parseDomainRoundingMode,value:"tick"},TickExponentMin:{resolve:"_resolveFull",cast:Tt.castNumber},TickExponentMax:{resolve:"_resolveFull",cast:Tt.castNumber},Title:{resolve:"_resolveFull",cast:String},TitleSize:{resolve:"_resolveFull",cast:xt},TitleSizeMax:{resolve:"_resolveFull",cast:xt},TitleFont:{resolve:"_resolveFull",cast:String},TitleMargins:{resolve:"_resolveFull",cast:Vt.as},TitlePaddings:{resolve:"_resolveFull",cast:Vt.as},TitleAlign:{resolve:"_resolveFull",cast:function(e){var t=this.option("Position");return Tt.parseAlign(t,e)}},Font:{resolve:"_resolveFull",cast:String},ClickAction:{resolve:"_resolveFull",data:Xt},DoubleClickAction:{resolve:"_resolveFull",data:Xt},TooltipEnabled:{resolve:"_resolveFull",cast:Boolean,value:!0},TooltipFormat:{resolve:"_resolveFull",cast:e.fun.as,value:null},TooltipAutoContent:{resolve:"_resolveFull",cast:Tt.parseTooltipAutoContent,value:"value"}});e.type("pvc.visual.CartesianAxisRootScene",Tt.visual.Scene);e.type("pvc.visual.CartesianAxisTickScene",Tt.visual.Scene).init(function(t,i){this.base(t,i); this.vars.tick=new jt(e.get(i,"tick"),e.get(i,"tickLabel"),e.get(i,"tickRaw"));e.get(i,"isHidden")&&(this.isHidden=!0)}).add({isHidden:!1});e.type("pvc.visual.CartesianFocusWindow",Tt.visual.OptionsBase).init(function(e){this.base(e,"focusWindow",0,{byNaked:!1});var t=e.axes.base;this.base=new Tt.visual.CartesianFocusWindowAxis(this,t)}).add({_getOptionsDefinition:function(){return ti},_exportData:function(){return{base:e.copyProps(this.base,Tt.visual.CartesianFocusWindow.props)}},_importData:function(e){var t=e.base;this.base.option.specify({Begin:t.begin,End:t.end,Length:t.length})},_initFromOptions:function(){this.base._initFromOptions()},_onAxisChanged:function(){var e=this.option("Changed");e&&e.call(this.chart.basePanel.context())}});var ti=e.create(Yt,{Changed:{resolve:"_resolveFull",cast:e.fun.as}});e.type("pvc.visual.CartesianFocusWindowAxis",Tt.visual.OptionsBase).init(function(t,i){this.window=t;this.axis=i;this.isDiscrete=i.isDiscrete();this.base(i.chart,"focusWindow"+e.firstUpperCase(i.type),0,{byNaked:!1}) }).addStatic({props:["begin","end","length"]}).add({_getOptionsDefinition:function(){return ii},_initFromOptions:function(){var e=this.option;this.set({begin:e("Begin"),end:e("End"),length:e("Length")})},set:function(t){var i,n,a,r=this,s=e.get(t,"render"),o=e.get(t,"select",!0);t=r._readArgs(t);if(t){i=t.begin;n=t.end;a=t.length}else if(null!=this.begin&&null!=this.end&&null!=this.length)return;var l,u,c=r.axis,h=c.scale,d=r.isDiscrete,f=d?null:c.role.firstDimensionType().cast,v=h.domain();if(d){u=v.length;var p,m,g;if(null!=i){var b=+i;if(!isNaN(b))if(1/0===b){p=u-1;i=v[p]}else if(b===-1/0){p=0;i=v[p]}if(null==p){p=v.indexOf(""+i);if(0>p){p=0;i=v[p]}}}if(null!=n){var _=+n;if(!isNaN(_))if(1/0===_){m=u-1;n=v[m]}else if(_===-1/0){m=0;n=v[m]}if(null==m){m=v.indexOf(""+n);if(0>m){m=u-1;n=v[m]}}}if(null!=a){a=+a;if(isNaN(a))a=null;else if(0>a&&(null!=i||null!=n)){l=i;g=p;i=n,p=m,n=l,m=g;a=-a}}if(null!=i)if(null!=n){if(p>m){l=i;g=p;i=n,p=m,n=l,m=g}a=m-p+1}else{null==a&&(a=u-p);m=p+a-1;if(m>u-1){m=u-1; a=m-p+1}n=v[m]}else if(null!=n){null==a&&(a=m);p=m-a+1;if(0>p){p=0;a=m-p+1}i=v[p]}else{null==a&&(a=Math.max(~~(u/3),1));if(a>u){a=u;p=0;m=u-1}else{g=~~(u/2);p=g-~~(a/2);m=p+a-1}i=v[p];n=v[m]}}else{if(null!=a){a=+a;if(isNaN(a))a=null;else if(0>a&&(null!=i||null!=n)){l=i;i=n,n=l;a=-a}}var y=v[0],x=v[1];u=x-y;if(null!=i){y>i&&(i=y);i>x&&(i=x)}if(null!=n){y>n&&(n=y);n>x&&(n=x)}if(null!=i)if(null!=n){if(i>n){l=i;i=n,n=l}a=n-i}else{null==a&&(a=x-i);n=i+a;if(n>x){n=x;a=n-i}}else if(null!=n){null==a&&(a=n-y);i=n-a;if(y>i){i=y;a=n-i}}else{null==a&&(a=Math.max(~~(u/3),1));if(a>u){a=u;i=y;n=x}else{l=~~(u/2);i=l-~~(a/2);var S=+i,w=+a;n=S+w}}i=f(i);n=f(n);a=f(a);var C=r.option("Constraint");if(C){var k={type:"new",target:"begin",value:i,length:a,length0:a,min:y,max:x,minView:y,maxView:x};C(k);i=f(k.value);a=f(k.length);var S=+i,w=+a;n=f(S+w)}}r._set(i,n,a,o,s)},_updatePosition:function(e,t,i,n){var a,r,s,o=this,l=o.axis,u=l.scale;if(o.isDiscrete){var c=u.invertIndex(e),h=u.invertIndex(t)-1,d=u.domain(); a=d[c];r=d[h];s=h-c+1}else{a=u.invert(e);r=u.invert(t);s=r-a}this._set(a,r,s,i,n)},_constraintPosition:function(e){var t,i=this,n=i.axis,a=n.scale;if(i.isDiscrete){var r=Math.floor(a.invertIndex(e.point,!0));if(r>=0){var s=a.range(),o=a.domain().length,l=(s.max-s.min)/o;r>=o&&("new"===e.type||"resize-begin"===e.type)&&(r=o-1);e.point=r*l}}else if(t=i.option("Constraint")){var u,c,h,d=n.role.firstDimensionType().cast,f=d(a.invert(e.point)),v="begin"===e.target?1:-1,p=e.point+v*e.length,m=d(a.invert(p)),g=d(v*(m-f));if(e.length===e.length0)u=g;else{c=e.point+v*e.length0;h=d(a.invert(c));u=v*(h-f)}var b=d(a.invert(e.min)),_=d(a.invert(e.max)),y={type:e.type,target:e.target,value:f,length:g,length0:u,min:b,max:_,minView:d(a.invert(e.minView)),maxView:d(a.invert(e.maxView))};t(y);if(+y.value!==+f){f=y.value;e.point=a(f)}var x=y.length;if(+x!==+g)if(+x===+u)e.length=e.length0;else{var S=+f+v*+x,w=a(S);e.length=w-v*e.point}+y.min!==+b&&(e.min=a(y.min));+y.max!==+_&&(e.max=a(y.max))}},_compare:function(e,t){return this.isDiscrete?""+e==""+t:+e===+t },_set:function(e,t,i,n,a){var r=this,s=!1;if(!r._compare(e,r.begin)){r.begin=e;s=!0}if(!r._compare(t,r.end)){r.end=t;s=!0}if(!r._compare(i,r.length)){r.length=i;s=!0}s&&r.window._onAxisChanged(this);n&&r._updateSelection({render:a});return s},_readArgs:function(e){if(e){var t={},i=0,n=function(n){var a=e[n];null!=a?i=!0:a=this[n];t[n]=a};Tt.visual.CartesianFocusWindowAxis.props.forEach(n,this);if(i)return t}},_updateSelection:function(t){var i,n,a=this,r=a.axis,s=r.isDiscrete(),o=r.chart,l=r.dataCell,u=l.role,c=o.partData(l.dataPartValue);if(s){n=u.flatten(c);var h=n.child(a.begin),d=n.child(a.end);if(h&&d){var f=h.childIndex(),v=d.childIndex();i=e.range(f,v-f+1).select(function(e){return n.childNodes[e]}).selectMany(e.propGet("_datums")).where(P).distinct(e.propGet("key"))}}else{n=c;var p=u.firstDimensionName();i=e.query(c._datums).where(P).where(function(e){var t=e.atoms[p].value;return null!=t&&t>=a.begin&&t<=a.end})}if(i){o.data.replaceSelected(i);o.root.updateSelections(t)}}});var ii=e.create(Yt,{Resizable:{resolve:"_resolveFull",cast:Boolean,value:!0},Movable:{resolve:"_resolveFull",cast:Boolean,value:!0},Begin:{resolve:"_resolveFull"},End:{resolve:"_resolveFull"},Length:{resolve:"_resolveFull"},Constraint:{resolve:"_resolveFull",cast:e.fun.as}}); e.type("pvc.visual.ColorAxis",Qt).add({scaleNullRangeValue:function(){return this.option("Missing")||null},scaleUsesAbs:function(){return this.option("UseAbs")},domainVisibleOnly:function(){return"discrete"!==this.scaleType},bind:function(t){this.base(t);this._legendGroupScene=null;this._plotList=e.query(t).select(function(e){return e.plot}).distinct(function(e){return e&&e.id}).array();return this},_wrapScale:function(e){var t;t="discrete"===this.scaleType?this.option.isSpecified("Transform")||!this.option.isSpecified("Colors")&&!this.option.isSpecified("Map"):!0;if(t){var i=this.option("Transform");i&&(e=e.transform(i))}return this.base(e)},scheme:function(){return e.lazy(this,"_scheme",this._createScheme,this)},_createColorMapFilter:function(t){var i=e.uniqueIndex(t,function(e){return e.key});return{domain:function(i){return!e.hasOwn(t,i)},color:function(t){return!e.hasOwn(i,t.key)}}},_getBaseScheme:function(){return this.option("Colors")},_createScheme:function(){var t=this,i=t._getBaseScheme(); if("discrete"!==t.scaleType)return function(){var e=i.apply(null,arguments);return t._wrapScale(e)};var n=t.option("Map");if(!n)return function(){var e=i.apply(null,arguments);return t._wrapScale(e)};var a=this._createColorMapFilter(n);return function(r){var s;r instanceof Array||(r=e.array.copy(arguments));r=r.filter(a.domain);var o=i(r),l=o.range().filter(a.color);o.range(l);s=function(t){var i=e.getOwn(n,t);return i||o(t)};e.copy(s,o);var u,c;s.domain=function(){if(arguments.length)throw e.operationInvalid("The scale cannot be modified.");u||(u=e.array.append(e.ownKeys(n),r));return u};s.range=function(){if(arguments.length)throw e.operationInvalid("The scale cannot be modified.");c||(c=e.array.append(e.own(n),l));return c};return t._wrapScale(s)}},sceneScale:function(t){var i=e.get(t,"sceneVarName")||this.role.name,n=this.scalesByCateg;if(n){var a=this.option("Missing");return function(e){var t=e.vars[i].value;if(null==t)return a;var r=e.group.parent.absKey;return n[r](t)}}return this.scale.by1(function(e){return e&&e.vars[i].value })},_buildOptionId:function(){return this.id+"Axis"},_getOptionsDefinition:function(){return ri},_resolveByNaked:Tt.options.specify(function(t){return this.index?void 0:this._chartOption(this.id+e.firstUpperCase(t.name))}),_specifyV1ChartOption:function(e,t){return!this.index&&this.chart.compatVersion()<=1&&this._specifyChartOption(e,t)?!0:void 0}});var ni,ai={resolveDefault:function(t){return!this.index&&this._specifyChartOption(t,e.firstLowerCase(t.name))?!0:void 0}},ri=e.create(Yt,{Colors:{resolve:"_resolveFull",getDefault:wt,data:{resolveV1:function(e){"discrete"===this.scaleType?0===this.index?this._specifyChartOption(e,"colors"):1===this.index&&this.chart._allowV1SecondAxis&&this._specifyChartOption(e,"secondAxisColor"):this._specifyChartOption(e,"colorRange");return!0},resolveDefault:function(e){0===this.index&&this._specifyChartOption(e,"colors")}},cast:Tt.colorScheme},Map:{resolve:"_resolveFull",cast:St},Transform:{resolve:"_resolveFull",data:{resolveDefault:function(t){var i=this._plotList; if(i.length<=2){var n=e.query(i).all(function(e){var t=e.name;return"plot2"===t||"trend"===t});if(n){t.defaultValue(Tt.brighterColorTransform);return!0}}}},cast:e.fun.to},NormByCategory:{resolve:function(e){if(!this.chart._allowColorPerCategory){e.specify(!1);return!0}return this._resolveFull(e)},data:{resolveV1:function(e){this._specifyV1ChartOption(e,"normPerBaseCategory");return!0}},cast:Boolean,value:!1},ScaleType:{resolve:"_resolveFull",data:{resolveV1:function(e){this._specifyV1ChartOption(e,"scalingType");return!0}},cast:Tt.parseContinuousColorScaleType,value:"linear"},UseAbs:{resolve:"_resolveFull",cast:Boolean,value:!1},Domain:{resolve:"_resolveFull",data:{resolveV1:function(e){this._specifyV1ChartOption(e,"colorRangeInterval");return!0}},cast:e.array.to},Min:{resolve:"_resolveFull",data:{resolveV1:function(e){this._specifyV1ChartOption(e,"minColor");return!0}},cast:t.color},Max:{resolve:"_resolveFull",data:{resolveV1:function(e){this._specifyV1ChartOption(e,"maxColor");return!0 }},cast:t.color},Missing:{resolve:"_resolveFull",data:{resolveV1:function(e){this._specifyV1ChartOption(e,"nullColor");return!0}},cast:t.color,value:t.color("lightgray")},Unbound:{resolve:"_resolveFull",getDefault:function(){var e=this.option("Colors");return e().range()[0]||Tt.defaultColor},cast:t.color},LegendVisible:{resolve:"_resolveFull",data:ai,cast:Boolean,value:!0},LegendClickMode:{resolve:"_resolveFull",data:ai,cast:Tt.parseLegendClickMode,value:"togglevisible"},LegendDrawLine:{resolve:"_resolveFull",data:ai,cast:Boolean,value:!1},LegendDrawMarker:{resolve:"_resolveFull",data:ai,cast:Boolean,value:!0},LegendShape:{resolve:"_resolveFull",data:ai,cast:Tt.parseShape}});e.type("pvc.visual.SizeAxis",Qt).init(function(t,i,n,a){a=e.set(a,"byNaked",!1);this.base(t,i,n,a)}).add({_buildOptionId:function(){return this.id+"Axis"},scaleTreatsNullAs:function(){return"min"},scaleUsesAbs:function(){return this.option("UseAbs")},setScaleRange:function(t){var i=this.scale;i.min=t.min;i.max=t.max; i.size=t.max-t.min;i.range(i.min,i.max);Tt.debug>=4&&Tt.log("Scale: "+Tt.stringify(e.copyOwn(i)));return this},_getOptionsDefinition:function(){return si}});var si=e.create(Yt,{OriginIsZero:{resolve:"_resolveFull",cast:Boolean,value:!1},FixedMin:{resolve:"_resolveFull",cast:Tt.castNumber},FixedMax:{resolve:"_resolveFull",cast:Tt.castNumber},UseAbs:{resolve:"_resolveFull",cast:Boolean,value:!1}});e.type("pvc.visual.NormalizedAxis",Qt).init(function(t,i,n,a){a=e.set(a,"byNaked",!1);this.base(t,i,n,a)}).add({_buildOptionId:function(){return this.id+"Axis"},scaleTreatsNullAs:function(){return"zero"},scaleUsesAbs:e.retTrue,scaleSumNormalized:e.retTrue,setScaleRange:function(t){var i=this.scale;i.min=t.min;i.max=t.max;i.size=t.max-t.min;i.range(i.min,i.max);Tt.debug>=4&&Tt.log("Scale: "+Tt.stringify(e.copyOwn(i)));return this},_getOptionsDefinition:function(){return oi}});var oi=e.create(Yt,{OriginIsZero:{value:!0}});e.type("pvc.visual.Legend",Tt.visual.OptionsBase).init(function(t,i,n,a){a=e.set(a,"byNaked",!1); this.base(t,i,n,a)}).add({_getOptionsDefinition:function(){return li}});var li={Position:{resolve:"_resolveFull",cast:Tt.parsePosition,value:"bottom"},Size:{resolve:"_resolveFull",cast:Ct},SizeMax:{resolve:"_resolveFull",cast:Ct},Align:{resolve:"_resolveFull",data:{resolveDefault:function(e){var t,i=this.option("Position");"top"!==i&&"bottom"!==i?t="top":this.chart.compatVersion()<=1&&(t="left");e.defaultValue(t);return!0}},cast:kt},Margins:{resolve:"_resolveFull",data:{resolveDefault:function(t){if(this.chart.compatVersion()>1){var i=this.option("Position"),n=e.set({},Tt.BasePanel.oppositeAnchor[i],5);t.defaultValue(n)}return!0}},cast:Vt.as},Paddings:{resolve:"_resolveFull",cast:Vt.as,value:5},Font:{resolve:"_resolveFull",cast:String},ItemSize:{resolve:"_resolveFull",cast:Dt}};e.type("pvc.visual.legend.BulletRootScene",Tt.visual.Scene).init(function(t,i){this.base(t,i);this._unresolvedMarkerDiam=e.get(i,"markerSize");this._unresolvedItemPadding=new Vt(e.get(i,"itemPadding",5));this._unresolvedItemSize=zt.to(e.get(i,"itemSize"))||new zt; e.set(this.vars,"horizontal",e.get(i,"horizontal",!1),"font",e.get(i,"font"),"textMargin",e.get(i,"textMargin",6)-3)}).add({layout:function(t){function i(t){var i=t.labelTextSize(),a=!i||!i.width||!i.height;t.isHidden=a;if(!a){var r,o={width:h+i.width,height:Math.max(i.height,c)},u={width:l.width||s.width+o.width,height:l.height||s.height+o.height},d={width:Math.max(0,u.width-s.width),height:Math.max(0,u.height-s.height)};if(m)r=!m.items.length;else{m=new Tt.visual.legend.BulletItemSceneSection(0);r=!0}var g=m.size[f]+d[f];r||(g+=s[f]);if(!r&&g>p){n(!1);g=d[f]}var b=m.size;b[f]=g;b[v]=Math.max(b[v],d[v]);var _=m.items.length;m.items.push(t);e.set(t.vars,"section",m,"sectionIndex",_,"textSize",i,"itemSize",u,"itemClientSize",d,"itemContentSize",o)}}function n(e){var t=m.size;b[v]+=t[v];g.length&&(b[v]+=s[v]);b[f]=Math.max(b[f],t[f]);g.push(m);e||(m=new Tt.visual.legend.BulletItemSceneSection(g.length))}var a=t.clientSize;if(!(a.width>0&&a.height>0))return new zt(0,0);var r=t.desiredClientSize,s=this._unresolvedItemPadding.resolve(a),o={width:a.width+s.width,height:a.height+s.height},l=this._unresolvedItemSize.resolve(o),u={width:l.width&&Math.max(0,l.width-s.width),height:l.height&&Math.max(0,l.height-s.height)},c=this._unresolvedMarkerDiam||u.height||15; this.vars.itemPadding=s;this.vars.desiredItemSize=l;this.vars.desiredItemClientSize=u;this.vars.markerSize=c;var h=c+this.vars.textMargin,d=Math.max(0,Math.min(u.width||1/0,r.width||1/0,a.width)-h),f=this.vars.horizontal?"width":"height",v=Tt.BasePanel.oppositeLength[f],p=r[f];(!p||0>p)&&(p=a[f]);var m,g=[],b={width:0,height:0};this.childNodes.forEach(function(e){e.childNodes.forEach(i,this)},this);if(!m)return new zt(0,0);n(!0);e.set(this.vars,"sections",g,"contentSize",b,"labelWidthMax",d);var _=this.compatVersion()<=1,y=_?p:b[f],x=r[v];(!x||0>x)&&(x=b[v]);var S=this.vars.size=e.set({},f,Math.min(y,a[f]),v,Math.min(x,a[v]));return S},defaultGroupSceneType:function(){var t=this._bulletGroupType;if(!t){t=e.type(Tt.visual.legend.BulletGroupScene);this._bulletGroupType=t}return t},createGroup:function(e){var t=this.defaultGroupSceneType();return new t(this,e)}});e.type("pvc.visual.legend.BulletItemSceneSection").init(function(e){this.index=e;this.items=[];this.size={width:0,height:0}});e.type("pvc.visual.legend.BulletGroupScene",Tt.visual.Scene).init(function(t,i){this.base(t,i); this.extensionPrefix=e.get(i,"extensionPrefix")||"";this._renderer=e.get(i,"renderer");this.colorAxis=e.get(i,"colorAxis");this.clickMode=e.get(i,"clickMode");!this.clickMode&&this.colorAxis&&(this.clickMode=this.colorAxis.option("LegendClickMode"))}).add({hasRenderer:function(){return!!this._renderer},renderer:function(e){if(null!=e)this._renderer=e;else{e=this._renderer;if(!e){var t,i=this.colorAxis;i&&(t={drawRule:i.option("LegendDrawLine"),drawMarker:i.option("LegendDrawMarker"),markerShape:i.option("LegendShape")});e=new Tt.visual.legend.BulletItemDefaultRenderer(t);this._renderer=e}}return e},itemSceneType:function(){var t=this._itemSceneType;if(!t){t=e.type(Tt.visual.legend.BulletItemScene);var i=this.clickMode;switch(i){case"toggleselected":t.add(Tt.visual.legend.BulletItemSceneSelection);break;case"togglevisible":t.add(Tt.visual.legend.BulletItemSceneVisibility)}var n=this.panel();n._extendSceneType("item",t,["isOn","executable","execute","value","labelText"]);var a=Tt.makeExtensionAbsId(Tt.makeExtensionAbsId("ItemScene",[this.extensionPrefix,"$"]),n._getExtensionPrefix()),r=n.chart._getExtension(a,"value"); void 0!==r&&t.prototype.variable("value",r);this._itemSceneType=t}return t},createItem:function(e){var t=this.itemSceneType();return new t(this,e)}});e.type("pvc.visual.legend.BulletItemScene",Tt.visual.Scene).init(function(){this.base.apply(this,arguments);if(!this.executable()){var e=Tt.visual.Interactive;this._ibits=e.Interactive|e.ShowsInteraction|e.Hoverable|e.SelectableAny}}).add({isOn:e.fun.constant(!0),executable:e.fun.constant(!1),execute:e.fun.constant(),labelText:function(){return this.value().label},labelTextSize:function(){return t.Text.measure(this.labelText(),this.vars.font)},_valueEval:function(){var e=this._valueEvalCore();e instanceof jt||(e=new jt(e,e));return e},_valueEvalCore:function(){var e,t,i,n,a,r=this.group||this.datum;if(r){e=r.value;t=r.rawValue;a=this._getTrendLineSuffix(r);i=r.ensureLabel()+a;n=r.absLabel?r.absLabel+a:i}return new jt(e||null,i||"",t,n)},_getTrendLineSuffix:function(e){var t,i;return(t=e.firstDatum())&&(i=t.trend)?" ("+i.label+")":""}}).prototype.variable("value"); e.type("pvc.visual.legend.BulletItemSceneSelection").add({isOn:function(){var e=this.group||this.datum;return!e.owner.selectedCount()||this.isSelected()},executable:function(){return this.chart().selectableByClick()},execute:function(){var e=this.datums().array();if(e.length){var t=this.chart();t._updatingSelections(function(){e=t._onUserSelection(e);e&&e.length&&Tt.data.Data.toggleSelected(e,!0)})}}});e.type("pvc.visual.legend.BulletItemSceneVisibility").add({isOn:function(){return this.datums().any(function(e){return!e.isNull&&e.isVisible})},executable:e.fun.constant(!0),execute:function(){Tt.data.Data.toggleVisible(this.datums())&&this.chart().render(!0,!0,!1)}});e.type("pvc.visual.legend.BulletItemRenderer");e.type("pvc.visual.legend.BulletItemDefaultRenderer",Tt.visual.legend.BulletItemRenderer).init(function(t){this.drawRule=e.get(t,"drawRule",!1);this.drawRule&&(this.rulePvProto=e.get(t,"rulePvProto"));this.drawMarker=!this.drawRule||e.get(t,"drawMarker",!0);if(this.drawMarker){this.markerShape=e.get(t,"markerShape","square"); this.markerPvProto=e.get(t,"markerPvProto")}}).add({drawRule:!1,drawMarker:!0,markerShape:null,rulePvProto:null,markerPvProto:null,create:function(e,t,i,n){var a={},r=this.drawRule,s=function(e){return e.color};if(r){var o=(new At).left(0).top(function(){return this.parent.height()/2}).width(function(){return this.parent.width()}).lineWidth(1,Tt.extensionTag).strokeStyle(s,Tt.extensionTag),l=this.rulePvProto;l&&(o=l.extend(o));a.pvRule=new Tt.visual.Rule(e,t,{proto:o,noSelect:!1,noHover:!1,activeSeriesAware:!1,extensionId:i+"Rule",extensionId:Tt.makeExtensionAbsId("Rule",[i,"$"]),showsInteraction:!0,wrapper:n}).pvMark}if(this.drawMarker){var u=(new At).left(function(){return this.parent.width()/2}).top(function(){return this.parent.height()/2}).shapeSize(function(){return this.parent.width()},Tt.extensionTag).lineWidth(2,Tt.extensionTag).fillStyle(s,Tt.extensionTag).strokeStyle(s,Tt.extensionTag).shape(this.markerShape,Tt.extensionTag).angle(r?0:Math.PI/2,Tt.extensionTag).antialias(function(){var e=Math.abs(Math.cos(this.angle())); if(0!==e&&1!==e)switch(this.shape()){case"square":case"bar":return!1}return!0},Tt.extensionTag),c=this.markerPvProto;c&&(u=c.extend(u));a.pvDot=new Tt.visual.Dot(e,t,{proto:u,freePosition:!0,activeSeriesAware:!1,noTooltip:!0,noClick:!0,extensionId:Tt.makeExtensionAbsId("Dot",[i,"$"]),wrapper:n}).pvMark}return a}});e.type("pvc.visual.DataCell").init(function(t,i,n,a,r){this.plot=t;this.axisType=i;this.axisIndex=n;this.role=t.chart.visualRoles[a]||e.fail.argumentInvalid("roleName","Role is not defined.");this.dataPartValue=r});e.type("pvc.visual.ColorDataCell",Tt.visual.DataCell).init(function(e,t,i,n,a){this.base(e,t,i,n,a);this._legendGroupScene=null}).add({legendGroupScene:function(e){if(arguments.length){this._legendGroupScene=e;return this}return this._legendGroupScene}});e.type("pvc.visual.Plot",Tt.visual.OptionsBase).init(function(t,i){var n=e.getPath(t,["plotsByType",this.type]),a=n?n.length:0,r=t.plotList.length;i=e.set(i,"byNaked",!r);this.base(t,this.type,a,i);t._addPlot(this); var s=this.extensionPrefixes=[this.id];this.globalIndex||s.push("");this.name&&s.push(this.name)}).add({_getOptionsDefinition:function(){return Tt.visual.Plot.optionsDef},_resolveByNaked:Tt.options.specify(function(t){return this.globalIndex?void 0:this._chartOption(e.firstLowerCase(t.name))}),collectDataCells:function(e){var t=this._getColorDataCell();t&&e.push(t)},_getColorDataCell:function(){var e=this.option("ColorRole");return e?new Tt.visual.ColorDataCell(this,"color",this.option("ColorAxis")-1,e,this.option("DataPart")):void 0}});Tt.visual.Plot.optionsDef={Orientation:{resolve:function(e){e.specify(this._chartOption("orientation")||"vertical");return!0},cast:String},ValuesVisible:{resolve:"_resolveFull",data:{resolveV1:function(e){if(0===this.globalIndex){var t=this._chartOption("showValues");if(void 0!==t)e.specify(t);else{t="point"!==this.type;e.defaultValue(t)}return!0}}},cast:Boolean,value:!1},ValuesAnchor:{resolve:"_resolveFull",cast:Tt.parseAnchor},ValuesFont:{resolve:"_resolveFull",cast:String,value:"10px sans-serif"},ValuesMask:{resolve:"_resolveFull",cast:String,value:"{value}"},ValuesOptimizeLegibility:{resolve:"_resolveFull",cast:Boolean,value:!1},ValuesOverflow:{resolve:"_resolveFull",cast:Tt.parseValuesOverflow,value:"hide"},DataPart:{resolve:"_resolveFixed",cast:String,value:"0"},ColorRole:{resolve:"_resolveFixed",cast:String,value:"color"},ColorAxis:{resolve:Tt.options.resolvers([function(e){if(0===this.globalIndex){e.specify(1); return!0}},"_resolveFull"]),cast:function(t){t=Tt.castNumber(t);t=null!=t?e.between(t,1,10):1;return t},value:1}};e.type("pvc.visual.CartesianOrthoDataCell",Tt.visual.DataCell).init(function(e,t,i,n,a,r,s,o){this.base(e,t,i,n,a);this.isStacked=r;this.nullInterpolationMode=s;this.trend=o});e.type("pvc.visual.CartesianPlot",Tt.visual.Plot).add({collectDataCells:function(t){this.base(t);t.push(new Tt.visual.DataCell(this,"base",this.option("BaseAxis")-1,this.option("BaseRole"),this.option("DataPart")));var i=e.array.to(this.option("OrthoRole")),n=this.option("DataPart"),a=this.option("OrthoAxis")-1,r=this.option.isDefined("Stacked")?this.option("Stacked"):void 0,s=this.option("NullInterpolationMode"),o=this.option("Trend");i.forEach(function(e){t.push(new Tt.visual.CartesianOrthoDataCell(this,"ortho",a,e,n,r,s,o))},this)},_getOptionsDefinition:function(){return Tt.visual.CartesianPlot.optionsDef}});Tt.visual.CartesianPlot.optionsDef=e.create(Tt.visual.Plot.optionsDef,{BaseAxis:{value:1},BaseRole:{resolve:"_resolveFixed",cast:String},OrthoAxis:{resolve:function(e){if(0===this.globalIndex){e.specify(1); return!0}return this._resolveFull(e)},data:{resolveV1:function(e){"plot2"===this.name&&this.chart._allowV1SecondAxis&&this._chartOption("secondAxisIndependentScale")&&e.specify(2);return!0}},cast:function(t){t=Tt.castNumber(t);return null!=t?e.between(t,1,10):1},value:1},OrthoRole:{resolve:Tt.options.resolvers(["_resolveFixed","_resolveDefault"])},Trend:{resolve:"_resolveFull",data:{resolveDefault:function(e){var t=this.option("TrendType");if(t){e.defaultValue({type:t});return!0}}},cast:It},TrendType:{resolve:"_resolveFull",cast:Tt.parseTrendType},TrendLabel:{resolve:"_resolveFull",cast:String},NullInterpolationMode:{resolve:"_resolveFull",cast:Tt.parseNullInterpolationMode,value:"none"}});e.type("pvc.visual.CategoricalPlot",Tt.visual.CartesianPlot).add({_getOptionsDefinition:function(){return Tt.visual.CategoricalPlot.optionsDef}});Tt.visual.CategoricalPlot.optionsDef=e.create(Tt.visual.CartesianPlot.optionsDef,{Stacked:{resolve:"_resolveFull",cast:Boolean,value:!1},BaseRole:{value:"category"},OrthoRole:{value:"value"}}); e.type("pvc.visual.BarPlotAbstract",Tt.visual.CategoricalPlot).add({_getOptionsDefinition:function(){return Tt.visual.BarPlotAbstract.optionsDef}});Tt.visual.BarPlotAbstract.optionsDef=e.create(Tt.visual.CategoricalPlot.optionsDef,{BarSizeRatio:{resolve:"_resolveFull",cast:function(e){e=Tt.castNumber(e);null==e?e=1:.05>e?e=.05:e>1&&(e=1);return e},value:.9},BarSizeMax:{resolve:"_resolveFull",data:{resolveV1:function(e){this._specifyChartOption(e,"maxBarSize");return!0}},cast:function(e){e=Tt.castNumber(e);null==e?e=1/0:1>e&&(e=1);return e},value:2e3},BarOrthoSizeMin:{resolve:"_resolveFull",cast:Tt.castNonNegativeNumber,value:1.5},BarStackedMargin:{resolve:"_resolveFull",cast:function(e){e=Tt.castNumber(e);null!=e&&0>e&&(e=0);return e},value:0},OverflowMarkersVisible:{resolve:"_resolveFull",cast:Boolean,value:!0},ValuesAnchor:{value:"center"}});e.type("pvc.visual.BarPlot",Tt.visual.BarPlotAbstract).add({type:"bar"});e.type("pvc.visual.NormalizedBarPlot",Tt.visual.BarPlotAbstract).add({type:"bar",_getOptionsDefinition:function(){return Tt.visual.NormalizedBarPlot.optionsDef }});Tt.visual.NormalizedBarPlot.optionsDef=e.create(Tt.visual.BarPlotAbstract.optionsDef,{Stacked:{resolve:null,value:!0}});e.type("pvc.visual.WaterfallPlot",Tt.visual.BarPlotAbstract).add({type:"water",_getOptionsDefinition:function(){return Tt.visual.WaterfallPlot.optionsDef}});Tt.visual.WaterfallPlot.optionsDef=e.create(Tt.visual.BarPlotAbstract.optionsDef,{Stacked:{resolve:null,value:!0},TotalLineLabel:{resolve:"_resolveFull",cast:String,value:"Accumulated"},TotalValuesVisible:{resolve:"_resolveFull",data:{resolveDefault:function(e){e.defaultValue(this.option("ValuesVisible"));return!0}},cast:Boolean},Direction:{resolve:"_resolveFull",cast:Tt.parseWaterDirection,value:"down"},AreasVisible:{resolve:"_resolveFull",cast:Boolean,value:!0},AllCategoryLabel:{resolve:"_resolveFull",cast:String,value:"All"}});e.type("pvc.visual.PointPlot",Tt.visual.CategoricalPlot).add({type:"point",_getOptionsDefinition:function(){return Tt.visual.PointPlot.optionsDef}});Tt.visual.PointPlot.optionsDef=e.create(Tt.visual.CategoricalPlot.optionsDef,{DotsVisible:{resolve:"_resolveFull",data:Rt("Dots",!0),cast:Boolean,value:!1},LinesVisible:{resolve:"_resolveFull",data:Rt("Lines",!0),cast:Boolean,value:!1},AreasVisible:{resolve:"_resolveFull",data:Rt("Areas",!1),cast:Boolean,value:!1},ValuesAnchor:{value:"right"}}); e.type("pvc.visual.MetricXYPlot",Tt.visual.CartesianPlot).add({_getOptionsDefinition:function(){return Tt.visual.MetricXYPlot.optionsDef}});Tt.visual.MetricXYPlot.optionsDef=e.create(Tt.visual.CartesianPlot.optionsDef,{BaseRole:{value:"x"},OrthoAxis:{resolve:null},OrthoRole:{value:"y"}});e.type("pvc.visual.MetricPointPlot",Tt.visual.MetricXYPlot).add({type:"scatter",collectDataCells:function(e){this.base(e);if(this.option("DotsVisible")){var t=this.chart.visualRole(this.option("SizeRole"));t.isBound()&&e.push(new Tt.visual.DataCell(this,"size",this.option("SizeAxis")-1,t.name,this.option("DataPart")))}},_getOptionsDefinition:function(){return Tt.visual.MetricPointPlot.optionsDef}});Tt.visual.MetricPointPlot.optionsDef=e.create(Tt.visual.MetricXYPlot.optionsDef,{SizeRole:{resolve:"_resolveFixed",value:"size"},SizeAxis:{resolve:"_resolveFixed",value:1},Shape:{resolve:"_resolveFull",cast:Tt.parseShape,value:"circle"},NullShape:{resolve:"_resolveFull",cast:Tt.parseShape,value:"cross"},DotsVisible:{resolve:"_resolveFull",data:Mt("Dots"),cast:Boolean,value:!1},LinesVisible:{resolve:"_resolveFull",data:Mt("Lines"),cast:Boolean,value:!1},ValuesAnchor:{value:"right"},ValuesMask:{value:"{x},{y}"}}); e.type("pvc.visual.PiePlot",Tt.visual.Plot).add({type:"pie",collectDataCells:function(e){this.base(e);var t=this.option("DataPart");e.push(new Tt.visual.DataCell(this,"category",0,"category",t));e.push(new Tt.visual.DataCell(this,"angle",0,"value",t))},_getOptionsDefinition:function(){return Tt.visual.PiePlot.optionsDef}});Tt.visual.PiePlot.optionsDef=e.create(Tt.visual.Plot.optionsDef,{ActiveSliceRadius:{resolve:"_resolveFull",cast:Nt.parse,value:new Nt(.05)},ExplodedSliceRadius:{resolve:"_resolveFull",cast:Nt.parse,value:0},ExplodedSliceIndex:{resolve:"_resolveFull",cast:Tt.castNumber,value:null},ValuesAnchor:{cast:Tt.parseAnchorWedge,value:"outer"},ValuesVisible:{value:!0},ValuesLabelStyle:{resolve:function(e){var t=this.chart.compatVersion()<=1;if(t){e.specify("inside");return!0}return this._resolveFull(e)},cast:function(e){switch(e){case"inside":case"linked":return e}Tt.debug>=2&&Tt.log("[Warning] Invalid 'ValuesLabelStyle' value: '"+e+"'.");return"linked"},value:"linked"},ValuesMask:{resolve:"_resolveFull",data:{resolveDefault:function(e){e.defaultValue("linked"===this.option("ValuesLabelStyle")?"{value} ({value.percent})":"{value}"); return!0}}},LinkInsetRadius:{resolve:"_resolveFull",cast:Nt.parse,value:new Nt(.05)},LinkOutsetRadius:{resolve:"_resolveFull",cast:Nt.parse,value:new Nt(.025)},LinkMargin:{resolve:"_resolveFull",cast:Nt.parse,value:new Nt(.025)},LinkHandleWidth:{resolve:"_resolveFull",cast:Tt.castNumber,value:.5},LinkLabelSize:{resolve:"_resolveFull",cast:Nt.parse,value:new Nt(.15)},LinkLabelSpacingMin:{resolve:"_resolveFull",cast:Tt.castNumber,value:.5}});e.type("pvc.visual.HeatGridPlot",Tt.visual.CategoricalPlot).add({type:"heatGrid",collectDataCells:function(e){this.base(e);if(this.option("UseShapes")){var t=this.chart.visualRole(this.option("SizeRole"));t.isBound()&&e.push(new Tt.visual.DataCell(this,"size",this.option("SizeAxis")-1,t.name,this.option("DataPart")))}},_getOptionsDefinition:function(){return Tt.visual.HeatGridPlot.optionsDef}});Tt.visual.HeatGridPlot.optionsDef=e.create(Tt.visual.CategoricalPlot.optionsDef,{SizeRole:{value:"size"},SizeAxis:{value:1},UseShapes:{resolve:"_resolveFull",cast:Boolean,value:!1},Shape:{resolve:"_resolveFull",cast:Tt.parseShape,value:"square"},NullShape:{resolve:"_resolveFull",cast:Tt.parseShape,value:"cross"},ValuesVisible:{getDefault:function(){return!this.option("UseShapes") },value:null},ValuesMask:{value:null},ValuesAnchor:{value:"center"},OrthoRole:{value:"series"},OrthoAxis:{resolve:null},NullInterpolationMode:{resolve:null,value:"none"},Stacked:{resolve:null,value:!1}});e.type("pvc.visual.BoxPlot",Tt.visual.CategoricalPlot).add({type:"box",_getOptionsDefinition:function(){return Tt.visual.BoxPlot.optionsDef}});Tt.visual.BoxPlot.optionsDef=e.create(Tt.visual.CategoricalPlot.optionsDef,{Stacked:{resolve:null,value:!1},OrthoRole:{value:["median","lowerQuartil","upperQuartil","minimum","maximum"]},BoxSizeRatio:{resolve:"_resolveFull",cast:function(e){e=Tt.castNumber(e);null==e?e=1:.05>e?e=.05:e>1&&(e=1);return e},value:1/3},BoxSizeMax:{resolve:"_resolveFull",data:{resolveV1:function(e){this._specifyChartOption(e,"maxBoxSize");return!0}},cast:function(e){e=Tt.castNumber(e);null==e?e=1/0:1>e&&(e=1);return e},value:1/0}});e.type("pvc.visual.BulletPlot",Tt.visual.Plot).add({type:"bullet",_getOptionsDefinition:function(){return Tt.visual.BulletPlot.optionsDef}}); Tt.visual.BulletPlot.optionsDef=e.create(Tt.visual.Plot.optionsDef,{ValuesVisible:{value:!0},ColorRole:{value:null}});e.type("pvc.visual.TreemapPlot",Tt.visual.Plot).add({type:"treemap",_getOptionsDefinition:function(){return Tt.visual.TreemapPlot.optionsDef},collectDataCells:function(e){this.base(e);var t=this.option("SizeRole");t&&e.push(new Tt.visual.DataCell(this,"size",this.option("SizeAxis")-1,t,this.option("DataPart")))}});Tt.visual.TreemapPlot.optionsDef=e.create(Tt.visual.Plot.optionsDef,{SizeRole:{resolve:"_resolveFixed",value:"size"},SizeAxis:{resolve:"_resolveFixed",value:1},ValuesAnchor:{cast:Tt.parseAnchor,value:"center"},ValuesVisible:{value:!0},ValuesMask:{resolve:"_resolveFull",value:"{category}"},ValuesOptimizeLegibility:{value:!0},LayoutMode:{resolve:"_resolveFull",cast:Tt.parseTreemapLayoutMode,value:"squarify"},ColorMode:{resolve:"_resolveFull",cast:Tt.parseTreemapColorMode,value:"byparent"},RootCategoryLabel:{resolve:"_resolveFull",cast:String,value:"All"}});e.type("pvc.visual.SunburstPlot",Tt.visual.Plot).add({type:"sunburst",_getOptionsDefinition:function(){return Tt.visual.SunburstPlot.optionsDef },collectDataCells:function(e){this.base(e);var t=this.option("SizeRole");t&&e.push(new Tt.visual.DataCell(this,"size",this.option("SizeAxis")-1,t,this.option("DataPart")))}});Tt.visual.SunburstPlot.optionsDef=e.create(Tt.visual.Plot.optionsDef,{SizeRole:{resolve:"_resolveFixed",value:"size"},SizeAxis:{resolve:"_resolveFixed",value:1},ValuesAnchor:{cast:Tt.parseAnchor,value:"center"},ValuesVisible:{value:!0},ValuesMask:{resolve:"_resolveFull",value:"{category}"},ValuesOptimizeLegibility:{value:!0},RootCategoryLabel:{resolve:"_resolveFull",cast:String,value:"All"},SliceOrder:{resolve:"_resolveFull",cast:Tt.parseSunburstSliceOrder,value:"bySizeDescending"},EmptySlicesVisible:{resolve:"_resolveFull",cast:Boolean,value:!1},EmptySlicesLabel:{resolve:"_resolveFull",cast:String,value:""}});e.type("pvc.Abstract").init(function(){this._syncLog()}).add({invisibleLineWidth:.001,defaultLineWidth:1.5,_logInstanceId:null,_syncLog:function(){if(Tt.debug&&"undefined"!=typeof console){var e=this._getLogInstanceId(); ["log","info",["trace","debug"],"error","warn",["group","groupCollapsed"],"groupEnd"].forEach(function(t){t=t instanceof Array?t:[t,t];a(this,"_"+t[0],t[1],e)},this)}},_getLogInstanceId:function(){return this._logInstanceId||(this._logInstanceId=this._processLogInstanceId(this._createLogInstanceId()))},_createLogInstanceId:function(){return""+this.constructor},_processLogInstanceId:function(t){var i=30,n=t.substr(0,i);n.length=3&&this._info("NEW CHART\n"+Tt.logSeparator.replace(/-/g,"=")+"\n DebugLevel: "+Tt.debug);if(Tt.debug>=3&&!n&&i){this._info("OPTIONS:\n",i);Tt.debug>=5&&this._trace(Tt.stringify(t,{ownOnly:!1,funs:!0}))}n&&n._addChild(this);this._constructData(t);this._constructVisualRoles(t)}).add({_disposed:!1,_animatable:!1,parent:null,children:null,root:null,isCreated:!1,_createVersion:0,renderCallback:void 0,multiChartPageCount:null,multiChartPageIndex:null,_multiChartOverflowClipped:!1,left:0,top:0,width:null,height:null,margins:null,paddings:null,_allowV1SecondAxis:!1,compatVersion:function(e){return(e||this.options).compatVersion},_createLogInstanceId:function(){return""+this.constructor+this._createLogChildSuffix()},_createLogChildSuffix:function(){return this.parent?" ("+(this.smallRowIndex+1)+","+(this.smallColIndex+1)+")":""},_addChild:function(t){t.parent===this||e.assert("Not a child of this chart.");this.children.push(t)},_create:function(e){this._createPhase1(e);this._createPhase2(e) },_createPhase1:function(e){this._createVersion++;this.isCreated=!1;Tt.debug>=3&&this._log("Creating");this.children=[];this.parent||Tt.removeTipsyLegends();this._processOptions();this.parent||this._checkNoDataI();if(!this.parent&&!this.data){this._initVisualRoles();this._bindVisualRolesPreI();this._complexTypeProj=this._createComplexTypeProject();this._bindVisualRolesPreII()}this._initData(e);this.parent||this._checkNoDataII();var t=this.visualRoles.multiChart.isBound(),i=this._chartLevel();this._initPlots(t);this._initAxes(t);t&&!this.parent&&this._initMultiCharts();if(!this.parent){this._interpolate(t);this._generateTrends(t)}this._setAxesScales(i)},_createPhase2:function(){var e=this.visualRoles.multiChart.isBound();this._initChartPanels(e);this.isCreated=!0},_setSmallLayout:function(t){if(t){var i=this.basePanel;this._setProp("left",t)|this._setProp("top",t)&&i&&e.set(i.position,"left",this.left,"top",this.top);this._setProp("width",t)|this._setProp("height",t)&&i&&(i.size=new zt(this.width,this.height)); this._setProp("margins",t)&&i&&(i.margins=new Vt(this.margins));this._setProp("paddings",t)&&i&&(i.paddings=new Vt(this.paddings))}},_setProp:function(e,t){var i=t[e];if(null!=i){this[e]=i;return!0}},_processOptions:function(){var e=this.options;if(!this.parent){this.width=e.width;this.height=e.height;this.margins=e.margins;this.paddings=e.paddings}this.compatVersion()<=1&&(e.plot2=this._allowV1SecondAxis&&!!e.secondAxis);this._processOptionsCore(e);this._processExtensionPoints();return e},_processOptionsCore:function(e){if(this.parent){this._ibits=this.parent._ibits;this._tooltipOptions=this.parent._tooltipOptions}else{var i="batik"!==t.renderer();if(i){i=e.interactive;null==i&&(i=!0)}var n;if(i){var a=Tt.visual.Interactive;n=a.Interactive|a.ShowsInteraction;this._processTooltipOptions(e)&&(n|=a.ShowsTooltip);e.animate&&$.support.svg&&(n|=a.Animatable);var r=!1;if(e.selectable){n|=a.Selectable;switch(Tt.parseSelectionMode(e.selectionMode)){case"rubberband":n|=a.SelectableByRubberband|a.SelectableByClick; break;case"focuswindow":n|=a.SelectableByFocusWindow;r=!0}}r||"emptyspaceclick"!==Tt.parseClearSelectionMode(e.clearSelectionMode)||(n|=a.Unselectable);e.hoverable&&(n|=a.Hoverable);e.clickable&&(n|=a.Clickable|a.DoubleClickable)}else n=0;this._ibits=n}},_tooltipDefaults:{gravity:"s",delayIn:200,delayOut:80,offset:2,opacity:.9,html:!0,fade:!0,useCorners:!1,arrowVisible:!0,followMouse:!1,format:void 0},_processTooltipOptions:function(t){var i=this.compatVersion()<=1,n=t.tooltip,a=t.tooltipEnabled;if(null==a){n&&(a=n.enabled);if(null==a){i&&(a=t.showTooltips);null==a&&(a=!0)}}if(a){n||(n={});i&&this._importV1TooltipOptions(n,t);e.eachOwn(this._tooltipDefaults,function(i,a){var r=t["tooltip"+e.firstUpperCase(a)];void 0!==r?n[a]=r:void 0===n[a]&&(n[a]=i)})}else n={};this._tooltipOptions=n;return a},_importV1TooltipOptions:function(e,t){var i=t.tipsySettings;if(i){this.extend(i,"tooltip");for(var n in i)void 0===e[n]&&(e[n]=i[n]);null==e.html&&(e.html=!1)}},render:function(e,t,i){var n;Tt.debug>1&&Tt.group("CCC RENDER"); this._suspendSelectionUpdate();try{this.useTextMeasureCache(function(){try{for(;;){!this.isCreated||t?this._create({reloadData:i}):!this.parent&&this.isCreated&&Tt.removeTipsyLegends();this.basePanel.render({bypassAnimation:e,recreate:t});if(!this._isMultiChartOverflowClip){this._isMultiChartOverflowClipRetry=!1;break}t=!0;i=!1;this._isMultiChartOverflowClipRetry=!0;this._isMultiChartOverflowClip=!1;this._multiChartOverflowClipped=!0}}catch(a){if(a instanceof NoDataException){Tt.debug>1&&this._log("No data found.");this._addErrorPanelMessage("No data found",!0)}else{n=!0;Tt.logError(a.message);Tt.debug>0&&this._addErrorPanelMessage("Error: "+a.message,!1)}}})}finally{n||this._resumeSelectionUpdate();Tt.debug>1&&Tt.groupEnd()}return this},_addErrorPanelMessage:function(e,i){var n=this.options,a=(new t.Panel).canvas(n.canvas).width(this.width).height(this.height),r=a.anchor("center").add(t.Label).text(e);i&&this.extend(r,"noDataMessage");a.render()},useTextMeasureCache:function(e,i){var n=this.root,a=n._textMeasureCache||(n._textMeasureCache=t.Text.createCache()); return t.Text.usingCache(a,e,i||this)},animate:function(e,t){return this.basePanel.animate(e,t)},animatingStart:function(){return this.basePanel.animatingStart()},animatable:function(){return this._animatable&&this.base()},isOrientationVertical:function(e){return(e||this.options.orientation)===Tt.orientation.vertical},isOrientationHorizontal:function(e){return(e||this.options.orientation)===Tt.orientation.horizontal},dispose:function(){this._disposed||(this._disposed=!0)},defaults:{width:400,height:300,orientation:"vertical",ignoreNulls:!0,crosstabMode:!0,isMultiValued:!1,seriesInRows:!1,groupedLabelSep:void 0,animate:!0,titlePosition:"top",titleAlign:"center",legend:!1,legendPosition:"bottom",v1StyleTooltipFormat:function(e,t,i,n){return e+", "+t+": "+this.chart.options.valueFormat(i)+(n&&n.percent?" ("+n.percent.label+")":"")},valueFormat:e.scope(function(){var e=t.Format.number().fractionDigits(0,2);return function(t){return e.format(t)}}),percentValueFormat:e.scope(function(){var e=t.Format.number().fractionDigits(0,1); return function(t){return e.format(100*t)+"%"}}),clickable:!1,doubleClickMaxDelay:300,hoverable:!1,selectable:!1,selectionMode:"rubberband",ctrlSelectMode:!0,clearSelectionMode:"emptySpaceClick",compatVersion:1/0}});Tt.BaseChart.add({visualRoles:null,visualRoleList:null,_serRole:null,_dataPartRole:null,_measureVisualRoles:null,visualRole:function(t){var i=e.getOwn(this.visualRoles,t);if(!i)throw e.error.operationInvalid("roleName","There is no visual role with name '{0}'.",[t]);return i},measureVisualRoles:function(){return this._measureVisualRoles},measureDimensionsNames:function(){return e.query(this._measureVisualRoles).select(function(e){return e.firstDimensionName()}).where(e.notNully).array()},_constructVisualRoles:function(){var e=this.parent;if(e){this.visualRoles=e.visualRoles;this.visualRoleList=e.visualRoleList;this._measureVisualRoles=e._measureVisualRoles;["_multiChartRole","_serRole","_colorRole","_dataPartRole"].forEach(function(t){var i=e[t];i&&(this[t]=i)},this)}else{this.visualRoles={}; this.visualRoleList=[];this._measureVisualRoles=[]}},_hasDataPartRole:e.fun.constant(!1),_getSeriesRoleSpec:e.fun.constant(null),_getColorRoleSpec:e.fun.constant(null),_addVisualRole:function(t,i){i=e.set(i,"index",this.visualRoleList.length);var n=new Tt.visual.Role(t,i);this.visualRoleList.push(n);this.visualRoles[t]=n;n.isMeasure&&this._measureVisualRoles.push(n);return n},_initVisualRoles:function(){this._multiChartRole=this._addVisualRole("multiChart",{defaultDimension:"multiChart*",requireIsDiscrete:!0});this._hasDataPartRole()&&(this._dataPartRole=this._addVisualRole("dataPart",{defaultDimension:"dataPart",requireSingleDimension:!0,requireIsDiscrete:!0,dimensionDefaults:{isHidden:!0,comparer:e.compare}}));var t=this._getSeriesRoleSpec();t&&(this._serRole=this._addVisualRole("series",t));var i=this._getColorRoleSpec();i&&(this._colorRole=this._addVisualRole("color",i))},_assertUnboundRoleIsOptional:function(t){if(t.isRequired)throw e.error.operationInvalid("Chart type requires unassigned role '{0}'.",[t.name]) },_bindVisualRolesPreI:function(){e.eachOwn(this.visualRoles,function(e){e.setIsReversed(!1)});var t=[],i=this.options,n=i.visualRoles;this.visualRoleList.forEach(function(e){var t=e.name,a=i[t+"Role"];if(void 0!==a){n||(n=i.visualRoles={});void 0===n[t]&&(n[t]=a)}});var a;if(n){a={};var r=e.query(e.keys(n)).select(this.visualRole,this).array();r.sort(function(e,t){return e.index-t.index});r.forEach(function(i){var r,s,o=i.name,l=n[o];if(e.object.is(l)){e.nullyTo(l.isReversed,!1)&&i.setIsReversed(!0);s=l.from;if(s&&s!==o){var u=this.visualRoles[s]||e.fail.operationInvalid("Source role '{0}' is not supported by the chart type.",[s]);i.setSourceRole(u);t.push(i)}else r=l.dimensions}else r=l;if(void 0!==r){r||this._assertUnboundRoleIsOptional(i);var c=Tt.data.GroupingSpec.parse(r);i.preBind(c);c.dimensions().each(function(t){e.hasOwn(a,t.name)?delete a[t.name]:a[t.name]=i})}},this)}this._sourcedRoles=t;this._dimsBoundToSingleRole=a},_bindVisualRolesPreII:function(){var t=this._dimsBoundToSingleRole; if(t){delete this._dimsBoundToSingleRole;e.eachOwn(t,this._setRoleBoundDimensionDefaults,this)}var i=this._sourcedRoles;delete this._sourcedRoles;e.query(this.visualRoleList).where(function(e){return e.defaultSourceRoleName&&!e.sourceRole&&!e.isPreBound()}).each(function(e){var t=this.visualRoles[e.defaultSourceRoleName];if(t){e.setSourceRole(t,!0);i.push(e)}},this);i.forEach(function(e){var t=e.sourceRole;t.isReversed&&e.setIsReversed(!e.isReversed);!e.defaultDimensionName&&t.isPreBound()&&e.preBind(t.preBoundGrouping())})},_setRoleBoundDimensionDefaults:function(e,t){this._complexTypeProj.setDimDefaults(t,e.dimensionDefaults)},_bindVisualRolesPostI:function(){function t(t,i){e.array.lazy(d,t).push(i)}function i(e){return h.hasDim(e)}function n(i,n){e.array.is(n)?n.forEach(function(e){t(e,i)}):t(n,i);i.setSourceRole(null);i.preBind(Tt.data.GroupingSpec.parse(n))}function a(e,t){t.length&&(e.requireSingleDimension?n(e,t[0]):n(e,t))}function r(e,t){h.setDim(t,{isHidden:!0});n(e,t)}function s(e){c._assertUnboundRoleIsOptional(e); e.bind(null);e.setSourceRole(null)}function o(e){e.preBoundGrouping().dimensionNames().forEach(t)}function l(t){if(!t.sourceRole||t.isDefaultSourceRole){var o=t.defaultDimensionName;if(o){var l=o.match(/^(.*?)(\*)?$/)||e.fail.argumentInvalid("defaultDimensionName"),u=l[1],c=l[2];if(c){var d=h.groupDimensionsNames(u);if(d){a(t,d);return}}else if(i(u)){n(t,u);return}t.autoCreateDimension?r(t,u):t.sourceRole?f.push(t):s(t)}else t.sourceRole?f.push(t):s(t)}else f.push(t)}function u(e){var t=e.sourceRole;t.isPreBound()?e.preBind(t.preBoundGrouping()):s(e)}var c=this,h=c._complexTypeProj,d={},f=[];e.query(c.visualRoleList).where(function(e){return e.isPreBound()}).each(o);e.query(c.visualRoleList).where(function(e){return!e.isPreBound()}).each(l);f.forEach(u);e.query(e.ownKeys(d)).where(function(e){return 1===d[e].length}).each(function(e){var t=d[e][0];c._setRoleBoundDimensionDefaults(t,e)})},_bindVisualRolesPostII:function(t){e.query(this.visualRoleList).where(function(e){return e.isPreBound() }).each(function(e){e.postBind(t)})},_logVisualRoles:function(){var t=e.ownKeys(this.visualRoles),i=Math.max(10,e.query(t).select(function(e){return e.length}).max()),n=e.string.padRight("VisualRole",i)+" < Dimension(s)",a=["VISUAL ROLES MAP SUMMARY",Tt.logSeparator,n,e.string.padRight("",i+1,"-")+"+--------------"];e.eachOwn(this.visualRoles,function(t,n){a.push(e.string.padRight(n,i)+" | "+(t.grouping||"-"))});a.push("");this._log(a.join("\n"))},_getDataPartDimName:function(){var e=this._dataPartRole;if(e){if(e.isBound())return e.firstDimensionName();var t=e.preBoundGrouping();return t?t.firstDimensionName():e.defaultDimensionName}}});Tt.BaseChart.add({dataEngine:null,data:null,_partsDataCache:null,_visibleDataCache:null,resultset:[],metadata:[],_trendable:!1,_interpolatable:!1,_constructData:function(t){this.parent&&(this.dataEngine=this.data=t.data||e.fail.argumentRequired("options.data"))},_checkNoDataI:function(){if(!this.allowNoData&&!this.resultset.length)throw new NoDataException },_checkNoDataII:function(){if(!(this.allowNoData||this.data&&this.data.count())){this.data=null;throw new NoDataException}},_initData:function(t){if(!this.parent){var i=this.data;if(i)if(e.get(t,"reloadData",!0))this._onReloadData();else{i.disposeChildren();i.clearVirtuals()}else this._onLoadData()}delete this._partsDataCache;delete this._visibleDataCache;Tt.debug>=3&&this._log(this.data.getInfo())},_onLoadData:function(){var t=this.data,i=this._translation;!t&&!i||e.assert("Invalid state.");var n=this.options,a=this._getDataPartDimName(),r=this._complexTypeProj||e.assert("Invalid state."),s=this._createTranslationOptions(a);i=this._translation=this._createTranslation(s);if(Tt.debug>=3){this._log(i.logSource());this._log(i.logTranslatorType())}i.configureType();a&&!r.isReadOrCalc(a)&&this._addDefaultDataPartCalculation(a);Tt.debug>=3&&this._log(i.logVItem());this._bindVisualRolesPostI();var o=new Tt.data.ComplexType;r.configureComplexType(o,s);this._bindVisualRolesPostII(o);Tt.debug>=10&&this._log(o.describe()); Tt.debug>=3&&this._logVisualRoles();t=this.dataEngine=this.data=new Tt.data.Data({type:o,labelSep:n.groupedLabelSep,keySep:s.separator});var l={where:this._getLoadFilter(),isNull:this._getIsNullDatum()},u=i.execute(t);t.load(u,l)},_onReloadData:function(){var t=this.data,i=this._translation;t&&i||e.assert("Invalid state.");this.options;i.setSource(this.resultset);Tt.debug>=3&&this._log(i.logSource());var n={where:this._getLoadFilter(),isNull:this._getIsNullDatum()},a=i.execute(t);t.load(a,n)},_createComplexTypeProject:function(){var e=this.options,t=new Tt.data.ComplexTypeProject(e.dimensionGroups),i=e.dimensions;for(var n in i)t.setDim(n,i[n]);var a=this._getDataPartDimName();if(a){t.setDim(a);this._addPlot2SeriesDataPartCalculation(t,a)}var r=e.calculations;r&&r.forEach(function(e){t.setCalc(e)});return t},_getLoadFilter:function(){},_getIsNullDatum:function(){var e=this.measureDimensionsNames(),t=e.length;return t?function(i){for(var n=i.atoms,a=0;t>a;a++)if(null!=n[e[a]].value)return!1; return!0}:void 0},_createTranslation:function(e){var t=this._getTranslationClass(e);return new t(this,this._complexTypeProj,this.resultset,this.metadata,e)},_getTranslationClass:function(e){return e.crosstabMode?Tt.data.CrosstabTranslationOper:Tt.data.RelationalTranslationOper},_createTranslationOptions:function(t){var i=this.options,n=i.dataOptions||{},a=i.dataSeparator;void 0===a&&(a=n.separator);a||(a="~");var r=i.dataMeasuresInColumns;void 0===r&&(r=n.measuresInColumns);var s=i.dataCategoriesCount;void 0===s&&(s=n.categoriesCount);var o=i.dataIgnoreMetadataLabels;void 0===o&&(o=n.ignoreMetadataLabels);var l,u=i.plot2,c=i.valueFormat;c&&c!==this.defaults.valueFormat&&(l=function(e){return null!=e?c(e):""});var h,d;if(u){if(this._allowV1SecondAxis&&this.compatVersion()<=1)d=i.secondAxisIdx;else{h=null!=this._serRole&&i.plot2Series&&e.array.as(i.plot2Series);if(!h||!h.length){h=null;d=i.plot2SeriesIndexes}}h||(d=Tt.parseDistinctIndexArray(d,-1/0)||-1)}return{compatVersion:this.compatVersion(),plot2DataSeriesIndexes:d,seriesInRows:i.seriesInRows,crosstabMode:i.crosstabMode,isMultiValued:i.isMultiValued,dataPartDimName:t,dimensionGroups:i.dimensionGroups,dimensions:i.dimensions,readers:i.readers,measuresIndexes:i.measuresIndexes,multiChartIndexes:i.multiChartIndexes,separator:a,measuresInColumns:r,categoriesCount:s,measuresIndex:n.measuresIndex||n.measuresIdx,measuresCount:n.measuresCount||n.numMeasures,isCategoryTimeSeries:i.timeSeries,timeSeriesFormat:i.timeSeriesFormat,valueNumberFormatter:l,ignoreMetadataLabels:o} },_addPlot2SeriesDataPartCalculation:function(t,i){if(!(this.compatVersion()<=1)){var n=this.options,a=this._serRole,r=null!=a&&n.plot2&&n.plot2Series&&e.array.as(n.plot2Series);if(r&&r.length){var s,o,l,u,c=!1,h=e.query(r).uniqueIndex();t.setCalc({names:i,calculation:function(t,n){if(!c){if(a.isBound()){s=a.grouping.dimensionNames();o=t.owner.dimensions(i)}c=!0}if(o){var r=Tt.data.Complex.compositeKey(t,s);n[i]=e.hasOwnProp.call(h,r)?u||(u=o.intern("1")):l||(l=o.intern("0"))}}})}}},_addDefaultDataPartCalculation:function(e){var t,i;this._complexTypeProj.setCalc({names:e,calculation:function(n,a){t||(t=n.owner.dimensions(e));a[e]=i||(i=t.intern("0"))}})},partData:function(t,i){i||(i=this.data);if(null==t)return i;if(this.parent)return this.root.partData(t,i);var n=this._dataPartRole;if(!n||!n.isBound())return i;var a="\x00"+i.id+":"+e.nullyTo(t,""),r=e.lazy(this,"_partsDataCache"),s=r[a];if(!s){s=this._createPartData(i,n,t);r[a]=s}return s},_createPartData:function(t,i,n){var a=i.firstDimensionName(),r=t.dimensions(a).getDistinctAtoms(e.array.to(n)),s=ot([e.set({},a,r)]); return t.where(null,{where:s})},visibleData:function(t,i){var n=e.get(i,"baseData")||this.data;if(this.parent){i=i?Object.create(i):{};i.baseData=n;return this.root.visibleData(t,i)}var a=!!e.get(i,"inverted",!1),r=!(!this.options.ignoreNulls&&!e.get(i,"ignoreNulls",!0)),s="\x00"+n.id+"|"+a+"|"+r+"|"+(null!=t?t:null),o=e.lazy(this,"_visibleDataCache"),l=o[s];if(!l){var u=this.partData(t,n);i=i?Object.create(i):{};i.visible=!0;i.isNull=r?!1:null;l=o[s]=this._createVisibleData(u,i)}return l},_createVisibleData:function(e,t){var i=this._serRole;return i&&i.isBound()?i.flatten(e,t):e.where(null,t)},_initMultiCharts:function(){var t=this;t.multiOptions=new Tt.visual.MultiChart(t);t.smallOptions=new Tt.visual.SmallChart(t);var i,n,a,r,s=t.multiOptions.option,o=t.visualRoles.multiChart.flatten(t.data,{visible:!0,isNull:null}),l=o.childNodes;if(t._isMultiChartOverflowClipRetry){n=t._clippedMultiChartRowsMax;i=t._clippedMultiChartColsMax;r=i;a=n*i}else a=s("Max");var u=Math.min(l.length,a);if(0===u)i=n=r=0; else if(!t._isMultiChartOverflowClipRetry){r=s("ColumnsMax");i=Math.min(u,r);i>=1&&isFinite(i)||e.assert("Must be at least 1 and finite");n=Math.ceil(u/i);n>=1||e.assert("Must be at least 1")}t._multiInfo={data:o,smallDatas:l,count:u,rowCount:n,colCount:i,colsMax:r}},_interpolate:function(t){if(this._interpolatable){var i=e.query(this.axesList).selectMany(e.propGet("dataCells")).where(function(e){var t=e.nullInterpolationMode;return!!t&&"none"!==t}).distinct(function(e){return e.role.name+"|"+(e.dataPartValue||"")}).array();this._eachLeafDatasAndDataCells(t,i,this._interpolateDataCell,this)}},_generateTrends:function(t){var i=this._getDataPartDimName();if(this._trendable&&i){var n=e.query(this.axesList).selectMany(e.propGet("dataCells")).where(e.propGet("trend")).distinct(function(e){return e.role.name+"|"+(e.dataPartValue||"")}).array(),a=[];this._eachLeafDatasAndDataCells(t,n,function(e,t){this._generateTrendsDataCell(a,e,t)},this);a.length&&this.data.owner.add(a)}},_eachLeafDatasAndDataCells:function(e,t,i,n){var a=t.length; if(a){var r,s;if(e){r=this._multiInfo.smallDatas;s=this._multiInfo.count}else{r=[this.data];s=1}for(var o=0;s>o;o++)for(var l=r[o],u=0;a>u;u++)i.call(n,t[u],l,u,o)}},_interpolateDataCell:function(){},_generateTrendsDataCell:function(){},_getTrendDataPartAtom:function(){var e=this._getDataPartDimName();return e?this.data.owner.dimensions(e).intern("trend"):void 0},setData:function(e,t){this.setResultset(e&&e.resultset);this.setMetadata(e&&e.metadata);$.extend(this.options,t);return this},setResultset:function(t){!this.parent||e.fail.operationInvalid("Can only set resultset on root chart.");this.resultset=t||[];this.resultset.length||this._warn("Resultset is empty");return this},setMetadata:function(t){!this.parent||e.fail.operationInvalid("Can only set metadata on root chart.");this.metadata=t||[];this.metadata.length||this._warn("Metadata is empty");return this}});Tt.BaseChart.add({_initPlots:function(e){this.plotPanelList=null;if(this.parent){var t=this.root;this.plots=t.plots;this.plotList=t.plotList; this.plotsByType=t.plotsByType}else{this.plots={};this.plotList=[];this.plotsByType={};this._initPlotsCore(e)}},_initPlotsCore:function(){},_addPlot:function(t){var i=this.plotsByType,n=this.plots,a=t.type,r=t.index,s=t.name,o=t.id;if(s&&e.hasOwn(n,s))throw e.error.operationInvalid("Plot name '{0}' already taken.",[s]);if(e.hasOwn(n,o))throw e.error.operationInvalid("Plot id '{0}' already taken.",[o]);var l=e.array.lazy(i,a);if(e.hasOwn(l,r))throw e.error.operationInvalid("Plot index '{0}' of type '{1}' already taken.",[r,a]);t.globalIndex=this.plotList.length;l[r]=t;this.plotList.push(t);n[o]=t;s&&(n[s]=t)},_collectPlotAxesDataCells:function(t,i){var n=[];t.collectDataCells(n);n.length&&e.query(n).where(function(e){return e.role.isBound()}).each(function(t){var n=e.array.lazy(i,t.axisType);e.array.lazy(n,t.axisIndex).push(t)})},_addPlotPanel:function(t){e.lazy(this,"plotPanels")[t.plot.id]=t;e.array.lazy(this,"plotPanelList").push(t)},_createPlotPanels:function(){throw e.error.notImplemented() }});Tt.BaseChart.add({colors:null,axes:null,axesList:null,axesByType:null,_axisClassByType:{color:Tt.visual.ColorAxis,size:Tt.visual.SizeAxis,base:Zt,ortho:Zt},_axisCreateChartLevel:{color:1,size:2,base:3,ortho:3},_axisSetScaleChartLevel:{color:1,size:2,base:2,ortho:2},_axisCreationOrder:["color","size","base","ortho"],_axisCreateIfUnbound:{},_chartLevel:function(){var e=0;this.parent||(e|=1);(this.parent||!this.visualRoles.multiChart.isBound())&&(e|=2);return e},_initAxes:function(){this.axes={};this.axesList=[];this.axesByType={};delete this._rolesColorScale;var t;if(this.parent)t=this.root._dataCellsByAxisTypeThenIndex;else{t={};this.plotList.forEach(function(e){this._collectPlotAxesDataCells(e,t)},this);this._dataCellsByAxisTypeThenIndex=t}var i=this._chartLevel();this._axisCreationOrder.forEach(function(e){if(0!==(this._axisCreateChartLevel[e]&i)){var n,a=t[e];if(a){n=this._axisClassByType[e];n&&a.forEach(function(t,i){new n(this,e,i)},this)}else if(this._axisCreateIfUnbound[e]){n=this._axisClassByType[e]; n&&new n(this,e,0)}}},this);this.parent&&this.root.axesList.forEach(function(t){e.hasOwn(this.axes,t.id)||this._addAxis(t)},this);e.eachOwn(t,function(e,t){this._axisCreateChartLevel[t]&i&&e.forEach(function(e,i){var n=this.axes[Tt.buildIndexedId(t,i)];n.isBound()||n.bind(e)},this)},this)},_addAxis:function(t){this.axes[t.id]=t;t.chart===this&&(t.axisIndex=this.axesList.length);this.axesList.push(t);var i=e.array.lazy(this.axesByType,t.type),n=i.count||0;t.typeIndex=n;i[t.index]=t;n||(i.first=t);i.count=n+1;"color"===t.type&&t.isBound()&&this._onColorAxisScaleSet(t);return this},_getAxis:function(e,t){var i=this.axesByType[e];return i&&null!=t&&+t>=0?i[t]:void 0},_setAxesScales:function(e){this.axesList.forEach(function(t){this._axisSetScaleChartLevel[t.type]&e&&t.isBound()&&this._setAxisScale(t,e)},this)},_setAxisScale:function(e,t){this._setAxisScaleByScaleType(e,t)},_setAxisScaleByScaleType:function(t,i){switch(t.scaleType){case"discrete":this._setDiscreteAxisScale(t,i);break;case"numeric":this._setNumericAxisScale(t,i); break;case"timeSeries":this._setTimeSeriesAxisScale(t,i);break;default:throw e.error("Unknown axis scale type.")}},_describeScale:function(t,i){i.isNull&&Tt.debug>=3&&this._log(e.format("{0} scale for axis '{1}'- no data",[t.scaleType,t.id]))},_setDiscreteAxisScale:function(e){if("color"!==e.type){var i=e.domainValues(),n=new t.Scale.ordinal;i.length?n.domain(i):n.isNull=!0;this._describeScale(e,n);e.setScale(n)}else this._setDiscreteColorAxisScale(e)},_setTimeSeriesAxisScale:function(e){var i=this._getContinuousVisibleExtentConstrained(e),n=new t.Scale.linear;if(i){var a=i.min,r=i.max,s=1,o=function(){var e=r-a;if(e&&Math.abs(e)e&&(!i.maxLocked||i.minLocked?r=new Date(a.getTime()+Tt.time.intervals.h):a=new Date(r.getTime()-Tt.time.intervals.h));else{i.minLocked||(a=new Date(a.getTime()-Tt.time.intervals.h));(!i.maxLocked||i.minLocked)&&(r=new Date(r.getTime()+Tt.time.intervals.h))}};o();n.domain(a,r);n.minLocked=i.minLocked;n.maxLocked=i.maxLocked }else n.isNull=!0;this._describeScale(e,n);e.setScale(n)},_setNumericAxisScale:function(e){if("color"!==e.type){var i=this._getContinuousVisibleExtentConstrained(e),n=new t.Scale.linear;if(i){var a=i.min,r=i.max,s=1e-10,o=function(){var e=r-a;if(e&&Math.abs(e)<=s){a=(a+r)/2;a=r=+a.toFixed(10);e=0}if(e)0>e&&(!i.maxLocked||i.minLocked?r=Math.abs(a)>s?1.01*a:.1:a=Math.abs(r)>s?.99*r:-.1);else{i.minLocked||(a=Math.abs(a)>s?.99*a:-.1);(!i.maxLocked||i.minLocked)&&(r=Math.abs(r)>s?1.01*r:.1)}};o();var l=e.option.isDefined("OriginIsZero")&&e.option("OriginIsZero");if(l)if(0===a)i.minLocked=!0;else if(0===r)i.maxLocked=!0;else if(a*r>0){if(a>0){if(!i.minLocked){i.minLocked=!0;a=0}}else if(!i.maxLocked){i.maxLocked=!0;r=0}o()}n.domain(a,r);n.minLocked=i.minLocked;n.maxLocked=i.maxLocked}else n.isNull=!0;this._describeScale(e,n);e.setScale(n)}else this._setNumericColorAxisScale(e)},_warnSingleContinuousValueRole:function(t){t.grouping.isSingleDimension||this._warn("A linear scale can only be obtained for a single dimension role."); t.grouping.isDiscrete()&&this._warn(e.format("The single dimension of role '{0}' should be continuous.",[t.name]))},_getContinuousVisibleExtentConstrained:function(e,t,i){var n,a=function(){return n||(n=this.data.owner.dimensions(e.role.grouping.firstDimensionName()))},r=!1,s=!1;if(null==t&&e.option.isDefined("FixedMin")){t=e.option("FixedMin");null!=t&&(t=a.call(this).read(t));r=null!=t;if(r){t=t.value;0>t&&e.scaleUsesAbs()&&(t=-t)}}if(null==i&&e.option.isDefined("FixedMax")){i=e.option("FixedMax");null!=i&&(i=a.call(this).read(i));s=null!=i;if(s){i=i.value;0>i&&e.scaleUsesAbs()&&(i=-i)}}if(null==t||null==i){var o=this._getContinuousVisibleExtent(e);if(!o)return null;null==t&&(t=o.min);null==i&&(i=o.max)}return{min:t,max:i,minLocked:r,maxLocked:s}},_getContinuousVisibleExtent:function(t){var i=t.dataCells;return 1===i.length?this._getContinuousVisibleCellExtent(t,i[0]):e.query(i).select(function(e){return this._getContinuousVisibleCellExtent(t,e)},this).reduce(Tt.unionExtents,null)},_getContinuousVisibleCellExtent:function(t,i){var n=i.role; this._warnSingleContinuousValueRole(n);if("series"===n.name)throw e.error.notImplemented();var a=t.scaleSumNormalized(),r=this.visibleData(i.dataPartValue),s=n.firstDimensionName();if(a){var o=r.dimensionsSumAbs(s);if(o)return{min:0,max:o}}else{var l=t.scaleUsesAbs(),u=r.dimensions(s).extent({abs:l});if(u){var c=u.min.value,h=u.max.value;return{min:l?Math.abs(c):c,max:l?Math.abs(h):h}}}},_setDiscreteColorAxisScale:function(e){var t=e.domainValues(),i=e.scheme()(t);this._describeScale(e,i);e.setScale(i,!0);this._onColorAxisScaleSet(e)},_setNumericColorAxisScale:function(t){if(1!==t.dataCells.length)throw e.error("Can't handle multiple continuous datacells in color axis.");this._warnSingleContinuousValueRole(t.role);var i=this.visibleData(t.dataCell.dataPartValue),n=t.option("NormByCategory"),a={type:t.option("ScaleType"),colors:t.option("Colors")().range(),colorDomain:t.option("Domain"),colorMin:t.option("Min"),colorMax:t.option("Max"),colorMissing:t.option("Missing"),data:i,colorDimension:t.role.firstDimensionName(),normPerBaseCategory:n}; if(n)t.scalesByCateg=o(a);else{var r=l(a);this._describeScale(t,r);t.setScale(r)}this._onColorAxisScaleSet(t)},_onColorAxisScaleSet:function(e){switch(e.index){case 0:this.colors=e.scheme();break;case 1:this._allowV1SecondAxis&&(this.secondAxisColor=e.scheme())}},_getRoleColorScale:function(t){return e.lazy(e.lazy(this,"_rolesColorScale"),t,this._createRoleColorScale,this)},_createRoleColorScale:function(t){function i(t){var i=""+t;e.hasOwnProp.call(r,i)||(r[i]=a(t))}var n,a,r={};this.axesByType.color.forEach(function(e){var r=e.role,s=r.name===t||r.sourceRole&&r.sourceRole.name===t;if(s&&e.scale&&(0===e.index||e.option.isSpecified("Colors")||e.option.isSpecified("Map"))){a=e.scale;n||(n=a);e.domainValues().forEach(i)}},this);if(!n)return Tt.createColorScheme()();a=function(t){var i=""+t;if(e.hasOwnProp.call(r,i))return r[i];var a=n(t);r[i]=a;return a};e.copy(a,n);return a},_onLaidOut:function(){}});Tt.BaseChart.add({basePanel:null,titlePanel:null,legendPanel:null,_multiChartPanel:null,_initChartPanels:function(e){this._initBasePanel(); this._initTitlePanel();var t=this._initLegendPanel(),i=e&&!this.parent;i&&this._initMultiChartPanel();t&&this._initLegendScenes(t);if(!i){var n=this.options;this._createContent({margins:e?n.smallContentMargins:n.contentMargins,paddings:e?n.smallContentPaddings:n.contentPaddings,clickAction:n.clickAction,doubleClickAction:n.doubleClickAction})}},_createContent:function(){},_initBasePanel:function(){var e=this.parent;this.basePanel=new Tt.BasePanel(this,e&&e._multiChartPanel,{margins:this.margins,paddings:this.paddings,size:{width:this.width,height:this.height}})},_initTitlePanel:function(){var t=this,i=t.options,n=i.title;if(!e.empty(n)){{!t.parent}this.titlePanel=new Tt.TitlePanel(t,t.basePanel,{title:n,font:i.titleFont,anchor:i.titlePosition,align:i.titleAlign,alignTo:i.titleAlignTo,offset:i.titleOffset,keepInBounds:i.titleKeepInBounds,margins:i.titleMargins,paddings:i.titlePaddings,titleSize:i.titleSize,titleSizeMax:i.titleSizeMax})}},_initLegendPanel:function(){var t=this.options;if(t.legend){var i=new Tt.visual.Legend(this,"legend",0); return this.legendPanel=new Tt.LegendPanel(this,this.basePanel,{anchor:i.option("Position"),align:i.option("Align"),alignTo:t.legendAlignTo,offset:t.legendOffset,keepInBounds:t.legendKeepInBounds,size:i.option("Size"),sizeMax:i.option("SizeMax"),margins:i.option("Margins"),paddings:i.option("Paddings"),font:i.option("Font"),scenes:e.getPath(t,"legend.scenes"),textMargin:t.legendTextMargin,itemPadding:t.legendItemPadding,itemSize:i.option("ItemSize"),markerSize:t.legendMarkerSize})}},_getLegendBulletRootScene:function(){return this.legendPanel&&this.legendPanel._getBulletRootScene()},_initMultiChartPanel:function(){var e=this.basePanel,t=this.options;this._multiChartPanel=new Tt.MultiChartPanel(this,e,{margins:t.contentMargins,paddings:t.contentPaddings});this._multiChartPanel.createSmallCharts();e._children.unshift(e._children.pop())},_coordinateSmallChartsLayout:function(){},_initLegendScenes:function(t){var i=this.axesByType.color;if(i){var n,a,r,s=0,o=this,l=function(e,t){if("togglevisible"===e.option("LegendClickMode")){if(void 0===n){n=o._getTrendDataPartAtom()||null; n&&(a=n.dimension.name)}if(n&&t.firstAtoms()[a]===n)return"none"}},u=function(){return r||(rootScene=t._getBulletRootScene())};e.query(i).where(function(e){return e.option("LegendVisible")&&e.isBound()&&e.isDiscrete()}).each(function(e){for(var t=e.scale,i=-1,n=e.dataCells,a=n.length;++i0&&(--this._updateSelectionSuspendCount||this.updateSelections()):this.root._resumeSelectionUpdate() },updateSelections:function(t){if(this===this.root){if(this._inUpdateSelections||this._updateSelectionSuspendCount)return this;var i=this._calcSelectedChangedDatums();if(!i)return this;Tt.removeTipsyLegends();this._inUpdateSelections=!0;try{var n=this.options.selectionChangedAction;if(n){var a=this.data.selectedDatums(),r=i.values();n.call(this.basePanel.context(),a,r)}e.get(t,"render",!0)&&this.useTextMeasureCache(function(){this.basePanel.renderInteractive()},this)}finally{this._inUpdateSelections=!1}}else this.root.updateSelections();return this},_calcSelectedChangedDatums:function(){if(this.data){var e,t=this.data.selectedDatumMap(),i=this._lastSelectedDatums;if(i){e=i.symmetricDifference(t);if(!e.count)return}else{if(!t.count)return;e=t.clone()}this._lastSelectedDatums=t;return e}},_onUserSelection:function(e){if(!e||!e.length)return e;if(this===this.root){var t=this.options.userSelectionAction;return t?t.call(this.basePanel.context(),e)||e:e}return this.root._onUserSelection(e)}}); Tt.BaseChart.add({_processExtensionPoints:function(){var t;if(this.parent)t=this.parent._components;else{var i=this.options.extensionPoints;t={};if(i)for(var n in i){var a,r,s=n.indexOf("_");if(s>0){a=n.substring(0,s);r=n.substr(s+1);if(a&&r){var o=e.getOwn(t,a)||(t[a]=new e.OrderedMap);o.add(r,i[n])}}}}this._components=t},extend:function(t,i,n){e.array.is(i)?i.forEach(function(e){this._extendCore(t,e,n)},this):this._extendCore(t,i,n)},_extendCore:function(t,i,n){if(t){var a=e.getOwn(this._components,i);if(a){t.borderPanel&&(t=t.borderPanel);var r=Tt.debug>=3?[]:null,s=e.get(n,"constOnly",!1),o=t.wrap,l={tag:Tt.extensionTag},u=t instanceof At,c=u&&(o||s),h=function(i,n){if(null!=i){var a=typeof i;if("object"===a){if("svg"===n||"css"===n){var r=t.propertyValue(n);r&&(i=e.copy(r,i))}else if(i instanceof Array)return i.map(function(e){return h(e,n)})}else if(c&&"function"===a){if(s)return;"add"!==n&&"call"!==n&&(i=o.call(t,i,n))}}return i},d=function(e,i){i instanceof Array?e.apply(t,i):e.call(t,i) };a.forEach(function(e,i){if(t.isLocked&&t.isLocked(i))r&&r.push(i+": locked extension point!");else if(t.isIntercepted&&t.isIntercepted(i))r&&r.push(i+":"+Tt.stringify(e)+" (controlled)");else{r&&r.push(i+": "+Tt.stringify(e));e=h(e,i);if(void 0!==e){var n=t[i];"function"==typeof n?u&&t.properties[i]?t.intercept(i,e,l):e instanceof Array?e.forEach(function(e){d(n,e)}):d(n,e):t[i]=e}}});r&&(r.length?this._log("Applying Extension Points for: '"+i+"'\n * "+r.join("\n * ")):Tt.debug>=5&&this._log("No Extension Points for: '"+i+"'"))}}else Tt.debug>=4&&this._log("Applying Extension Points for: '"+i+"' (target mark does not exist)")},_getExtension:function(t,i){var n;if(e.array.is(t))for(var a,r=t.length-1;r>=0;){n=e.getOwn(this._components,t[r--]);if(n&&void 0!==(a=n.get(i)))return a}else{n=e.getOwn(this._components,t);if(n)return n.get(i)}},_getComponentExtensions:function(t){return e.getOwn(this._components,t)},_getConstantExtension:function(t,i){var n=this._getExtension(t,i);return e.fun.is(n)?void 0:n }});e.type("pvc.BasePanel",Tt.Abstract).add(Tt.visual.Interactive).init(function(t,i,n){this.chart=t;this.base();this.axes=Object.create(t.axes);if(n){if(n.scenes){this._sceneTypeExtensions=n.scenes;delete n.scenes}var a=n.axes;if(a){e.copy(this.axes,a);delete n.axes}}$.extend(this,n);this.axes.color||(this.axes.color=t.axes.color);this.position={};var r=n&&n.margins;i||void 0!==r||(r=3);this.margins=new Vt(r);this.paddings=new Vt(n&&n.paddings);this.size=new zt(n&&n.size);this.sizeMax=new zt(n&&n.sizeMax);if(i){this.parent=i;this.isTopRoot=!1;this.isRoot=i.chart!==t;this.root=this.isRoot?this:i.root;this.topRoot=i.topRoot;this._ibits=i._ibits;if(this.isRoot){this.position.left=t.left;this.position.top=t.top}i._addChild(this)}else{this.parent=null;this.root=this;this.topRoot=this;this.isRoot=!0;this.isTopRoot=!0;this._ibits=t._ibits}this.data=(this.isRoot?t:i).data;if(this.isRoot){this.anchor=null;this.align=null;this.alignTo=null;this.offset=null}else{this.align=Tt.parseAlign(this.anchor,this.align); var s=this.alignTo,o=this.anchor;null==s||""===s||"left"!==o&&"right"!==o?s=this.align:"page-middle"!==s&&(s=isNaN(+s.charAt(0))?Tt.parseAlign(o,s):Nt.parse(s));this.alignTo=s;this.offset=new Ft(this.offset)}if(null==this.borderWidth){var l,u=this._getExtensionId();if(u){var c=this._getExtension(u,"strokeStyle");if(null!=c){l=+this._getConstantExtension(u,"lineWidth");(isNaN(l)||!isFinite(l))&&(l=null)}}this.borderWidth=null==l?0:1.5}var h=Tt.visual.Interactive,d=this._ibits;d=e.bit.set(d,h.Clickable,t._ibits&h.Clickable&&!!this.clickAction);d=e.bit.set(d,h.DoubleClickable,t._ibits&h.DoubleClickable&&!!this.doubleClickAction);this._ibits=d}).add({chart:null,parent:null,_children:null,type:t.Panel,_extensionPrefix:"",_rubberSelectableMarks:null,height:null,width:null,borderWidth:null,anchor:"top",pvPanel:null,margins:null,paddings:null,isRoot:!1,isTopRoot:!1,root:null,topRoot:null,_layoutInfo:null,_signs:null,data:null,dataPartValue:null,_animating:0,_selectingByRubberband:!1,_v1DimRoleName:{series:"series",category:"category",value:"value"},_sceneTypeExtensions:null,clickAction:null,doubleClickAction:null,compatVersion:function(e){return this.chart.compatVersion(e) },_createLogInstanceId:function(){return""+this.constructor+this.chart._createLogChildSuffix()},_getLegendBulletRootScene:function(){return this.chart._getLegendBulletRootScene()},_addChild:function(t){t.parent===this||e.assert("Child has a != parent.");(this._children||(this._children=[])).push(t)},_addSign:function(t){e.array.lazy(this,"_signs").push(t);t.selectableByRubberband()&&e.array.lazy(this,"_rubberSelectableMarks").push(t.pvMark)},visibleData:function(e){return this.chart.visibleData(this.dataPartValue,e)},partData:function(){return this.chart.partData(this.dataPartValue)},layout:function(t,i){if(!this._layoutInfo||e.get(i,"force",!1)){var n=e.get(i,"referenceSize");!n&&t&&(n=e.copyOwn(t));var a=this.size.resolve(n),r=this.sizeMax.resolve(n);if(!t){if(null==a.width||null==a.height)throw e.error.operationInvalid("Panel layout without width or height set.");t=e.copyOwn(a)}!n&&t&&(n=e.copyOwn(t));null!=r.width&&t.width>r.width&&(t.width=r.width);null!=r.height&&t.height>r.height&&(t.height=r.height); var s=this.borderWidth/2,o=(e.get(i,"margins")||this.margins).resolve(n),l=(e.get(i,"paddings")||this.paddings).resolve(n),u=Vt.inflate(o,s),c=Vt.inflate(l,s),h=u.width+c.width,d=u.height+c.height,f=new zt(Math.max(t.width-h,0),Math.max(t.height-d,0)),v=e.copyOwn(a);null!=v.width&&(v.width=Math.max(v.width-h,0));null!=v.height&&(v.height=Math.max(v.height-d,0));var p=this._layoutInfo||null,m=e.get(i,"canChange",!0),g=this._layoutInfo={canChange:m,referenceSize:n,realMargins:o,realPaddings:l,borderWidth:this.borderWidth,margins:u,paddings:c,desiredClientSize:v,clientSize:f,pageClientSize:p?p.pageClientSize:f.clone(),previous:p};if(p){delete p.previous;delete p.pageClientSize}var b,_=this._calcLayout(g);if(_){g.clientSize=_;b={width:_.width+h,height:_.height+d}}else{b=t;_=f}this.isVisible=_.width>0&&_.height>0;delete g.desiredClientSize;this.width=b.width;this.height=b.height;!m&&p&&delete g.previous;if(Tt.debug>=5){this._log("Size = "+Tt.stringify(b));this._log("Margins = "+Tt.stringify(g.margins)); this._log("Paddings = "+Tt.stringify(g.paddings));this._log("ClientSize = "+Tt.stringify(g.clientSize))}this._onLaidOut()}},_onLaidOut:function(){this.isRoot&&this.chart._onLaidOut()},_calcLayout:function(t){function i(e,t,i){for(var n=0;e--;){if(t.call(i,e,n)===!1)return!0;n++}return!1}function n(t,i){d&&f._group("LayoutCycle #"+(i+1)+" (remaining: "+t+")");try{var n=t>0;c=new Vt(0);h=e.copyOwn(u);for(var r,s=0,o=_.length;o>s;){r=_[s];d&&f._group("SIDE Child #"+(s+1)+" at "+r.anchor);try{if(a.call(this,r,n))return!0}finally{d&&f._groupEnd()}s++}s=0;o=b.length;for(;o>s;){r=b[s];d&&f._group("FILL Child #"+(s+1));try{if(a.call(this,r,n))return!0}finally{d&&f._groupEnd()}s++}return!1}finally{d&&f._groupEnd()}}function a(e,t){var n,a=!1;y.canChange=t;i(3,function(i,u){d&&f._group("Attempt #"+(u+1));try{y.paddings=n;y.canChange=i>0;e.layout(new zt(h),y);if(e.isVisible){a=s.call(this,e,t);if(a)return!1;var c=e._layoutInfo.requestPaddings;if(r(n,c)){n=c;if(i>0){n=new Vt(n);d&&this._log("Child requested paddings change: "+Tt.stringify(n)); return!0}Tt.debug>=2&&this._warn("Child requests paddings change but iterations limit has been reached.")}o.call(this,e);"fill"!==e.anchor&&l.call(this,e)}return!1}finally{d&&f._groupEnd()}},this);return a}function r(t,i){return i?e.query(Vt.names).each(function(e){var n=t&&t[e]||0,a=i&&i[e]||0;return Math.abs(a-n)>=.1?!1:void 0}):!1}function s(e,t){var i=!1,n=e.width-h.width;if(n>0){Tt.debug>=3&&this._log("Child added width = "+n);if(t){i=!0;h.width+=n;u.width+=n}else Tt.debug>=2&&this._warn("Child wanted more width, but layout iterations limit has been reached.")}var a=e.height-h.height;if(a>0){Tt.debug>=3&&this._log("Child added height ="+a);if(t){i=!0;h.height+=a;u.height+=a}else Tt.debug>=2&&this._warn("Child wanted more height, but layout iterations limit has been reached.")}return i}function o(i){var n,a=i.anchor,r=i.align,s=i.alignTo;if("fill"===a){a="left";n=c.left+h.width/2-i.width/2;r=s="middle"}else n=c[a];var o,l;switch(r){case"top":case"bottom":case"left":case"right":o=r;l=0; break;case"center":case"middle":o=m[p[a]];l=-i[v[o]]/2}var u,d;switch(s){case"top":case"bottom":case"left":case"right":d=s;u=d!==o?h[v[o]]:0;break;case"center":case"middle":d=m[p[a]];u=h[v[o]]/2;break;case"page-center":case"page-middle":d=m[p[a]];var f=v[o],b=Math.min(h[f],t.pageClientSize[f]);u=b/2}var _=c[d]+u+l,y=i.offset.resolve(h);if(y){n+=y[g[a]]||0;_+=y[g[o]]||0}if(i.keepInBounds){0>n&&(n=0);0>_&&(_=0)}i.setPosition(e.set({},a,n,o,_))}function l(e){var t=e.anchor,i=v[t],n=e[i];c[t]+=n;h[i]-=n}var u,c,h,d,f=this;if(f._children){var v=Tt.BasePanel.orthogonalLength,p=Tt.BasePanel.relativeAnchor,m=Tt.BasePanel.leftTopAnchor,g=Ft.namesSidesToOffset,b=[],_=[];f._children.forEach(function(t){var i=t.anchor;if(i)if("fill"===i)b.push(t);else{e.hasOwn(p,i)||e.fail.operationInvalid("Unknown anchor value '{0}'",[i]);_.push(t)}});d=Tt.debug>=5;u=e.copyOwn(t.clientSize);var y={force:!0,referenceSize:u};d&&f._group("CCC DOCK LAYOUT clientSize = "+Tt.stringify(u));try{i(5,n,f)}finally{d&&f._groupEnd() }}return u},invalidateLayout:function(){this._layoutInfo=null;this._children&&this._children.forEach(function(e){e.invalidateLayout()})},_create:function(i){if(!this.pvPanel||i){var n;delete this._invalidDataError;this.pvPanel=null;this.pvRootPanel&&(this.pvRootPanel=null);delete this._signs;try{this.layout()}catch(a){if(!(a instanceof InvalidDataException))throw a;this._invalidDataError=n=a}if(this.isTopRoot&&this.chart._isMultiChartOverflowClip)return;if(!this.isVisible)return;this.isRoot&&this._creating();var r=this._layoutInfo.margins,s=this._layoutInfo.paddings;if(this.isTopRoot){this.pvRootPanel=this.pvPanel=(new t.Panel).canvas(this.chart.options.canvas);var o=new Tt.visual.Scene(null,{panel:this});this.pvRootPanel.lock("data",[o]);if(r.width>0||r.height>0){this.pvPanel.width(this.width).height(this.height);this.pvPanel=this.pvPanel.add(t.Panel)}}else this.pvPanel=this.parent.pvPanel.add(this.type);var l=this.pvPanel,u=this.width-r.width,c=this.height-r.height;l.width(u).height(c); Tt.debug>=15&&(r.width>0||r.height>0)&&(this.isTopRoot?this.pvRootPanel:this.parent.pvPanel).add(this.type).width(this.width).height(this.height).left(null!=this.position.left?this.position.left:null).right(null!=this.position.right?this.position.right:null).top(null!=this.position.top?this.position.top:null).bottom(null!=this.position.bottom?this.position.bottom:null).strokeStyle("orange").lineWidth(1).strokeDasharray("- .");var h={};e.eachOwn(this.position,function(e,t){l[t](e+r[t]);h[this.anchorLength(t)]=!0},this);if(!h.width){r.left>0&&l.left(r.left);r.right>0&&l.right(r.right)}if(!h.height){r.top>0&&l.top(r.top);r.bottom>0&&l.bottom(r.bottom)}(s.width>0||s.height>0)&&(this.pvPanel=l.add(t.Panel).width(u-s.width).height(c-s.height).left(s.left).top(s.top));l.borderPanel=l;l.paddingPanel=this.pvPanel;this.pvPanel.paddingPanel=this.pvPanel;this.pvPanel.borderPanel=l;if(Tt.debug>=15){this.pvPanel.strokeStyle("lightgreen").lineWidth(1).strokeDasharray("- ");this.pvPanel!==l&&l.strokeStyle("blue").lineWidth(1).strokeDasharray(". ") }var d=this._getExtensionId();new Tt.visual.Panel(this,null,{panel:l,extensionId:d});if(!n)try{this._createCore(this._layoutInfo)}catch(a){if(!(a instanceof InvalidDataException))throw a;this._invalidDataError=n=a}if(n){var f=l.anchor("center").add(t.Label).text(n.message);this.chart.extend(f,"invalidDataMessage")}if(this.isTopRoot){this.chart._multiChartOverflowClipped&&this._addMultichartOverflowClipMarker();this._initSelection()}this.applyExtensions();if(this.isRoot&&Tt.debug>5){var v=["SCALES SUMMARY",Tt.logSeparator];this.chart.axesList.forEach(function(e){var t=e.scale;if(t){var i=t.domain&&t.domain(),n=t.range&&t.range();v.push(e.id);v.push(" domain: "+(i?Tt.stringify(i):"?"));v.push(" range : "+(n?Tt.stringify(n):"?"))}},this);this._log(v.join("\n"))}}},_creating:function(){this._children&&this._children.forEach(function(e){e._creating()})},_createCore:function(){this._children&&this._children.forEach(function(e){e._create()})},render:function(t){if(!this.isTopRoot)return this.topRoot.render(t); this._create(e.get(t,"recreate",!1));if((!this.isTopRoot||!this.chart._isMultiChartOverflowClip)&&this.isVisible){var i=this.pvRootPanel;if(this._invalidDataError)i.render();else{this._onRender();var n=(this.chart.options,this._animating),a=this.chart.animatable();this._animating=a&&!e.get(t,"bypassAnimation",!1)?1:0;try{i.render();if(this._animating){this._animating=2;var r=this;i.transition().duration(2e3).ease("cubic-in-out").start(function(){if(n)n=0;else{r._animating=0;r._onRenderEnd(!0)}})}else this._onRenderEnd(!1)}finally{this._animating=0}}}},_onRender:function(){var e=this.chart.options.renderCallback;if(e)if(this.compatVersion()<=1)e.call(this.chart);else{var t=this.context();e.call(t,t.scene)}},_onRenderEnd:function(e){this._children&&this._children.forEach(function(t){t._onRenderEnd(e)})},renderInteractive:function(){if(this.isVisible){var e=this._getSelectableMarks();if(e&&e.length)e.forEach(function(e){e.render()});else if(!this._children){this.pvPanel.render();return}this._children&&this._children.forEach(function(e){e.renderInteractive() })}},_getSelectableMarks:function(){return this._rubberSelectableMarks},animate:function(e,t){return 1===this.topRoot._animating?e:t},animatingStart:function(){return 1===this.topRoot._animating},animating:function(){return this.topRoot._animating>0},setPosition:function(t){for(var i in t)if(e.hasOwn(Vt.namesSet,i)){var n=t[i];if(null===n)delete this.position[i];else{n=+n;!isNaN(n)&&isFinite(n)&&(this.position[i]=n)}}},createAnchoredSize:function(e,t){return this.isAnchorTopOrBottom()?new zt(t.width,Math.min(t.height,e)):new zt(Math.min(t.width,e),t.height)},applyExtensions:function(){this._signs&&this._signs.forEach(function(e){e.applyExtensions()})},extend:function(e,t,i){this.chart.extend(e,this._makeExtensionAbsId(t),i)},extendAbs:function(e,t,i){this.chart.extend(e,t,i)},_extendSceneType:function(t,i,n){var a=e.get(this._sceneTypeExtensions,t);a&&Tt.extendType(i,a,n)},_absBaseExtId:{abs:"base"},_absSmallBaseExtId:{abs:"smallBase"},_getExtensionId:function(){return this.isRoot?this.chart.parent?this._absSmallBaseExtId:this._absBaseExtId:void 0 },_getExtensionPrefix:function(){return this._extensionPrefix},_makeExtensionAbsId:function(e){return Tt.makeExtensionAbsId(e,this._getExtensionPrefix())},_getExtension:function(e,t){return this.chart._getExtension(this._makeExtensionAbsId(e),t)},_getExtensionAbs:function(e,t){return this.chart._getExtension(e,t)},_getConstantExtension:function(e,t){return this.chart._getConstantExtension(this._makeExtensionAbsId(e),t)},getPvPanel:function(i){var n=this.pvPanel;if(!i)return n;if(!this.parent)throw e.error.operationInvalid("Layers are not possible in a root panel.");if(!n)throw e.error.operationInvalid("Cannot access layer panels without having created the main panel.");var a=null;this._layers?a=this._layers[i]:this._layers={};if(!a){var r=this.parent.pvPanel;a=r.borderPanel.add(this.type).extend(n.borderPanel);var s=a;n!==n.borderPanel&&(a=s.add(t.Panel).extend(n));s.borderPanel=s;s.paddingPanel=a;a.paddingPanel=a;a.borderPanel=s;this.initLayerPanel(a,i);this._layers[i]=a}return a},initLayerPanel:function(){},_getV1DimName:function(e){var t=this._v1DimName||(this._v1DimNameCache={}),i=t[e]; if(null==i){var n=this.chart.visualRoles[this._v1DimRoleName[e]];i=n?n.firstDimensionName():"";t[e]=i}return i},_getV1Datum:function(e){return e.datum},context:function(){var e=this._context;!e||e.isPinned?e=this._context=new Tt.visual.Context(this):vt.call(e);return e},_isTooltipEnabled:function(){return!this.selectingByRubberband()&&!this.animating()},_getTooltipFormatter:function(e){var t=this.compatVersion()<=1,i=e.format;if(!i){if(!t)return this._summaryTooltipFormatter;i=this.chart.options.v1StyleTooltipFormat;if(!i)return}return t?function(e){return i.call(e.panel,e.getV1Series(),e.getV1Category(),e.getV1Value()||"",e.getV1Datum())}:function(e){return i.call(e,e.scene)}},_summaryTooltipFormatter:function(t){function i(t,i){c.push(""+t+": "+(e.html.escape(i)||" - ")+"
")}function n(e,t){var i;i=r?r.dimensions(t).valuePercent(u):l.dimensions(t).percent(e.value,u);return f(i)}var a=t.scene;if(!a.datum)return"";var r=a.group,s=r&&r.count()>1,o=a.datum;if(!s&&(!o||o.isNull))return""; var l=a.data(),u={visible:!0},c=[];o.isInterpolated?c.push("Interpolation: "+e.html.escape(o.interpolation)+"
"):o.isTrend&&c.push(""+e.html.escape(o.trend.label)+"
");var h=l.type,d=t.panel.stacked===!1?null:h.getPlayingPercentVisualRoleDimensionMap(),f=d?t.chart.options.percentValueFormat:null,v=s?r.atoms:a.datum.atoms,p=h.sortDimensionNames(e.keys(v)),m=!1;p.forEach(function(t){var a=v[t],r=a.dimension.type;if(!(r.isHidden||s&&null==a.value)){m=!0;var o=a.label;d&&d.has(t)&&(o+=" ("+n(a,t)+")");i(e.html.escape(a.dimension.type.label),o)}});if(s){m&&c.push("
");c.push("#: "+r._datums.length+"
");h.sortDimensionNames(r.freeDimensionsNames()).forEach(function(t){var a=r.dimensions(t);if(!a.type.isHidden){var s,o=e.html.escape(a.type.label);if(a.type.valueType===Number){s=a.format(a.value(u));d&&d.has(t)&&(s+=" ("+n(null,t)+")");o="∑ "+o}else s=a.atoms(u).map(function(e){return e.label||"- "}).join(", ");i(o,s)}})}return'
'+c.join("\n")+"
" },_onClick:function(e){var t=this.clickAction;t&&(this.compatVersion()<=1?this._onV1Click(e,t):t.call(e,e.scene))},_onDoubleClick:function(e){var t=this.doubleClickAction;t&&(this.compatVersion()<=1?this._onV1DoubleClick(e,t):t.call(e,e.scene))},_onV1Click:function(e,t){t.call(e.pvMark,e.getV1Series(),e.getV1Category(),e.getV1Value(),e.event,e.getV1Datum())},_onV1DoubleClick:function(e,t){t.call(e.pvMark,e.getV1Series(),e.getV1Category(),e.getV1Value(),e.event,e.getV1Datum())},_addMultichartOverflowClipMarker:function(){function t(e){var t=e.shapeRadius();if(null==t){var i=e.shapeSize();null!=i&&(t=Math.sqrt(i))}return t||n}var i=10,n=5,a=new Tt.visual.Dot(this,this.pvPanel,{noSelect:!0,noHover:!0,noClick:!0,noDoubleClick:!0,noTooltip:!1,freePosition:!0,extensionId:"multiChartOverflowMarker"}).lock("data").pvMark.shape("triangle").shapeRadius(n).top(null).left(null).bottom(function(){return t(this)+i}).right(function(){return t(this)+i}).shapeAngle(0).lineWidth(1.5).strokeStyle("red").fillStyle("rgba(255, 0, 0, 0.2)"); e.fun.is(a.tooltip)&&a.tooltip("Some charts did not fit the available space.")},selectingByRubberband:function(){return this.topRoot._selectingByRubberband},_initSelection:function(){var i=this,n=i.chart;if(i.interactive()){var a=i.unselectable(),r=i.selectableByRubberband();if(r||a){var s=i.data,o=i.pvRootPanel||i.pvPanel.paddingPanel;i._getExtensionAbs("base","fillStyle")||o.fillStyle(Tt.invisibleFill);o.lock("events","all");if(r){var l=4;i._selectingByRubberband=!1;var u,c,h,d=this.selectBar=new Tt.visual.Bar(i,o,{extensionId:"rubberBand",normalStroke:!0,noHover:!0,noSelect:!0,noClick:!0,noDoubleClick:!0,noTooltip:!0}).override("defaultStrokeWidth",e.fun.constant(1.5)).override("defaultColor",function(e,t){return"stroke"===t?"#86fe00":"rgba(203, 239, 163, 0.6)"}).override("interactiveColor",function(e,t){return t}).pvMark.lock("visible",function(){return!!c}).lock("left",function(){return c.x}).lock("right").lock("top",function(){return c.y}).lock("bottom").lock("width",function(){return c.dx }).lock("height",function(){return c.dy}).lock("cursor").lock("events","none");o.intercept("data",function(){var e=this.delegate();e&&e.forEach(function(e){null==e.x&&(e.x=e.y=e.dx=e.dy=0)});return e}).event("mousedown",t.Behavior.select().autoRender(!1)).event("select",function(e){if(c)c=new t.Shape.Rect(e.x,e.y,e.dx,e.dy);else{if(i.animating())return;if(e.dx*e.dx+e.dy*e.dy<=l)return;c=new t.Shape.Rect(e.x,e.y,e.dx,e.dy);i._selectingByRubberband=!0;u||(u=o.toScreenTransform());i.rubberBand=c.apply(u)}d.render()}).event("selectend",function(){if(c){var e=arguments[arguments.length-1];u||(u=o.toScreenTransform());var t=c.apply(u);c=null;i._selectingByRubberband=!1;d.render();try{i._processRubberBand(t,e)}finally{h=new Date}}});a&&o.event("click",function(){if(h){var e=new Date-h;if(300>e){h=null;return}}s.clearSelected()&&n.updateSelections()})}else a&&o.event("click",function(){s.clearSelected()&&n.updateSelections()})}}},_processRubberBand:function(e,t,i){this.rubberBand=e;try{this._onRubberBandSelectionEnd(t,i) }finally{this.rubberBand=null}},_onRubberBandSelectionEnd:function(e,t){Tt.debug>=20&&this._log("rubberBand "+Tt.stringify(this.rubberBand));t=Object.create(t||{});t.toggle=!1;var i=this._getDatumsOnRubberBand(e,t);if(i){var n=this.chart;n._updatingSelections(function(){var a=!e.ctrlKey&&n.options.ctrlSelectMode;if(a){n.data.owner.clearSelected();Tt.data.Data.setSelected(i,!0)}else t.toggle?Tt.data.Data.toggleSelected(i):Tt.data.Data.setSelected(i,!0)})}},_getDatumsOnRubberBand:function(t,i){var n=new e.Map;this._getDatumsOnRect(n,this.rubberBand,i);var a=n.values();if(a.length){a=this.chart._onUserSelection(a);a&&!a.length&&(a=null)}return a},_getDatumsOnRect:function(e,t,i){this._getOwnDatumsOnRect(e,t,i);var n=this._children;n&&n.forEach(function(n){n._getDatumsOnRect(e,t,i)})},_getOwnDatumsOnRect:function(t,i,n){var a=this;if(!a.isVisible)return!1;var r=a._getSelectableMarks();if(!r||!r.length)return!1;var s=t.count,o=e.get(n,"markSelectionMode"),l=function(e){e.isNull||t.set(e.id,e) },u=function(e){e.selectableByRubberband()&&e.datums().each(l)},c=function(e){e.eachSceneWithDataOnRect(i,u,null,o)};r.forEach(c);return sd;d++){var f=c[d],v=d%h,p=Math.floor(d/h),m=e.set(Object.create(l),"smallColIndex",v,"smallRowIndex",p,"title",f.absLabel,"data",f),g=new u(m); if(o){g._createPhase1();s(g)}else g._create()}if(o){var b=this;e.eachOwn(o,function(e,t){e.forEach(function(e){a[t].forEach(function(t){b._coordinateScopeAxes(e.id,t)})})});i.children.forEach(function(e){e._createPhase2()})}n.coordScopesByType=a}},_getCoordinatedRootAxesByScopeType:function(){var t=!1,i=e.query(this.chart.axesList).multipleIndex(function(e){if("discrete"!==e.scaleType&&e.option.isDefined("DomainScope")){var i=e.option("DomainScope");if("cell"!==i){t=!0;return i}}});return t?i:null},_coordinateScopeAxes:function(t,i){var n=e.query(i).select(function(e){var i=e.axes[t].scale;if(!i.isNull){var n=i.domain();return{min:n[0],max:n[1]}}}).reduce(Tt.unionExtents,null);n&&i.forEach(function(e){var i=e.axes[t],a=i.scale;if(!a.isNull){a.domain(n.min,n.max);i.setScale(a)}})},_buildSmallChartsBaseOptions:function(){var t=this.chart,i=t.options;return e.set(Object.create(i),"parent",t,"legend",!1,"titleFont",i.smallTitleFont,"titlePosition",i.smallTitlePosition,"titleAlign",i.smallTitleAlign,"titleAlignTo",i.smallTitleAlignTo,"titleOffset",i.smallTitleOffset,"titleKeepInBounds",i.smallTitleKeepInBounds,"titleMargins",i.smallTitleMargins,"titlePaddings",i.smallTitlePaddings,"titleSize",i.smallTitleSize,"titleSizeMax",i.smallTitleSizeMax) },_calcLayout:function(t){var i=this.chart,n=i._multiInfo;if(n){var a=i.multiOptions.option,r=i.smallOptions.option,s=t.clientSize,o=t.previous,l=o?o.initialClientWidth:s.width,u=o?o.initialClientHeight:s.height,c=r("Width");null!=c&&(c=Nt.resolve(c,l));var h=r("Height");null!=h&&(h=Nt.resolve(h,u));var d=r("AspectRatio"),f=n.rowCount,v=n.colCount;if(null==c)if(isFinite(n.colsMax))c=s.width/v;else{null==h&&(h=u);c=d*h}null==h&&(h=1===f&&a("SingleRowFillsHeight")||1===v&&a("SingleColFillsHeight")?u:c/d);var p=c*v,m=h*f;if(!i._isMultiChartOverflowClipRetry){i._isMultiChartOverflowClip=!1;switch(a("Overflow")){case"fit":if(p>l){p=l;c=p/v}if(m>u){m=u;h=m/f}break;case"clip":var g=v,b=f,_=p>l;_&&(g=Math.floor(l/c));var y=m>u;y&&(b=Math.floor(u/h));if(y||_){i._isMultiChartOverflowClip=!0;i._clippedMultiChartRowsMax=b;i._clippedMultiChartColsMax=g}}}e.set(t,"initialClientWidth",l,"initialClientHeight",u,"width",c,"height",h);return{width:p,height:Math.max(s.height,m)}}},_getExtensionId:function(){return"content" },_createCore:function(t){var i=this.chart;!i._isMultiChartOverflowClip||e.assert("Overflow&clip condition should be resolved.");var n=i._multiInfo;if(n){var a=i.smallOptions.option,r=a("Margins"),s=a("Paddings");i.children.forEach(function(e){e._setSmallLayout({left:e.smallColIndex*t.width,top:e.smallRowIndex*t.height,width:t.width,height:t.height,margins:this._buildSmallMargins(e,r,n),paddings:s})},this);var o=n.coordScopesByType;o&&i._coordinateSmallChartsLayout(o);this.base(t)}},_buildSmallMargins:function(e,t,i){var n=i.colCount-1,a=i.rowCount-1,r=e.smallColIndex,s=e.smallRowIndex,o={};r>0&&(o.left=t.left);n>r&&(o.right=t.right);s>0&&(o.top=t.top);a>s&&(o.bottom=t.bottom);return o}});e.type("pvc.TitlePanelAbstract",Tt.BasePanel).init(function(e,t,i){i||(i={});var n=i.anchor||this.anchor;if(null==i.size){var a=i.titleSize;null!=a&&(i.size=(new zt).setSize(a,{singleProp:this.anchorOrthoLength(n)}))}if(null==i.sizeMax){var r=i.titleSizeMax;null!=r&&(i.sizeMax=(new zt).setSize(r,{singleProp:this.anchorOrthoLength(n)})) }null==i.paddings&&(i.paddings=this.defaultPaddings);this.base(e,t,i);if(void 0===i.font){var s=this._getExtension("label","font");"string"==typeof s&&(this.font=s)}}).add({pvLabel:null,anchor:"top",title:null,titleSize:void 0,font:"12px sans-serif",defaultPaddings:2,_extensionPrefix:"title",_calcLayout:function(e){var i=new zt,n=this.anchor,a=this.anchorLength(n),r=this.anchorOrthoLength(n),s=t.Text.measureWidth(this.title,this.font)+2,o=e.clientSize[a],l=e.desiredClientSize[a];null==l?l=s>o?o:s:l>o&&(l=o);var u;u=s>l?Tt.text.justify(this.title,l,this.font):this.title?[this.title]:[];var c=t.Text.fontHeight(this.font),h=u.length*c,d=e.clientSize[r],f=e.desiredClientSize[r];null==f?f=h:f>d&&(f=d);if(h>f){var v=Math.max(1,Math.floor(f/c));if(u.length>v){var p=u[v];u.length=v;h=f=v*c;var m=u[v-1]+" "+p;u[v-1]=Tt.text.trimToWidthB(l,m,this.font,"..")}}e.lines=u;e.topOffset=(f-h)/2;e.lineSize={width:l,height:c};e.a_width=a;e.a_height=r;i[a]=l;i[r]=f;return i},_createCore:function(e){var t,i=this._buildScene(e),n={top:0,right:Math.PI/2,bottom:0,left:-Math.PI/2},a=Tt.BasePanel.horizontalAlign[this.align],r=Tt.BasePanel.leftTopAnchor[this.anchor]; this.compatVersion()<=1&&(t=function(e){return function(){return e.call(this)}});this.pvLabel=new Tt.visual.Label(this,this.pvPanel,{extensionId:"label",wrapper:t}).lock("data",i.lineScenes).pvMark[r](function(t){return e.topOffset+t.vars.size.height/2+this.index*t.vars.size.height}).textAlign(a)[this.anchorOrtho(r)](function(e){switch(this.textAlign()){case"center":return e.vars.size.width/2;case"left":return 0;case"right":return e.vars.size.width}}).text(function(e){return e.vars.textLines[this.index]}).font(this.font).textBaseline("middle").textAngle(n[this.anchor])},_buildScene:function(t){var i=new Tt.visual.Scene(null,{panel:this,source:this.chart.data}),n=t.lines;i.vars.size=t.lineSize;i.vars.textLines=n;i.lineScenes=e.array.create(n.length,i);return i},_getExtensionId:e.fun.constant("")});e.type("pvc.TitlePanel",Tt.TitlePanelAbstract).init(function(e,t,i){i||(i={});var n=e.compatVersion()<=1;if(n){var a=i.titleSize;null==a&&(i.titleSize=25)}this._extensionPrefix=e.parent?"smallTitle":"title"; this.base(e,t,i)}).add({font:"14px sans-serif",defaultPaddings:4});e.type("pvc.LegendPanel",Tt.BasePanel).init(function(e,t,i){this.base(e,t,i);if(void 0===i.font){var n=this._getConstantExtension("label","font");n&&(this.font=n)}var a=Tt.visual.Interactive;this._ibits&a.Interactive&&(this._ibits|=a.Clickable)}).add({pvRule:null,pvDot:null,pvLabel:null,anchor:"bottom",pvLegendPanel:null,textMargin:6,itemPadding:2.5,itemSize:null,markerSize:15,font:"10px sans-serif",_calcLayout:function(e){return this._getBulletRootScene().layout(e)},_createCore:function(e){var i=e.clientSize,n=this._getBulletRootScene(),a=n.vars.itemPadding,r=n.vars.contentSize,s=this.isAnchorTopOrBottom(),o=s?"top":"left",l=this.anchorOpposite(o),u=this.anchorLength(o),c=this.anchorOrthoLength(o),h=s?"center":"middle",d=s?"left":"top",f=this.anchorOpposite(d),v=0;switch(this.align){case f:v=i[u]-r[u];break;case h:v=(i[u]-r[u])/2}this.pvPanel.borderPanel.overflow("hidden");var p,m=this.pvPanel.add(t.Panel).data(n.vars.sections)[d](v)[o](function(){var e=this.sibling(); return e?e[o]+e[c]+a[c]:0})[u](function(e){return e.size[u]})[c](function(e){return e.size[c]});this.compatVersion()<=1&&(p=function(e){return function(t){return e.call(this,t.vars.value.rawValue)}});var g=this.pvLegendPanel=new Tt.visual.Panel(this,m,{extensionId:"panel",wrapper:p,noSelect:!1,noHover:!0,noClick:!1,noClickSelect:!0}).pvMark.lock("data",function(e){return e.items})[f](null)[l](null)[d](function(e){var t=e.vars.itemPadding,i=this.sibling();return i?i[d]+i[u]+t[u]:0})[o](s?function(e){var t=e.vars;return t.section.size.height/2-t.itemClientSize.height/2}:0).height(function(e){return e.vars.itemClientSize.height}).width(s?function(e){return e.vars.itemClientSize.width}:function(){return this.parent.width()}).def("hidden","false").fillStyle(function(){return"true"==this.hidden()?"rgba(200,200,200,1)":"rgba(200,200,200,0.0001)"}),b=new Tt.visual.Panel(this,g,{extensionId:"markerPanel"}).pvMark.left(0).top(0).right(null).bottom(null).width(function(e){return e.vars.markerSize}).height(function(e){return e.vars.itemClientSize.height });if(Tt.debug>=20){m.strokeStyle("red").lineWidth(.5).strokeDasharray(".");g.strokeStyle("green").lineWidth(.5).strokeDasharray(".");b.strokeStyle("blue").lineWidth(.5).strokeDasharray(".")}n.childNodes.forEach(function(e){var t=new Tt.visual.Panel(this,b).pvMark.visible(function(t){return t.parent===e});e.renderer().create(this,t,e.extensionPrefix,p)},this);this.pvLabel=new Tt.visual.Label(this,b.anchor("right"),{extensionId:"label",noTooltip:!1,noClick:!1,wrapper:p}).intercept("textStyle",function(e){var t=this.delegateExtension()||"black";return e.isOn()?t:Tt.toGrayScale(t,null,void 0,150)}).pvMark.textAlign("left").text(function(e){var t=e.labelText(),i=e.vars;i.textSize.width>i.labelWidthMax&&(t=Tt.text.trimToWidthB(i.labelWidthMax,t,i.font,"..",!1));return t}).textMargin(function(e){return e.vars.textMargin}).font(function(e){return e.vars.font}).textDecoration(function(e){return e.isOn()?"":"line-through"});Tt.debug>=16&&b.anchor("right").add(t.Panel)[this.anchorLength()](0)[this.anchorOrthoLength()](0).fillStyle(null).strokeStyle(null).lineWidth(0).add(t.Line).data(function(e){var t=e.vars,i=Tt.text.getLabelBBox(Math.min(t.labelWidthMax,t.textSize.width),2*t.textSize.height/3,"left","middle",0,t.textMargin),n=i.source.points(); n.length>1&&(n=n.concat(n[0]));return n}).left(function(e){return e.x}).top(function(e){return e.y}).strokeStyle("red").lineWidth(.5).strokeDasharray("-")},_onClick:function(t){var i=t.scene;e.fun.is(i.execute)&&i.executable()&&i.execute()},_getExtensionPrefix:function(){return"legend"},_getExtensionId:function(){return"area"},_getSelectableMarks:function(){return[this.pvLegendPanel]},_getBulletRootScene:function(){var e=this._rootScene;if(!e){e=new Tt.visual.legend.BulletRootScene(null,{panel:this,source:this.chart.data,horizontal:this.isAnchorTopOrBottom(),font:this.font,markerSize:this.markerSize,textMargin:this.textMargin,itemPadding:this.itemPadding,itemSize:this.itemSize});this._rootScene=e}return e},_getTooltipFormatter:function(e){e.isLazy=!1;return function(e){var t=e.scene.vars.value,i=t.absLabel||t.label,n=e.pvMark.text();return i!==n?i:""}}});e.type("pvc.CartesianAbstract",Tt.BaseChart).init(function(e){this.axesPanels={};this.base(e)}).add({_gridDockPanel:null,axesPanels:null,yAxisPanel:null,xAxisPanel:null,secondXAxisPanel:null,secondYAxisPanel:null,yScale:null,xScale:null,_getSeriesRoleSpec:function(){return{isRequired:!0,defaultDimension:"series*",autoCreateDimension:!0,requireIsDiscrete:!0} },_getColorRoleSpec:function(){return{isRequired:!0,defaultDimension:"color*",defaultSourceRole:"series",requireIsDiscrete:!0}},_addAxis:function(e){this.base(e);switch(e.type){case"base":case"ortho":this.axes[e.orientedId]=e;e.v1SecondOrientedId&&(this.axes[e.v1SecondOrientedId]=e)}return this},_setAxisScale:function(e,t){this.base(e,t);var i="ortho"===e.type,n=i||"base"===e.type;n&&(i&&1===e.index?this.secondScale=e.scale:e.index||(this[e.orientation+"Scale"]=e.scale))},_createContent:function(t){this._createFocusWindow();this._gridDockPanel=new Tt.CartesianGridDockingPanel(this,this.basePanel,{margins:t.margins,paddings:t.paddings});["base","ortho"].forEach(function(t){var i=this.axesByType[t];i&&e.query(i).reverse().each(function(e){this._createAxisPanel(e)},this)},this);this._createPlotPanels(this._gridDockPanel,{clickAction:t.clickAction,doubleClickAction:t.doubleClickAction})},_createFocusWindow:function(){if(this.selectableByFocusWindow()){var e,t=this.focusWindow;t&&(e=t._exportData()); t=this.focusWindow=new Tt.visual.CartesianFocusWindow(this);e&&t._importData(e);t._initFromOptions()}else this.focusWindow&&delete this.focusWindow},_createAxisPanel:function(t){if(t.option("Visible")){var i,n=t.option("Title");e.empty(n)||(i=new Tt.AxisTitlePanel(this,this._gridDockPanel,t,{title:n,font:t.option("TitleFont")||t.option("Font"),anchor:t.option("Position"),align:t.option("TitleAlign"),margins:t.option("TitleMargins"),paddings:t.option("TitlePaddings"),titleSize:t.option("TitleSize"),titleSizeMax:t.option("TitleSizeMax")}));var a=new Tt.AxisPanel(this,this._gridDockPanel,t,{anchor:t.option("Position"),size:t.option("Size"),sizeMax:t.option("SizeMax"),clickAction:t.option("ClickAction"),doubleClickAction:t.option("DoubleClickAction"),useCompositeAxis:t.option("Composite"),font:t.option("Font"),labelSpacingMin:t.option("LabelSpacingMin"),grid:t.option("Grid"),gridCrossesMargin:t.option("GridCrossesMargin"),ruleCrossesMargin:t.option("RuleCrossesMargin"),zeroLine:t.option("ZeroLine"),desiredTickCount:t.option("DesiredTickCount"),showTicks:t.option("Ticks"),showMinorTicks:t.option("MinorTicks")}); i&&(a.titlePanel=i);this.axesPanels[t.id]=a;this.axesPanels[t.orientedId]=a;t.index<=1&&t.v1SecondOrientedId&&(this[t.v1SecondOrientedId+"AxisPanel"]=a);return a}},_onLaidOut:function(){this.plotPanelList&&this.plotPanelList[0]&&["base","ortho"].forEach(function(e){var t=this.axesByType[e];t&&t.forEach(this._setCartAxisScaleRange,this)},this)},_setCartAxisScaleRange:function(e){var t=this.plotPanelList[0]._layoutInfo,i=t.clientSize,n="x"===e.orientation?i.width:i.height;e.setScaleRange(n);return e.scale},_getAxesRoundingPaddings:function(){function e(e,t,n){var a=i[e];if(null==a||t>a){i[e]=t;i[e+"Locked"]=n}else n&&(i[e+"Locked"]=n)}function t(t){if(t){var i=t.getScaleRoundingPaddings();if(i){var n="x"===t.orientation;e(n?"left":"bottom",i.begin,i.beginLocked);e(n?"right":"top",i.end,i.endLocked)}}}var i={},n=this.axesByType;["base","ortho"].forEach(function(e){var i=n[e];i&&i.forEach(t)});return i},markEventDefaults:{strokeStyle:"#5BCBF5",lineWidth:"0.5",textStyle:"#5BCBF5",verticalOffset:10,verticalAnchor:"bottom",horizontalAnchor:"right",forceHorizontalAnchor:!1,horizontalAnchorSwapLimit:80,font:"10px sans-serif"},markEvent:function(i,n,a){{var r=this,s=r.axes.base,o=r.axes.ortho,l=s.role,u=s.scale,c=r.data.owner.dimensions(l.grouping.firstDimensionName()); c.type}if(s.isDiscrete()){r._warn("Can only mark events in charts with a continuous base scale.");return r}var h=$.extend({},r.markEventDefaults,a),d=c.read(i,n),f=u(d.value),v=u.range(),p=v[1];if(fp){this._warn("Cannot mark event because it is outside the base scale's domain.");return this}var m=this.plotPanelList[0].pvPanel,g=o.scale.range()[1],b=h.horizontalAnchor;if(!h.forceHorizontalAnchor){var _="right"===b,y=_?p-f:f,x=t.Text.measureWidth(d.label,h.font);x>y&&(b=_?"left":"right")}var S="top"===h.verticalAnchor?h.verticalOffset:g-h.verticalOffset,w=m.add(t.Line).data([0,g]).bottom(e.identity).left(f).lineWidth(h.lineWidth).strokeStyle(h.strokeStyle);w.anchor(b).visible(function(){return!this.index}).top(S).add(t.Label).font(h.font).text(d.label).textStyle(h.textStyle);return r},defaults:{panelSizeRatio:.9,timeSeries:!1,timeSeriesFormat:"%Y-%m-%d"}});e.type("pvc.GridDockingPanel",Tt.BasePanel).add({anchor:"fill",_calcLayout:function(t){function i(e,n){m&&p._group("LayoutCycle "+(T?"- Disaster MODE":"#"+(n+1))); try{var a,r,l,u,c=t.canChange!==!1&&!T&&e>0,h=!1;a=0;r=k.length;for(;r>a;){m&&p._group("SIDE Child #"+(a+1));try{l=o(k[a],c);if(!T&&l){u=!1;if(0!==(l&R)){m&&p._log("SIDE Child #"+(a+1)+" changed overflow paddings");if(!h){h=!0;t.requestPaddings=t.paddings}}if(0!==(l&I))if(e>0){m&&p._log("SIDE Child #"+(a+1)+" changed normal paddings");u=!0}else Tt.debug>=2&&p._warn("SIDE Child #"+(a+1)+" changed paddings but no more iterations possible.");if(0!==(l&P)){T=!0;i(0);return!1}if(u)return!0}}finally{m&&p._groupEnd()}a++}if(h){m&&p._log("Restarting due to overflowPaddings change");return!1}a=0;r=C.length;for(;r>a;){m&&p._group("FILL Child #"+(a+1));try{l=s(C[a],c);if(!T&&l){u=!1;if(0!==(l&I))if(e>0){Tt.debug>=5&&p._log("FILL Child #"+(a+1)+" increased paddings");u=!0}else Tt.debug>=2&&p._warn("FILL Child #"+(a+1)+" increased paddings but no more iterations possible.");if(0!==(l&P)){T=!0;i(0);return!1}if(u)return!0}}finally{m&&p._groupEnd()}a++}return!1}finally{m&&p._groupEnd()}}function n(e,t){for(var i=0;e--;){if(t(e,i)===!1)return!0; i++}return!1}function a(t){var i=t.anchor;if(i)if("fill"===i){C.push(t);var n=t.paddings.resolve(w.referenceSize);b=Vt.resolvedMax(b,n)}else{e.hasOwn(x,i)||e.fail.operationInvalid("Unknown anchor value '{0}'",[i]);k.push(t)}}function r(e,t){m&&p._group("SIDE Child #"+(t+1));try{var i=0,n=e.anchor;w.paddings=h(n,b);e.layout(new zt(_),w);if(e.isVisible){i|=d(n,b,e);l(n,e);u(n,e)}return i}finally{m&&p._groupEnd()}}function s(e,t){var i=0,n=e.anchor;w.paddings=h(n,b);w.canChange=t;e.layout(new zt(_),w);if(e.isVisible){i|=d(n,b,e,t);l(n,e);c(e,n)}return i}function o(i,n){var a=0;if(i.isVisible){var r=i.anchor,s=S[r],o=y[r],l=_[s],u=i[o],v=new zt(e.set({},s,l,o,u));w.paddings=h(r,b);w.canChange=n;i.layout(v,w);if(i.isVisible){a=d(r,b,i,n)|f(r,t.paddings,i,n);a||c(i,i.align)}}return a}function l(t,i){var n;if("fill"===t){t="left";n=g.left+_.width/2-i.width/2}else n=g[t];i.setPosition(e.set({},t,n))}function u(e,t){var i=y[e],n=t[i];g[e]+=n;_[i]-=n}function c(t,i){var n;"fill"===i&&(i="middle"); var a;switch(i){case"top":case"bottom":case"left":case"right":n=i;a=g[n];break;case"middle":n="bottom";a=g.bottom+_.height/2-t.height/2;break;case"center":n="left";a=g.left+_.width/2-t.width/2}t.setPosition(e.set({},n,a))}function h(e,t){var i=new Vt;v(e).forEach(function(e){i.set(e,t[e])});return i}function d(t,i,n,a){var r=n._layoutInfo.requestPaddings,s=0;if(r){if(m&&Tt.debug>=10){p._log("=> clientSize="+Tt.stringify(n._layoutInfo.clientSize));p._log("<= requestPaddings="+Tt.stringify(r))}v(t).forEach(function(e){var t=i[e]||0,n=Math.floor(1e4*(r[e]||0))/1e4,o=n-t,l=Math.max(1,Math.abs(.01*t));if(0!==o&&Math.abs(o)>=l)if(a){s|=I;i[e]=n;m&&p._log("Changed padding "+e+" <- "+n)}else Tt.debug>=2&&p._warn("CANNOT change but child wanted to: "+e+"="+n)});if(s){var o=Vt.names.map(function(e){return(i[e]||0).toFixed(0)}).join("|");if(e.hasOwn(D,o)){Tt.debug>=2&&p._warn("LOOP detected!!!!");s|=P}else D[o]=!0;i.width=i.left+i.right;i.height=i.top+i.bottom}}return s}function f(e,t,i,n){var a=i._layoutInfo.overflowPaddings||M,r=0; m&&Tt.debug>=10&&p._log("<= overflowPaddings="+Tt.stringify(a));v(e).forEach(function(e){if(a.hasOwnProperty(e)){var i=t[e]||0,s=Math.floor(1e4*(a[e]||0))/1e4;s-=g[e];var o=s-i,l=Math.max(1,Math.abs(.05*i));if(o>=l)if(n){r|=R;t[e]=s;m&&p._log("changed overflow padding "+e+" <- "+s)}else Tt.debug>=2&&p._warn("CANNOT change overflow padding but child wanted to: "+e+"="+s)}});if(r){t.width=t.left+t.right;t.height=t.top+t.bottom}return r}function v(e){switch(e){case"left":case"right":return Vt.vnames;case"top":case"bottom":return Vt.hnames;case"fill":return Vt.names}}var p=this;if(p._children){var m=Tt.debug>=5,g=new Vt(0),b=new Vt(0),_=e.copyOwn(t.clientSize),y=Tt.BasePanel.orthogonalLength,x=Tt.BasePanel.relativeAnchor,S=Tt.BasePanel.parallelLength,w={force:!0,referenceSize:t.clientSize},C=[],k=[],D={},P=1,I=2,R=4,M=new Vt,T=!1;m&&p._group("CCC GRID LAYOUT clientSize = "+Tt.stringify(_));try{this._children.forEach(a);m&&p._group("Phase 1 - Determine MARGINS and FILL SIZE from SIDE panels"); try{k.forEach(r)}finally{if(m){p._groupEnd();p._log("Final FILL margins = "+Tt.stringify(g));p._log("Final FILL border size = "+Tt.stringify(_))}}m&&p._group("Phase 2 - Determine COMMON PADDINGS");try{n(9,i)}finally{if(m){p._groupEnd();p._log("Final FILL clientSize = "+Tt.stringify({width:_.width-b.width,height:_.height-b.height}));p._log("Final COMMON paddings = "+Tt.stringify(b))}}t.gridMargins=new Vt(g);t.gridPaddings=new Vt(b);t.gridSize=new zt(_)}finally{m&&p._groupEnd()}}}});e.type("pvc.CartesianGridDockingPanel",Tt.GridDockingPanel).init(function(e,t,i){this.base(e,t,i);this._plotBgPanel=new Tt.PlotBgPanel(e,this)}).add({_getExtensionId:function(){return this.chart.parent?"smallContent":"content"},_createCore:function(t){var i=this.chart,n=i.axes,a=n.x,r=n.y;a.isBound()||(a=null);r.isBound()||(r=null);a&&a.option("Grid")&&(this.xGridRule=this._createGridRule(a));r&&r.option("Grid")&&(this.yGridRule=this._createGridRule(r));this.base(t);i.focusWindow&&this._createFocusWindow(t);var s; s=i.compatVersion()<=1?!(!a.option("EndLine")&&!r.option("EndLine")):e.get(i.options,"plotFrameVisible",!0);s&&(this.pvFrameBar=this._createFrame(t,n));a&&"discrete"!==a.scaleType&&a.option("ZeroLine")&&(this.xZeroLine=this._createZeroLine(a,t));r&&"discrete"!==r.scaleType&&r.option("ZeroLine")&&(this.yZeroLine=this._createZeroLine(r,t))},_createGridRule:function(i){var n=i.scale;if(!n.isNull){var a=i.role.grouping.isDiscrete(),r=this._getAxisGridRootScene(i);if(r){var s=this._layoutInfo.gridMargins,o=this._layoutInfo.gridPaddings,l="x"===i.orientation?"left":"bottom",u=this.anchorLength(l),c=this.anchorOrtho(l),h=this.anchorOpposite(c),d=s[l]+o[l],f=s[c],v=s[h],p=r.leafs().array(),m=p.length;a&&m&&p.push(p[m-1]);var g;this.compatVersion()<=1&&(g=function(e){return function(t){return e.call(this,t.vars.tick.rawValue)}});var b=new Tt.visual.Rule(this,this.pvPanel,{extensionId:i.extensionPrefixes.map(function(e){return e+"Grid"}),wrapper:g}).lock("data",p).lock(u,null).override("defaultColor",e.fun.constant(t.color("#f0f0f0"))).pvMark.antialias(!0)[c](f)[h](v).zOrder(-12).events("none"); if(a){var _=n.range().step/2;b[l](function(e){var t=d+n(e.vars.tick.value),i=this.index===m;return t+(i?_:-_)})}else b[l](function(e){return d+n(e.vars.tick.value)});return b}}},_getAxisGridRootScene:function(e){var t=e.isDiscrete(),i=t?e.domainData():this.data,n=new Tt.visual.CartesianAxisRootScene(null,{panel:this,source:i});if(t)i.childNodes.forEach(function(e){new Tt.visual.CartesianAxisTickScene(n,{source:e,tick:e.value,tickRaw:e.rawValue,tickLabel:e.label})});else{var a=e.ticks||e.calcContinuousTicks();a.forEach(function(t){new Tt.visual.CartesianAxisTickScene(n,{tick:t,tickRaw:t,tickLabel:e.scale.tickFormat(t)})},this)}return n},_createFrame:function(e,t){if(!t.base.scale.isNull&&(!t.ortho.scale.isNull||t.ortho2&&!t.ortho2.scale.isNull)){var i=e.gridMargins,n=i.left,a=i.right,r=i.top,s=i.bottom,o=[];if(this.compatVersion()<=1){o.push("xAxisEndLine");o.push("yAxisEndLine")}o.push("plotFrame");return new Tt.visual.Panel(this,this.pvPanel,{extensionId:o}).pvMark.lock("left",n).lock("right",a).lock("top",r).lock("bottom",s).lock("fillStyle",null).events("none").strokeStyle("#666666").lineWidth(1).antialias(!1).zOrder(-8) }},_createZeroLine:function(i,n){var a=i.scale;if(!a.isNull){var r=a.domain();if(r[0]*r[1]<-1e-12){var s="x"===i.orientation?"left":"bottom",o=this.anchorLength(s),l=this.anchorOrtho(s),u=this.anchorOpposite(l),c=n.gridMargins,h=n.gridPaddings,d=c[s]+h[s]+a(0),f=c[l],v=c[u],p=new Tt.visual.Scene(null,{panel:this});return new Tt.visual.Rule(this,this.pvPanel,{extensionId:i.extensionPrefixes.map(function(e){return e+"ZeroLine"})}).lock("data",[p]).lock(o,null).lock(l,f).lock(u,v).lock(s,d).override("defaultColor",e.fun.constant(t.color("#666666"))).pvMark.events("none").lineWidth(1).antialias(!0).zOrder(-9)}}},_createFocusWindow:function(i){function n(){N[C]=0-P[g];N[k]=L+P[g]+P[x]}function a(){var e=arguments[arguments.length-1],t="end"===e.drag.phase;o._selectingByRubberband=!t;G.render();j.render();var i=N[S],n=N[S]+N[w];if(!p){var a=A-i;i=A-n;n=a}u._updatePosition(i,n,t,!0)}function r(e,t){var i,n,a=e.m,r=a[Y],s=N[Z];switch(t){case"new":i=0;n="begin";break;case"resize-begin":i=s;n="begin"; break;case"move":i=s;n="begin";break;case"resize-end":i=r-N[Y];n="end"}var o=e.min[Y],l=e.max[Y],c={type:t,target:n,point:r,length:i,length0:s,min:o,max:l,minView:0,maxView:A};u._constraintPosition(c);a[Y]=c.point;switch(t){case"resize-begin":c.max=Math.min(c.max,N[Y]+N[Z]);break;case"resize-end":c.min=Math.max(c.min,N[Y])}e.min[Y]=c.min;e.max[Y]=c.max}var s=this,o=s.topRoot,l=s.chart,u=l.focusWindow.base,c=u.axis,h=c.scale;if(!h.isNull){var d=u.option("Resizable"),f=u.option("Movable"),v=c.isDiscrete(),p=l.isOrientationVertical(),m=p?"left":"top",g=p?"top":"left",b=s.anchorOrthoLength(m),_=s.anchorOpposite(m),y=s.anchorOrthoLength(g),x=s.anchorOpposite(g),S=p?"x":"y",w="d"+S,C=p?"y":"x",k="d"+C,D=i.gridMargins,P=i.gridPaddings,I={left:D.left+P.left,right:D.right+P.right,top:D.top+P.top,bottom:D.bottom+P.bottom};I.width=I.left+I.right;I.height=I.top+I.bottom;var R=i.clientSize,M=R[b],T=R[y],A=M-I[b],L=T-I[y],O=P[m],V=P[_],N=new Tt.visual.Scene(null,{panel:this}),B=v?h.range().step:0,z=B/2; N[S]=h(u.begin)-z,N[w]=B+(h(u.end)-z)-N[S],n();var F=function(e){return function(){return N[e]}},E=function(){var e=N[S];return Math.max(0,Math.min(A,e))},W=function(){var e=E(),t=N[S]+N[w];t=Math.max(0,Math.min(A,t));return t-e},q=function(e,t){return new Tt.visual.Bar(s,e,{extensionId:t,normalStroke:!0,noHover:!0,noSelect:!0,noClick:!0,noDoubleClick:!0,noTooltip:!0,showsInteraction:!1}).pvMark.lock("data").lock("visible").lock(m,E).lock(b,W).lock(g,F(C)).lock(y,F(k)).lock(x).lock(_).sign},G=this._plotBgPanel.pvPanel.borderPanel;G.lock("data",[N]);f&&d?G.paddingPanel.lock("events","all").lock("cursor","crosshair").event("mousedown",t.Behavior.select().autoRender(!1).collapse(p?"y":"x").positionConstraint(function(e){var t="start"===e.phase?"new":"resize-end";return r(e,t)})).event("selectstart",function(e){n();a(e)}).event("select",a).event("selectend",a):G.paddingPanel.events("all");var H=q(G.paddingPanel,"focusWindowBg").override("defaultColor",e.fun.constant(Tt.invisibleFill)).pvMark; f?H.lock("events","all").lock("cursor","move").event("mousedown",t.Behavior.drag().autoRender(!1).collapse(p?"y":"x").positionConstraint(function(e){r(e,"move")})).event("drag",a).event("dragend",a):H.events("none");var j=new Tt.visual.Panel(s,s.pvPanel).pvMark.lock("data",[N]).lock("visible").lock("fillStyle",Tt.invisibleFill).lock("left",I.left).lock("right",I.right).lock("top",I.top).lock("bottom",I.bottom).lock("zOrder",10).lock("events",function(){var e=N.drag;return e&&"end"!==e.phase?"all":"none"}).lock("cursor",function(){var e=N.drag;return e&&"end"!==e.phase?"drag"===e.type||"select"===e.type&&!d?"move":p?"ew-resize":"ns-resize":null}).antialias(!1),U="rgba(20, 20, 20, 0.1)";new Tt.visual.Bar(s,j,{extensionId:"focusWindowBaseCurtain",normalStroke:!0,noHover:!0,noSelect:!0,noClick:!0,noDoubleClick:!0,noTooltip:!0,showsInteraction:!1}).override("defaultColor",function(e,t){return"stroke"===t?null:U}).pvMark.lock("data",[N,N]).lock("visible").lock("events","none").lock(m,function(){return this.index?E()+W():-O }).lock(_,function(){return this.index?-V:null}).lock(b,function(){return this.index?null:O+E()}).lock(g,F(C)).lock(y,F(k)).lock(x);var K=q(j,"focusWindow").override("defaultColor",e.fun.constant(null)).pvMark.lock("events","none"),Q=function(i){var n="left"===i||"top"===i?"begin":"end",o=s.anchorOpposite(i),l="linear-gradient(to "+o+", "+U+", #444 90%)",c=new Tt.visual.Bar(s,K.anchor(i),{extensionId:u.id+"Grip"+e.firstUpperCase(n),normalStroke:!0,noHover:!0,noSelect:!0,noClick:!0,noDoubleClick:!0,noTooltip:!0,showsInteraction:!1}).override("defaultColor",function(e,t){return"stroke"===t?null:l}).pvMark.lock("data").lock("visible")[g](N[C])[y](N[k]);if(d){var h="resize-"+n;c.lock("events","all")[b](5).cursor(p?"ew-resize":"ns-resize").event("mousedown",t.Behavior.resize(i).autoRender(!1).positionConstraint(function(e){r(e,h)}).preserveOrtho(!0)).event("resize",a).event("resizeend",a)}else c.events("none")[b](1);return c};Q(m);Q(_);var Y=S,Z=w}},_getDatumsOnRect:function(t,i,n){var a,r,s=this.chart,o=s.axesPanels.x,l=s.axesPanels.y; if(o){a=new e.Map;o._getDatumsOnRect(a,i,n);a.count||(a=null)}if(l){r=new e.Map;l._getOwnDatumsOnRect(r,i,n);r.count||(r=null)}if(a&&r){a.intersect(r,t);n.toggle=!0}else a?t.copy(a):r?t.copy(r):s.plotPanelList.forEach(function(e){e._getDatumsOnRect(t,i,n)},this)}});e.type("pvc.CartesianAbstractPanel",Tt.PlotPanel).init(function(e,t,i,n){function a(e){o[e.type]=e;o[e.orientedId]=e;e.v1SecondOrientedId&&(o[e.v1SecondOrientedId]=e)}function r(e,t){var i=l[e];if(null==i||t>i){u=!0;l[e]=t}}function s(e){var t=e&&e.option("Offset");if(null!=t&&t>0&&1>t)if("x"===e.orientation){r("left",t);r("right",t)}else{r("top",t);r("bottom",t)}}this.base(e,t,i,n);var o=this.axes;a(e._getAxis("base",i.option("BaseAxis")-1));a(e._getAxis("ortho",i.option("OrthoAxis")-1));var l={},u=!1,c=e.axesByType;["base","ortho"].forEach(function(e){var t=c[e];t&&t.forEach(s)});u&&(this.offsetPaddings=l)}).add({offsetPaddings:null,_calcLayout:function(e){e.requestPaddings=this._calcRequestPaddings(e)},_calcRequestPaddings:function(e){var t,i=this.offsetPaddings; if(i){var n=this.chart._getAxesRoundingPaddings(),a=e.clientSize,r=e.paddings;Vt.names.forEach(function(e){var s=Tt.BasePanel.orthogonalLength[e],o=a[s],l=r[s],u=o+l;if(!n[e+"Locked"]){var c=u*(i[e]||0),h=o*(n[e]||0);(t||(t={}))[e]=Math.max(c-h,0)}},this)}return t},_createCore:function(){this.pvPanel.zOrder(-10);var t,i=this.chart.options.leafContentOverflow||"auto";t="auto"===i?e.query(["ortho","base"]).select(function(e){return this.axes[e]},this).any(function(e){return null!=e.option("FixedMin")||null!=e.option("FixedMax")}):"hidden"===i;t&&this.pvPanel.borderPanel.overflow("hidden")}});e.type("pvc.PlotBgPanel",Tt.BasePanel).init(function(e,t,i){this.base(e,t,i)}).add({anchor:"fill",_getExtensionId:function(){return"plotBg"},_createCore:function(e){this.pvPanel.borderPanel.lock("zOrder",-13).antialias(!1);this.base(e)}});e.type("pvc.CategoricalAbstract",Tt.CartesianAbstract).init(function(e){this.base(e);var t=this.parent;t&&(this._catRole=t._catRole)}).add({_interpolatable:!0,_initVisualRoles:function(){this.base(); this._catRole=this._addVisualRole("category",this._getCategoryRoleSpec())},_getCategoryRoleSpec:function(){return{isRequired:!0,defaultDimension:"category*",autoCreateDimension:!0}},_createVisibleData:function(t,i){var n=this._serRole&&this._serRole.flattenedGrouping(),a=this._catRole.flattenedGrouping();return n?t.groupBy(e.get(i,"inverted",!1)?[n,a]:[a,n],i):t.groupBy(a,i)},_interpolateDataCell:function(e,t){var i=this._getNullInterpolationOperType(e.nullInterpolationMode);if(i){this._warnSingleContinuousValueRole(e.role);var n=e.dataPartValue,a=this.partData(n,t),r=this.visibleData(n,{baseData:t});r.childCount()>0&&new i(t,a,r,this._catRole,this._serRole,e.role,!0).interpolate()}},_getNullInterpolationOperType:function(t){switch(t){case"linear":return Tt.data.LinearInterpolationOper;case"zero":return Tt.data.ZeroInterpolationOper;case"none":break;default:throw e.error.argumentInvalid("nullInterpolationMode",""+t)}},_generateTrendsDataCell:function(t,i,n){function a(i){var n=d?null:function(e){return e.atoms[c].value },a=function(e){var t=p.child(e.key);t&&i&&(t=t.child(i.key));return t?t.dimensions(h).value(f):null},r=e.create(l,{rows:e.query(b),x:n,y:a}),s=u.model(r);s&&b.forEach(function(n,r){var o=d?r:n.atoms[c].value,u=s.sample(o,a(n),r);if(null!=u){var f,v=p.child(n.key),b=v||n;if(i){var _=v&&v.child(i.key);if(_)f=Object.create(_._datums[0].atoms);else{f=Object.create(b._datums[0].atoms);e.copyOwn(f,i.atoms)}}else f=Object.create(b._datums[0].atoms);f[h]=u;f[g]=m;t.push(new Tt.data.TrendDatum(b.owner,f,l))}},this)}var r=this._serRole,s=this._catRole,o=i.role,l=i.trend,u=l.info;this._warnSingleContinuousValueRole(o);var c,h=o.firstDimensionName(),d=s.isDiscrete();d||(c=s.firstDimensionName());var f={zeroIfNone:!1},v=this.partData(i.dataPartValue,n),p=this.visibleData(i.dataPartValue,{baseData:n}),m=this._getTrendDataPartAtom(),g=m.dimension.name,b=s.flatten(n,{visible:!0}).childNodes,_=r&&r.isBound()?r.flatten(v,{visible:!0}).children():e.query([null]);_.each(a,this)},_getContinuousVisibleCellExtent:function(t,i){var n=i.role; switch(n.name){case"series":case"category":return this.base(t,i)}this._warnSingleContinuousValueRole(n);var a=i.dataPartValue,r=n.firstDimensionName(),s=this.visibleData(a),o=t.scaleUsesAbs();return"ortho"===t.type&&i.isStacked?s.children().select(function(e){var t=this._getStackedCategoryValueExtent(e,r,o);return t?{range:t,group:e}:void 0},this).where(e.notNully).reduce(function(e,t){return this._reduceStackedCategoryValueExtent(e,t.range,t.group)}.bind(this),null):s.leafs().select(function(e){var t=e.dimensions(r).value();return o&&0>t?-t:t}).range()},_getStackedCategoryValueExtent:function(e,t,i){var n=null,a=null;e.children().select(function(e){var n=e.dimensions(t).value();return i&&0>n?-n:n}).each(function(e){null!=e&&(e>=0?n+=e:a+=e)});return null==n&&null==a?null:{max:n||0,min:a||0}},_reduceStackedCategoryValueExtent:function(e,t){return Tt.unionExtents(e,t)},_coordinateSmallChartsLayout:function(t){this.base(t);var i,n=0,a=null,r={};this.children.forEach(function(t){t.basePanel.layout(); var s,o=t.titlePanel;if(o){i||(i=o.anchorOrthoLength());s=o[i];s>n&&(n=s)}var l=t.axesPanels;a||(a=e.query(e.ownKeys(l)).where(function(e){return e===l[e].axis.id}).select(function(e){r[e]={axis:0,title:0};return e}).array());a.forEach(function(e){var t=l[e],i=r[e],n="x"===t.axis.orientation?"height":"width";s=t[n];s>i.axis&&(i.axis=s);var a=t.titlePanel;if(a){s=a[n];s>i.title&&(i.title=s)}})},this);this.children.forEach(function(e){if(n>0){var t=e.titlePanel;t.size=t.size.clone().set(i,n)}var s=e.axesPanels;a.forEach(function(e){var t=s[e],i=r[e],n="x"===t.axis.orientation?"height":"width";t.size=t.size.clone().set(n,i.axis);var a=t.titlePanel;a&&(a.size=a.size.clone().set(n,i.title))});e.basePanel.invalidateLayout()},this)}});e.type("pvc.CategoricalAbstractPanel",Tt.CartesianAbstractPanel).init(function(e,t,i,n){this.base(e,t,i,n);this.stacked=i.option("Stacked")});e.type("pvc.AxisPanel",Tt.BasePanel).init(function(t,i,n,a){a=e.create(a,{anchor:n.option("Position")});var r=a.anchor||this.anchor; this.axis=n;this.base(t,i,a);this.roleName=n.role.name;this.isDiscrete=n.role.isDiscrete();this._extensionPrefix=n.extensionPrefixes;null==this.labelSpacingMin&&(this.labelSpacingMin=this.isDiscrete?.25:1.5);null==this.showTicks&&(this.showTicks=!this.isDiscrete);if(void 0===a.font){var s=this._getConstantExtension("label","font");s&&(this.font=s)}if(void 0===a.tickLength){var o=+this._getConstantExtension("ticks",this.anchorOrthoLength(r));!isNaN(o)&&isFinite(o)&&(this.tickLength=o)}}).add({pvRule:null,pvTicks:null,pvLabel:null,pvRuleGrid:null,pvScale:null,isDiscrete:!1,roleName:null,axis:null,anchor:"bottom",tickLength:6,scale:null,ruleCrossesMargin:!0,font:"9px sans-serif",labelSpacingMin:null,desiredTickCount:null,showMinorTicks:!0,showTicks:null,hiddenLabelText:"·",_isScaleSetup:!1,_createLogInstanceId:function(){return this.base()+" - "+this.axis.id},getTicks:function(){return this._layoutInfo&&this._layoutInfo.ticks},_calcLayout:function(e){var t=this.axis.scale;if(!this._isScaleSetup){this.pvScale=t; this.scale=t;this.extend(t,"scale");this._isScaleSetup=!0}t.isNull?e.axisSize=0:this._calcLayoutCore(e);return this.createAnchoredSize(e.axisSize,e.clientSize)},_calcLayoutCore:function(e){var t=e.desiredClientSize[this.anchorOrthoLength()];e.axisSize=t;if(this.isDiscrete&&this.useCompositeAxis)null==e.axisSize&&(e.axisSize=50);else{this._readTextProperties(e);this._calcTicks();"discrete"===this.scale.type&&(this._tickIncludeModulo=this._calcDiscreteTicksIncludeModulo());this._calcAxisSizeFromLabel(e);null==e.axisSize&&(e.axisSize=e.requiredAxisSize);this._calcMaxTextLengthThatFits();this._calcOverflowPaddings()}},_calcAxisSizeFromLabel:function(e){this._calcTicksLabelBBoxes(e);this._calcAxisSizeFromLabelBBox(e)},_readTextProperties:function(t){var i=this._getExtension("label","textAngle");t.isTextAngleFixed=null!=i;t.textAngle=e.number.as(i,0);t.textMargin=e.number.as(this._getExtension("label","textMargin"),3);var n=this._getExtension("label","textAlign");"string"!=typeof n&&(n=this.isAnchorTopOrBottom()?"center":"left"==this.anchor?"right":"left"); t.textAlign=n;var a=this._getExtension("label","textBaseline");if("string"!=typeof a)switch(this.anchor){case"right":case"left":case"center":a="middle";break;case"bottom":a="top";break;default:a="bottom"}t.textBaseline=a},_calcAxisSizeFromLabelBBox:function(e){var t=e.maxLabelBBox,i=this._getLabelBBoxQuadrantLength(t,this.anchor),n=this.tickLength+i,a=t.sourceAngle;0===a&&this.isAnchorTopOrBottom()||(n+=this.tickLength);e.requiredAxisSize=n},_getLabelBBoxQuadrantLength:function(e,t){var i;switch(t){case"left":i=-e.x;break;case"right":i=e.x2;break;case"top":i=-e.y;break;case"bottom":i=e.y2}return Math.max(i,0)},_calcOverflowPaddings:function(){this._layoutInfo.canChange?this._calcOverflowPaddingsFromLabelBBox():Tt.debug>=2&&this._warn("Layout cannot change. Skipping calculation of overflow paddings.")},_calcOverflowPaddingsFromLabelBBox:function(){var t=null,i=this,n=i._layoutInfo,a=n.ticks,r=a.length;if(r){var s=n.ticksBBoxes,o=n.paddings,l=i.isAnchorTopOrBottom(),u=l?"left":"bottom",c=l?"right":"top",h=i.scale,d="discrete"===h.type,f=n.clientSize[i.anchorLength()]; this.axis.setScaleRange(f);var v=function(n,r,s,l){var u=i._getLabelBBoxQuadrantLength(n,r);if(u>1){var c=h(d?a[l].value:a[l]),v=s?c-u:c+u,p=Math.max(0,s?-v:v-f);if(p>1){p-=o[r]||0;if(p>1){d&&(p*=1.05);if(t){var m=t[r];(null==m||p>m)&&(t[r]=p)}else t=e.set({},r,p)}}}};s.forEach(function(e,t){v(e,u,!0,t);v(e,c,!1,t)});Tt.debug>=6&&t&&i._log("OverflowPaddings = "+Tt.stringify(t))}n.overflowPaddings=t},_calcMaxTextLengthThatFits:function(){var e=this._layoutInfo;if(this.compatVersion()<=1)e.maxTextWidth=null;else{var i=e.clientSize[this.anchorOrthoLength()],n=Math.min(e.axisSize,i);if(n>=e.requiredAxisSize-this.tickLength)e.maxTextWidth=null;else{var a,r,s=e.maxLabelBBox,o=n-2*this.tickLength;switch(this.anchor){case"left":r=t.vector(0,1);a=t.vector(-o,0);break;case"right":r=t.vector(0,1);a=t.vector(o,0);break;case"top":r=t.vector(1,0);a=t.vector(0,-o);break;case"bottom":r=t.vector(1,0);a=t.vector(0,o)}var l=a.norm(),u=s.source.points(),c=u[0],h=u[1],d=u[2],f=u[3],v=d.minus(f),p=h.minus(c),m=t.SvgScene.lineIntersect,g=m(a,r,c,p),b=m(a,r,f,v),_=s.sourceTextWidth,y=_,x=g.minus(c),S=x.length(); _>=S&&x.dot(v)>=0&&(y=c.dot(l)=C&&w.dot(v)>=0&&(y=f.dot(l)=3&&this._log("Trimming labels' text at length "+y.toFixed(2)+"px maxOrthoLength="+o.toFixed(2)+"px")}}},_calcTicks:function(){var i=this._layoutInfo;i.textHeight=2*t.Text.fontHeight(this.font)/3;i.maxTextWidth=null;this.axis.setTicks(null);switch(this.scale.type){case"discrete":this._calcDiscreteTicks();break;case"timeSeries":this._calcTimeSeriesTicks();break;case"numeric":this._calcNumberTicks(i);break;default:throw e.error.operationInvalid("Undefined axis scale type")}this.axis.setTicks(i.ticks);var n=i.clientSize[this.anchorLength()];this.axis.setScaleRange(n);null==i.maxTextWidth&&this._calcTicksTextLength(i)},_calcDiscreteTicks:function(){var i=this.axis,n=this._layoutInfo;n.ticks=i.domainItems();var a,r,s=i.role.grouping;if(s.isSingleDimension&&(r=s.firstDimensionType())&&r.valueType===Date){var o=e.query(i.domainValues()).range(); if(o&&o.min!==o.max){var l=new t.Scale.linear(o.min,o.max);l.ticks();var u=i.option("TickFormatter");u&&l.tickFormatter(u);var c=i.domainValues();a=function(e,t){return l.tickFormat(c[t])}}}a||(a=function(e){return e.absLabel});n.ticksText=n.ticks.map(a);this._clearTicksTextDeps(n)},_clearTicksTextDeps:function(e){e.maxTextWidth=e.ticksTextLength=e.ticksBBoxes=null},_calcTimeSeriesTicks:function(){this._calcContinuousTicks(this._layoutInfo,this.desiredTickCount)},_calcNumberTicks:function(){var e=this.desiredTickCount;if(null==e){if(this.isAnchorTopOrBottom()){this._calcNumberHTicks();return}e=this._calcNumberVDesiredTickCount()}this._calcContinuousTicks(this._layoutInfo,e)},_calcContinuousTicks:function(e,t){this._calcContinuousTicksValue(e,t);this._calcContinuousTicksText(e)},_calcContinuousTicksValue:function(e,t){e.ticks=this.axis.calcContinuousTicks(t);if(Tt.debug>4){this._log("DOMAIN: "+Tt.stringify(this.scale.domain()));this._log("TICKS: "+Tt.stringify(e.ticks))}},_calcContinuousTicksText:function(e){var t=e.ticksText=e.ticks.map(function(e){return this.scale.tickFormat(e) },this);this._clearTicksTextDeps(e);return t},_calcTicksTextLength:function(e){var i=0,n=this.font,a=e.ticksText||this._calcContinuousTicksText(e),r=e.ticksTextLength=a.map(function(e){var a=t.Text.measureWidth(e,n);a>i&&(i=a);return a});e.maxTextWidth=i;e.ticksBBoxes=null;return r},_calcTicksLabelBBoxes:function(e){var t,i=this,n=i._layoutInfo,a=e.ticksTextLength||i._calcTicksTextLength(e),r=n.maxTextWidth;e.ticksBBoxes=a.map(function(e){var n=i._calcLabelBBox(e);t||e!==r||(t=n);return n},i);n.maxLabelBBox=t},_calcLabelBBox:function(e){var t=this._layoutInfo;return Tt.text.getLabelBBox(e,t.textHeight,t.textAlign,t.textBaseline,t.textAngle,t.textMargin)},_calcDiscreteTicksIncludeModulo:function(){var e=this.axis.option("OverlappedLabelsMode");if("hide"!==e&&"rotatethenhide"!==e)return 1;var i=this._layoutInfo,n=i.ticks,a=n.length;if(2>=a)return 1;var r=this.scale.range().step,s=i.textHeight,o=i.maxTextWidth;if(!(o>0&&s>0&&r>0))return 1;var l=s*this.labelSpacingMin,u=l,c=t.Text.measureWidth("x",this.font),h=c+l,d=i.textAngle,f=this.isAnchorTopOrBottom(),v=Math.abs(Math[f?"sin":"cos"](d)),p=Math.abs(Math[f?"cos":"sin"](d)),m=1e-8>v?1/0:Math.ceil((u+s)/(r*v)),g=1e-8>p?1/0:Math.ceil((h+o)/(r*p)),b=Math.min(m,g); (!isFinite(b)||1>b||Math.ceil(a/b)<2)&&(b=1);return b},_tickMultipliers:[1,2,5,10],_calcNumberVDesiredTickCount:function(){var e=this._layoutInfo,i=e.textHeight*(1+Math.max(0,this.labelSpacingMin)),n=e.clientSize[this.anchorLength()],a=Math.max(1,~~(n/i));if(1>=a)return 1;var r=this.scale.domain(),s=r[1]-r[0];if(0>=s)return a;for(var o,l=s/a,u=Math.floor(t.log(l,10)),c=Math.pow(10,u),h=this._tickMultipliers,d=0;d=l)break}return Math.max(1,Math.floor(s/o))},_calcNumberHTicks:function(){for(var e,t,i,n,a,r=this._layoutInfo,s=r.clientSize[this.anchorLength()],o=r.textHeight*Math.max(0,this.labelSpacingMin),l=this._calcNumberHDesiredTickCount(o),u=Tt.debug>=7;;){u&&this._log("calculateNumberHTicks TickCount IN desired = "+l);i={};this._calcContinuousTicksValue(i,l);var c=i.ticks,h=c.length;if(c.exponentOverflow){if(null!=e){if(1===e){n&&(i=n);break}a&&(i=a);break}if(c.exponent===this.exponentMin){n=i;e=1}else{a=i;e=-1}}else if(null==t||h!==t){u&&this._log("calculateNumberHTicks TickCount desired/resulting = "+l+" -> "+h); t=h;this._calcContinuousTicksText(i);var d=this._calcNumberHLength(i,o),f=i.excessLength=d-s,v=i.error=Math.abs(f/s);if(u){this._log("calculateNumberHTicks error="+(f>=0?"+":"-")+(100*i.error).toFixed(0)+"% count="+h+" step="+c.step);this._log("calculateNumberHTicks Length client/resulting = "+s+" / "+d+" spacing = "+o)}if(f>0){if(1===l){if(3===h&&1>=v){i.ticks.splice(1,1);i.ticksText.splice(1,1);i.ticks.step*=2}else{i.ticks.length=1;i.ticksText.length=1}delete i.maxTextWidth;break}if(n){i=n;break}a=i;e=-1}else{if(.05>=v||-1===e)break;n=i;e=1}}l+=e}if(i){r.ticks=i.ticks;r.ticksText=i.ticksText;r.maxTextWidth=i.maxTextWidth;Tt.debug>=5&&this._log("calculateNumberHTicks RESULT error="+(i.excessLength>=0?"+":"-")+(100*i.error).toFixed(0)+"% count="+i.ticks.length+" step="+i.ticks.step)}u&&this._log("calculateNumberHTicks END")},_calcNumberHDesiredTickCount:function(e){var i=this._layoutInfo,n=this.scale.domain().map(function(e){e=+e.toFixed(2);var i=this.scale.tickFormat(e);return t.Text.measureWidth(i,this.font) },this),a=Math.max((n[1]+n[0])/2,i.textHeight),r=i.clientSize[this.anchorLength()];return Math.max(1,~~(r/(a+e)))},_calcNumberHLength:function(i,n){var a=i.ticksText,r=e.query(a).select(function(e){return t.Text.measureWidth(e,this.font)},this).max();return Math.max(r,(a.length-1)*(r+n))},_createCore:function(){if(!this.scale.isNull){var t=this._layoutInfo.clientSize,i=this._layoutInfo.paddings,n=this.anchorOrtho(),a=this.anchorOpposite(n),r=this.anchorOrthoLength(n),s=this.ruleCrossesMargin?-i[n]:0,o=t[r]+(this.ruleCrossesMargin?i[a]:0),l=o-s;this._rSize=l;var u=this._getRootScene();this.pvRule=new Tt.visual.Rule(this,this.pvPanel,{extensionId:"rule"}).lock("data",[u]).override("defaultColor",e.fun.constant("#666666")).lock(this.anchorOpposite(),0).lock(n,s).lock(r,l).pvMark.zOrder(30).strokeDasharray(null).lineCap("square");this.isDiscrete?this.useCompositeAxis?this.renderCompositeOrdinalAxis():this.renderOrdinalAxis():this.renderLinearAxis()}},_getExtensionId:function(){return""},_getRootScene:function(){if(!this._rootScene){var e=this._rootScene=new Tt.visual.CartesianAxisRootScene(null,{panel:this,source:this._getRootData()}),t=this._layoutInfo,i=t.ticks,n=t.ticksText; if(this.isDiscrete)if(this.useCompositeAxis)this._buildCompositeScene(e);else{var a=this._tickIncludeModulo,r=this.hiddenLabelText;e.vars.tickIncludeModulo=a;e.vars.hiddenLabelText=r;var s,o,l,u;if(a>2){Tt.debug>=3&&this._info("Showing only one in every "+a+" tick labels");var c=e.group.owner.keySep;l=function(){var t=s.map(function(e){return e.key}).join(c),i=o.slice(0,10).join(", ")+(o.length>10?", ...":""),n=new Tt.visual.CartesianAxisTickScene(e,{source:s,tick:t,tickRaw:t,tickLabel:i,isHidden:!0});n.dataIndex=u;s=o=u=null}}i.forEach(function(t,i){var r=i%a!==0;if(r&&a>2){null==u&&(u=i);(s||(s=[])).push(t);(o||(o=[])).push(n[i])}else{s&&l();var c=new Tt.visual.CartesianAxisTickScene(e,{source:t,tick:t.value,tickRaw:t.rawValue,tickLabel:n[i],isHidden:r});c.dataIndex=i}});s&&l()}else i.forEach(function(t,i){var a=new Tt.visual.CartesianAxisTickScene(e,{tick:t,tickRaw:t,tickLabel:n[i]});a.dataIndex=i},this)}return this._rootScene},_buildCompositeScene:function(e){function t(e){var n=e.group; if(i){var a=e.vars.tick;e.nodeValue=e.value=a.rawValue;e.nodeLabel=e.label=a.label}n.childCount()&&n.children().each(function(i){var n=new Tt.visual.CartesianAxisTickScene(e,{source:i,tick:i.value,tickRaw:i.rawValue,tickLabel:i.label});n.dataIndex=i.childIndex();t(n)})}var i=this.compatVersion()<=1;e.vars.tick=new jt("","");t(e)},_getRootData:function(){var e;if(this.isDiscrete&&this.useCompositeAxis){var t=this.anchor,i={visible:this.axis.domainVisibleOnly()?!0:null,isNull:this.chart.options.ignoreNulls||this.axis.domainIgnoreNulls()?!1:null,reverse:"bottom"==t||"left"==t};e=this.axis.role.select(this.data,i)}else e=this.data;return e},renderOrdinalAxis:function(){var e,i=this.scale,n=this.hiddenLabelText,a=this._tickIncludeModulo,r=a*i.range().step/2,s=this.anchorOpposite(),o=this.anchorLength(),l=this.anchorOrtho(),u=this.anchorOrthoLength(),c=this.pvRule,h=this._getRootScene(),d=this._layoutInfo,f=this.compatVersion()<=1;if(f){var v=function(e){this.value=this.absValue=e.rawValue;this.nodeName=""+(this.value||""); this.path=this.nodeName?[this.nodeName]:[];this.label=this.absLabel=e.label};v.prototype.toString=function(){return""+this.value};e=function(e){return function(t){var i=Object.create(this);i.index=this.parent.index;return e.call(i,new v(t.vars.tick))}}}var p=new Tt.visual.Panel(this,this.pvPanel,{extensionId:"ticksPanel"}).lock("data",h.childNodes).lock(s,0).lockMark(l,function(e){return e.isHidden?i(e.previousSibling.vars.tick.value)+r:i(e.vars.tick.value)}).lock("strokeDasharray",null).lock("strokeStyle",null).lock("fillStyle",null).lock("lineWidth",0).pvMark.zOrder(20);if(f||this.showTicks){this.pvTicks=new Tt.visual.Rule(this,p,{extensionId:"ticks",wrapper:e}).lock("data").intercept("visible",function(e){return!e.isHidden&&this.delegateExtension(!0)}).optional("lineWidth",1).lock(s,0).lock(l,0).lock(o,null).optional(u,2*this.tickLength/3).override("defaultColor",function(){return f?t.Color.names.transparent:c.scene?c.scene[0].strokeStyle:"#666666"}).pvMark}var m=this.font,g=this._layoutInfo.maxTextWidth; isFinite(g)||(g=0);this.pvLabel=new Tt.visual.Label(this,p,{extensionId:"label",showsInteraction:!0,noClick:!1,noDoubleClick:!1,noSelect:!1,noTooltip:!1,noHover:!1,wrapper:e}).intercept("visible",function(e){return e.isHidden?!!e.vars.hiddenLabelText:this.delegateExtension(!0)}).intercept("text",function(e){var t;if(e.isHidden)t=n;else{t=this.delegateExtension();void 0===t&&(t=e.vars.tick.label);!g||this.showsInteraction()&&e.isActive||(t=Tt.text.trimToWidthB(g,t,m,"..",!1))}return t}).pvMark.zOrder(40).lock(s,this.tickLength).lock(l,0).font(m).textStyle("#666666").textAlign(d.textAlign).textBaseline(d.textBaseline);this._debugTicksPanel(p)},_getTooltipFormatter:function(e){if(this.axis.option("TooltipEnabled")){e.gravity=this._calcTipsyGravity();var t=this.axis.option("TooltipFormat");if(t)return function(e){return t.call(e,e.scene)};var i=this.axis.option("TooltipAutoContent");if("summary"===i)return this._summaryTooltipFormatter;if("value"===i){e.isLazy=!1;return function(e){return e.scene.vars.tick.label }}}},_debugTicksPanel:function(e){if(Tt.debug>=16){var i=(this.font,this._layoutInfo),n=i.ticksBBoxes||this._calcTicksLabelBBoxes(i);e.add(t.Panel)[this.anchorOpposite()](this.tickLength)[this.anchorOrtho()](0)[this.anchorLength()](0)[this.anchorOrthoLength()](0).fillStyle(null).strokeStyle(null).lineWidth(0).visible(function(e){return!e.isHidden}).add(t.Line).data(function(e){var t=n[e.dataIndex],i=t.source.points();i.length>1&&(i=i.concat(i[0]));return i}).left(function(e){return e.x}).top(function(e){return e.y}).strokeStyle("red").lineWidth(.5).strokeDasharray("-")}},renderLinearAxis:function(){var e,i=this.scale,n=this.pvRule,a=this.anchorOpposite(),r=this.anchorLength(),s=this.anchorOrtho(),o=this.anchorOrthoLength(),l=this._getRootScene();this.compatVersion()<=1&&(e=function(e){return function(t){var i=Object.create(this);i.index=this.parent.index;return e.call(i,t.vars.tick.rawValue)}});var u=new Tt.visual.Panel(this,this.pvPanel,{extensionId:"ticksPanel"}).lock("data",l.childNodes).lock(a,0).lockMark(s,function(e){return i(e.vars.tick.value) }).lock("strokeStyle",null).lock("fillStyle",null).lock("lineWidth",0).pvMark.zOrder(20);if(this.showTicks){var c=this.pvTicks=new Tt.visual.Rule(this,u,{extensionId:"ticks",wrapper:e}).lock("data").override("defaultColor",function(){return n.scene?n.scene[0].strokeStyle:"#666666"}).lock(a,0).lock(s,0).lock(r,null).optional(o,this.tickLength).pvMark;if(this.showMinorTicks){var h=this._layoutInfo,d=h.ticks,f=d.length,v=f>1?Math.abs(i(d[1])-i(d[0]))/2:0;this.pvMinorTicks=new Tt.visual.Rule(this,this.pvTicks,{extensionId:"minorTicks",wrapper:e}).lock("data").intercept("visible",function(e){var t=e.childIndex()=t)return"left"}else if(this.index===e.parent.childNodes.length-1){t=s.toScreenTransform().transformHPosition(s.left());if(t>=o.width())return"right"}return"center"}):s.textAlign(i).textBaseline(function(e){var t;if(0===this.index){t=s.toScreenTransform().transformVPosition(s.top());if(t>=o.height())return"bottom"}else if(this.index===e.parent.childNodes.length-1){t=s.toScreenTransform().transformVPosition(s.top());if(0>=t)return"top"}return"middle"}) },_onV1Click:function(e,t){this.isDiscrete&&this.useCompositeAxis&&t.call(e.pvMark,e.scene,e.event)},_onV1DoubleClick:function(e,t){this.isDiscrete&&this.useCompositeAxis&&t.call(e.pvMark,e.scene,e.event)},_getSelectableMarks:function(){return this.isDiscrete&&this.isVisible&&this.pvLabel?this.base():void 0},renderCompositeOrdinalAxis:function(){var i=this.isAnchorTopOrBottom(),n=i?"h":"v",a=2,r=2,s=this.font,o=t.Text.fontHeight(s)/2,l=this._pvLayout=this._getCompositeLayoutSingleCluster();l.node.def("fitInfo",null).height(function(e){var t=Tt.text.getFitInfo(e.dx,e.dy,e.vars.tick.label,s,o);t.h||("v"===n&&t.v?r=Math.min(a,e.depth):a=Math.min(a,e.depth));this.fitInfo(t);return e.dy});l.node.add(t.Bar).fillStyle("rgba(127,127,127,.001)").strokeStyle(function(e){return 1!==e.maxDepth&&e.maxDepth?"rgba(127,127,127,0.3)":null}).lineWidth(function(e){return 1!==e.maxDepth&&e.maxDepth?.5:0}).text(function(e){return e.vars.tick.label});var u,c=.3,h=1.27,d=i?"center":"left"==this.anchor?"right":"left"; this.compatVersion()<=1&&(u=function(e){return function(t){return e.call(this,t)}});this.pvLabel=new Tt.visual.Label(this,l.label,{extensionId:"label",noClick:!1,noDoubleClick:!1,noSelect:!1,noTooltip:!1,noHover:!1,showsInteraction:!0,wrapper:u,tooltipArgs:{options:{offset:2*o}}}).pvMark.def("lblDirection","h").textAngle(function(e){if(e.depth>=r&&e.depth=a){var t=e.dy/e.dx,i=Math.atan(t);if(i>h){this.lblDirection("v");return-Math.PI/2}if(i>c){this.lblDirection("d");return-i}}this.lblDirection("h");return 0}).textMargin(1).textAlign(function(e){return"v"!=n||e.depth>=r||e.depth>=a?"center":d}).left(function(e){return"v"!=n||e.depth>=r||e.depth>=a?e.x+e.dx/2:"right"==d?e.x+e.dx:e.x}).font(s).textStyle("#666666").text(function(t){var i=t.vars.tick.label;if(!t.isActive||!this.sign.showsInteraction()){var n=this.fitInfo();switch(this.lblDirection()){case"h":if(!n.h)return Tt.text.trimToWidthB(t.dx,i,s,"..");break;case"v":if(!n.v)return Tt.text.trimToWidthB(t.dy,i,s,".."); break;case"d":if(!n.d){var a=Math.sqrt(e.sqr(t.dy)+e.sqr(t.dx));return Tt.text.trimToWidthB(a-o,i,s,"..")}}}return i})},_getCompositeLayoutSingleCluster:function(){var i=this._getRootScene(),n=this.anchor,a=i.group.treeHeight,r=this._layoutInfo.axisSize;a++;var s=r/a,o=a>2?1/12*r:0;s-=o;var l=a/(a-1),u=Tt.BasePanel.orthogonalLength[n],c="width"==u?"left"===n?[-s,0]:[s,0]:"top"===n?[0,-s]:[0,s];this.pvRule.sign.override("defaultColor",e.fun.constant(null)).override("defaultStrokeWidth",e.fun.constant(0));var h=this.pvRule.add(t.Panel)[u](r).strokeStyle(null).lineWidth(0).add(t.Panel)[u](r*l).strokeStyle(null).lineWidth(0);h.transform(t.Transform.identity.translate(c[0],c[1]));return h.add(t.Layout.Cluster.Fill).nodes(i.nodes()).orient(n)},_calcTipsyGravity:function(){switch(this.anchor){case"bottom":return"s";case"top":return"n";case"left":return"w";case"right":return"e"}return"s"}});e.type("pvc.AxisTitlePanel",Tt.TitlePanelAbstract).init(function(e,t,i,n){this.axis=i;this.base(e,t,n);this._extensionPrefix=i.extensionPrefixes.map(function(e){return e+"Title" })}).add({_calcLayout:function(e){var t=this.axis.scale;return!t||t.isNull?new zt(0,0):this.base(e)},_createCore:function(e){var t=this.axis.scale;return t&&!t.isNull?this.base(e):void 0}});e.type("pvc.PiePanel",Tt.PlotPanel).init(function(e,t,i,n){var a=i.option("ValuesLabelStyle");this.base(e,t,i,n);this.explodedOffsetRadius=i.option("ExplodedSliceRadius");this.explodedSliceIndex=i.option("ExplodedSliceIndex");this.activeOffsetRadius=i.option("ActiveSliceRadius");this.labelStyle=a;if("linked"===a){this.linkInsetRadius=i.option("LinkInsetRadius");this.linkOutsetRadius=i.option("LinkOutsetRadius");this.linkMargin=i.option("LinkMargin");this.linkHandleWidth=i.option("LinkHandleWidth");this.linkLabelSize=i.option("LinkLabelSize");this.linkLabelSpacingMin=i.option("LinkLabelSpacingMin")}}).add({pvPie:null,pvPieLabel:null,valueRoleName:"value",_getV1Datum:function(e){var t=e.datum;if(t){var i=Object.create(t);i.percent=e.vars.value.percent;t=i}return t},_calcLayout:function(i){function n(t){return e.between(Nt.resolve(t,o),0,o) }function a(t){return e.between(Nt.resolve(t,s),0,s)}var r=i.clientSize,s=r.width,o=Math.min(s,r.height)/2;if(!o)return new zt(0,0);var l=t.vector(r.width/2,r.height/2),u=this._getConstantExtension("label","font");e.string.is(u)||(u=this.valuesFont);var c=o;if(this.valuesVisible&&"linked"===this.labelStyle){var h=n(this.linkInsetRadius),d=n(this.linkOutsetRadius),f=a(this.linkMargin),v=a(this.linkLabelSize),p=e.number.to(this._getConstantExtension("label","textMargin"),3),m=2*t.Text.fontHeight(u)/3,g=this.linkHandleWidth*m;f+=g;var b=this.linkLabelSpacingMin*m,_=Math.max(0,s/2-o),y=Math.max(0,d+f+v-_),x=d+m,S=Math.max(0,x,y);if(S>=c){this.valuesVisible=!1;Tt.debug>=2&&this._log("Hiding linked labels due to insufficient space.")}else{c-=S;i.link={insetRadius:h,outsetRadius:d,elbowRadius:c+d,linkMargin:f,handleWidth:g,labelSize:v,maxTextWidth:v-p,labelSpacingMin:b,textMargin:p,lineHeight:m}}}var w=n(this.explodedOffsetRadius),C=0;this.hoverable()&&(C=n(this.activeOffsetRadius));var k=w+C,D=c-k; if(0>D)return new zt(0,0);i.resolvePctRadius=n;i.center=l;i.clientRadius=o;i.normalRadius=D;i.explodedOffsetRadius=w;i.activeOffsetRadius=C;i.maxOffsetRadius=k;i.labelFont=u},_createCore:function(i){var n,a=this,r=a.chart,s=this._buildScene(),o=i.center,l=i.normalRadius,u=["slice"];if(this.compatVersion()<=1){u.push("");n=function(e){return function(t){return e.call(this,t.vars.value.value)}}}this.pvPie=new Tt.visual.PieSlice(this,this.pvPanel,{extensionId:u,center:o,activeOffsetRadius:i.activeOffsetRadius,maxOffsetRadius:i.maxOffsetRadius,resolvePctRadius:i.resolvePctRadius,wrapper:n,tooltipArgs:{options:{useCorners:!0,gravity:function(){var e=this.midAngle(),t=Math.cos(e)>=0,i=Math.sin(e)>=0;return t?i?"nw":"sw":i?"ne":"se"}}}}).lock("data",s.childNodes).override("angle",function(e){return e.vars.value.angle}).override("defaultOffsetRadius",function(){var e=a.explodedSliceIndex;return null==e||e==this.pvMark.index?i.explodedOffsetRadius:0}).lockMark("outerRadius",function(){return r.animate(0,l) }).localProperty("innerRadiusEx",Nt.parse).intercept("innerRadius",function(){var e=this.delegateExtension();if(null==e){var t=this.pvMark.innerRadiusEx();e=null!=t?Nt.resolve(t,this.pvMark.outerRadius())||0:0}return e>0?r.animate(0,e):0}).pvMark;if(this.valuesVisible){this.valuesFont=i.labelFont;if("inside"===this.labelStyle)this.pvPieLabel=Tt.visual.ValueLabel.maybeCreate(this,this.pvPie,{wrapper:n}).override("defaultText",function(e){return e.vars.value.sliceLabel}).override("calcTextFitInfo",function(e,i){var n=this.pvMark,r=n.textMargin();if(!(-1e-6>r)){var s=n.textBaseline();if("middle"===s){var o=Tt.normAngle(a.pvPie.midAngle()),l=Tt.normAngle(n.textAngle()),u=Math.abs(o-l)<1e-6,c=!1;if(!u){var h=Tt.normAngle(l+Math.PI);c=Math.abs(o-h)<1e-6}if(u||c){var d=n.name(),f=n.textAlign(),v="outer"===d?f===(u?"right":"left"):!1;if(v){var p=!1,m=t.Text.measure(i,n.font()),g=.85*m.height,b=a.pvPie.outerRadius(),_=a.pvPie.innerRadius(),y=e.vars.value.angle,x=g+r/2,S=y=w;w-=r;p|=this.hideOverflowed&&m.width>w;return{hide:p,widthMax:w}}}}}}).pvMark.textMargin(10);else if("linked"===this.labelStyle){var c=i.link;s.layoutLinkLabels(i);this.pvLinkPanel=this.pvPanel.add(t.Panel).data(s.childNodes).localProperty("pieSlice").pieSlice(function(){return a.pvPie.scene[this.index]});var h=!1,d=!0;this.pvLinkLine=new Tt.visual.Line(this,this.pvLinkPanel,{extensionId:"linkLine",freePosition:d,noClick:d,noDoubleClick:d,noSelect:d,noTooltip:d,noHover:d,showsActivity:h}).lockMark("data",function(e){var t=this.parent.pieSlice(),i=t.startAngle+t.angle/2,n=t.outerRadius-c.insetRadius,a=t.left+n*Math.cos(i),r=t.top+n*Math.sin(i),s=e.childNodes[0];if(s&&s._isFirstDynamicScene){s.x=a;s.y=r}else{s=new Tt.visual.PieLinkLineScene(e,a,r,0);s._isFirstDynamicScene=d}return e.childNodes}).override("defaultColor",function(e,t){return"stroke"===t?"black":this.base(e,t)}).override("defaultStrokeWidth",e.fun.constant(.5)).pvMark.lock("visible").lock("top",function(e){return e.y }).lock("left",function(e){return e.x});this.pvPieLabel=new Tt.visual.Label(this,this.pvLinkPanel,{extensionId:"label",noClick:h,noDoubleClick:h,noSelect:h,noHover:h,showsInteraction:d}).lockMark("data",function(e){return e.lineScenes}).intercept("textStyle",function(e){this._finished=h;var t=this.delegate();t&&!this._finished&&!this.mayShowActive(e)&&this.mayShowNotAmongSelected(e)&&(t=this.dimColor(t,"text"));return t}).pvMark.lock("visible").left(function(e){return e.vars.link.labelX}).top(function(e){return e.vars.link.labelY+(this.index+1)*c.lineHeight}).textAlign(function(e){return e.vars.link.labelAnchor}).textMargin(c.textMargin).textBaseline("bottom").text(function(e){return e.vars.link.labelLines[this.index]});if(Tt.debug>=20){this.pvPanel.add(t.Panel).zOrder(-10).left(o.x-i.clientRadius).top(o.y-i.clientRadius).width(2*i.clientRadius).height(2*i.clientRadius).strokeStyle("red");this.pvPanel.strokeStyle("green");var f=t.Colors.category10();this.pvLinkLine.segmented(d).strokeStyle(function(){return f(this.index) })}}this.pvPieLabel.font(i.labelFont)}},_getExtensionId:function(){var e=[{abs:"content"}];this.chart.parent&&e.push({abs:"smallContent"});return e.concat(this.base())},renderInteractive:function(){this.pvPanel.render()},_buildScene:function(){var e=new Tt.visual.PieRootScene(this);this.sum=e.vars.sumAbs.value;return e}});e.type("pvc.visual.PieRootScene",Tt.visual.Scene).init(function(t){function i(e,t){if(t){var i=t._datums;if(1===i.length)return i[0].atoms[s].label}return o.format(e)}var n=t.axes.category,a=n.domainData();this.base(null,{panel:t,source:a});var r=new Tt.visual.RoleVarHelper(this,t.visualRoles.color,{roleVar:"color"}),s=t.visualRoles[t.valueRoleName].firstDimensionName(),o=a.dimensions(s),l=t.chart.options.percentValueFormat,u=t.axes.angle.scale,c=u.isNull?0:u.domain()[1];this.vars.sumAbs=new jt(c,i(c));var h=this,d=e.type(Tt.visual.PieCategoryScene).init(function(e,t){this.base(h,{source:e});this.vars.category=jt.fromComplex(e);var n=new jt(t,i(t,e));n.angle=u(t);var a=Math.abs(t)/c; n.percent=new jt(a,l(a));this.vars.value=n;n.sliceLabel=this.sliceLabel();r.onNewScene(this,!0)});t._extendSceneType("category",d,["sliceLabel","sliceLabelMask"]);var f=n.domainItems();if(f.length){f.forEach(function(e){var t=e.dimensions(s).value();0!==t&&new d(e,t)});if(!h.childNodes.length&&!t.visualRoles.multiChart.isBound())throw new InvalidDataException("Unable to create a pie chart, please check the data values.")}}).add({layoutLinkLabels:function(e){var t=-Math.PI/2,i=[],n=[];this.childNodes.forEach(function(a){t=a.layoutI(e,t);(a.vars.link.dir>0?n:i).push(a)});this._distributeLabels(-1,i,e);this._distributeLabels(1,n,e)},_distributeLabels:function(t,i,n){i.sort(function(t,i){return e.compare(t.vars.link.targetY,i.vars.link.targetY)});this._distributeLabelsDownwards(i,n)&&this._distributeLabelsUpwards(i,n)&&this._distributeLabelsEvenly(i,n);i.forEach(function(e){e.layoutII(n)})},_distributeLabelsDownwards:function(e,t){for(var i=t.link,n=i.labelSpacingMin,a=t.clientSize.height,r=!1,s=0,o=e.length-1;o>s;s++){var l=e[s].vars.link; !s&&l.labelTop()<0&&(r=!0);var u=e[s+1].vars.link,c=l.labelBottom()+n;if(u.labelTop()f){r=!0;u.targetY=f}else u.targetY=d}}return r},_distributeLabelsUpwards:function(e,t){for(var i=t.link,n=i.labelSpacingMin,a=!1,r=e.length-1;r>0;r--){var s=e[r-1].vars.link,o=e[r].vars.link;1===r&&s.labelTop()<0&&(a=!0);var l=o.labelTop()-n;if(s.labelBottom()>l){var u=s.labelHeight/2,c=l-u,h=u;if(h>c){a=!0;s.targetY=h}else s.targetY=c}}return a},_distributeLabelsEvenly:function(e,t){var i=0;e.forEach(function(e){i+=e.vars.link.labelHeight});var n=t.clientSize.height-i,a=n;e.length>1&&(a/=e.length-1);var r=0;e.forEach(function(e){var t=e.vars.link,i=t.labelHeight/2;r+=i;t.targetY=r;r+=i+a});return!0}});e.type("pvc.visual.PieLinkLabelVar").add({labelTop:function(){return this.targetY-this.labelHeight/2},labelBottom:function(){return this.targetY+this.labelHeight/2}});e.type("pvc.visual.PieCategoryScene",Tt.visual.Scene).add({sliceLabelMask:function(){return this.panel().valuesMask },sliceLabel:function(){return this.format(this.sliceLabelMask())},layoutI:function(t,i){var n=this.vars.value,a=i+n.angle,r=(i+a)/2,s=this.vars.link=new Tt.visual.PieLinkLabelVar,o=t.link,l=Tt.text.justify(n.sliceLabel,o.maxTextWidth,t.labelFont),u=l.length;s.labelLines=l;s.labelHeight=u*o.lineHeight;this.lineScenes=e.array.create(u,this);var c=Math.cos(r),h=Math.sin(r),d=c>=0,f=d?1:-1;s.labelAnchor=d?"left":"right";var v=t.center,p=o.elbowRadius,m=v.x+p*c,g=v.y+p*h,b=v.x+f*p,_=b+f*o.linkMargin;new Tt.visual.PieLinkLineScene(this,m,g);new Tt.visual.PieLinkLineScene(this,b,g);s.elbowY=g;s.targetY=g+0;s.targetX=_;s.dir=f;return a},layoutII:function(e){var t=this.vars.link,i=t.targetY,n=t.targetX,a=e.link.handleWidth;a>0&&new Tt.visual.PieLinkLineScene(this,n-t.dir*a,i);new Tt.visual.PieLinkLineScene(this,n,i);t.labelX=n;t.labelY=i-t.labelHeight/2}});e.type("pvc.visual.PieLinkLineScene",Tt.visual.Scene).init(function(e,t,i,n){this.base(e,{source:e.group,index:n});this.x=t;this.y=i}).add(t.Vector); e.type("pvc.PieChart",Tt.BaseChart).add({_animatable:!0,_axisClassByType:{category:Tt.visual.Axis,angle:Tt.visual.NormalizedAxis},_axisCreateChartLevel:{category:2,angle:2},_axisSetScaleChartLevel:{category:2,angle:2},_axisCreationOrder:function(){var e=Tt.BaseChart.prototype._axisCreationOrder.slice();e.push("category","angle");return e}(),pieChartPanel:null,_getColorRoleSpec:function(){return{isRequired:!0,defaultSourceRole:"category",defaultDimension:"color*",requireIsDiscrete:!0}},_initVisualRoles:function(){this.base();this._addVisualRole("category",{isRequired:!0,defaultDimension:"category*",autoCreateDimension:!0});this._addVisualRole("value",{isMeasure:!0,isRequired:!0,isPercent:!0,requireSingleDimension:!0,requireIsDiscrete:!1,valueType:Number,defaultDimension:"value"})},_initPlotsCore:function(){new Tt.visual.PiePlot(this)},_createVisibleData:function(e,t){return this.visualRoles.category.flatten(e,t)},_setAxisScale:function(e,t){this.base(e,t);2&t&&"angle"===e.type&&e.setScaleRange({min:0,max:2*Math.PI}) },_createContent:function(t){this.base();var i=this.compatVersion()<=1;if(i){var n=Tt.castNumber(this.options.innerGap)||.95;n=e.between(n,.1,1);t.paddings=(100*(1-n)/2).toFixed(2)+"%"}else null==t.paddings&&(t.paddings=new Nt(.025));var a=this.plots.pie;this.pieChartPanel=new Tt.PiePanel(this,this.basePanel,a,e.create(t,{scenes:e.getPath(this.options,"pie.scenes")}))}});e.type("pvc.BarAbstractPanel",Tt.CategoricalAbstractPanel).add({pvBar:null,pvBarLabel:null,pvCategoryPanel:null,pvSecondLine:null,pvSecondDot:null,_creating:function(){var e=this.defaultLegendGroupScene();if(e&&!e.hasRenderer()){var t=e.colorAxis,i=t.option("LegendDrawLine"),n=!i||t.option("LegendDrawMarker");if(n){var a={drawMarker:!0,markerShape:t.option("LegendShape"),drawRule:i,markerPvProto:new At};this.extend(a.markerPvProto,"",{constOnly:!0});e.renderer(new Tt.visual.legend.BulletItemDefaultRenderer(a))}}},_createCore:function(){this.base();var e,i,n=this,a=n.chart,r=n.plot,s=!!n.stacked,o=n.isOrientationVertical(),l=n.visibleData({ignoreNulls:!1}),u=n.axes.ortho,c=n.axes.base,h=c.domainItems(),d=n.visualRoles.series.flatten(n.partData(),{visible:!0,isNull:a.options.ignoreNulls?!1:null}).childNodes,f=n._buildScene(l,d,h),v=u.scale,p=v(0),m=u.sceneScale({sceneVarName:"value",nullToZero:!1}),g=c.sceneScale({sceneVarName:"category"}),b=r.option("BarSizeRatio"),_=r.option("BarSizeMax"),y=r.option("BarStackedMargin"),x=r.option("BarOrthoSizeMin"),S=c.scale.range(),w=S.band,C=S.step,k=S.margin,D=o===s; if(s)e=w;else{i=d.length;e=i?1===i?w:b*w/i:0}e>_&&(e=_);n.barWidth=e;n.barStepWidth=C;var P;n.compatVersion()<=1&&(P=function(e){return function(t){var i=Object.create(this.parent),n=Object.create(this);n.parent=i;var a=t.parent.childIndex(),r=t.childIndex();if(s){i.index=a;n.index=r}else{i.index=r;n.index=a}return e.call(n,t.vars.value.rawValue)}});n.pvBarPanel=new Tt.visual.Panel(n,n.pvPanel,{panelType:t.Layout.Band,extensionId:"panel"}).lock("layers",f.childNodes).lockMark("values",function(e){return e.childNodes}).lockMark("orient",o?"bottom-left":"left-bottom").lockMark("layout",s?"stacked":"grouped").lockMark("verticalMode",n._barVerticalMode()).lockMark("yZero",p).optionalMark("hZero",x).pvMark.band.x(g).w(w).differentialControl(n._barDifferentialControl()).item.order(D?"reverse":null).h(function(e){var t=m(e);return null!=t?a.animate(0,t-p):null}).w(e).horizontalRatio(b).verticalMargin(y).end;var I=4>=e||2>k,R=this.pvBar=new Tt.visual.Bar(n,n.pvBarPanel.item,{extensionId:"",freePosition:!0,wrapper:P}).lockDimensions().pvMark.antialias(function(e){if(I)return!0; var t=m(e),i=null==t?0:Math.abs(t-p);return 1e-8>i});r.option("OverflowMarkersVisible")&&this._addOverflowMarkers(P);var M=Tt.visual.ValueLabel.maybeCreate(n,R,{wrapper:P});if(M){var T;if(M.hideOrTrimOverflowed){T=w;!s&&i>1&&(T/=i)}n.pvBarLabel=M.override("calcTextFitInfo",function(e,i){var n=this.pvMark,a=n.textMargin();if(!(-1e-6>a)){var r=n.textAngle(),s=Math.sin(r),l=Math.abs(s)<1e-6,u=!l&&Math.abs(Math.cos(r))<1e-6;if(l||u&&o){var c,h,d,f=R.height(),v=R.width(),p=o?f:v,m=o?v:f,g=t.Text.measure(i,n.font()),b=.75*g.height,_=g.width,y=n.name(),x=n.textBaseline(),S=n.textAlign(),w="center"===y,C=!1;if(o)if(l){h=w||y===x;if(!h)return;C|=w&&"middle"!==x?b+a>p/2:b+2*a>p}else{C|=b>p;d="center"===S;h=w;h||d||(h=s>=1e-6?"left"===S?"top"===y:"bottom"===y:"left"===S?"bottom"===y:"top"===y);if(h){c=!w||d?p-2*a:(p-a)/2;C|=("middle"===x?b>m:b>m/2)||this.hideOverflowed&&_>c}else C|=b>=Math.max(m,T)}else{C|=b>p;h=w||y===S;if(h){c=w&&"center"!==S?(p-a)/2:p-2*a;C|=("middle"===x?b>m:b>m/2)||this.hideOverflowed&&_>c }else C|=b>=Math.max(m,T)}return{hide:C,widthMax:c}}}}).pvMark}},_barVerticalMode:function(){return null},_barDifferentialControl:function(){return null},_getV1Datum:function(e){var t=e.datum;if(t){var i=Object.create(t);i.percent=e.vars.value.percent;t=i}return t},_addOverflowMarkers:function(e){var t=this.axes.ortho;null!=t.option("FixedMax")&&(this.pvOverflowMarker=this._addOverflowMarker(!1,t.scale,e));null!=t.option("FixedMin")&&(this.pvUnderflowMarker=this._addOverflowMarker(!0,t.scale,e))},_addOverflowMarker:function(e,t,i){var n,a=this.isOrientationVertical(),r=a?"bottom":"left",s=this.anchorOpposite(r),o=this.anchorOrthoLength(r),l=this.anchorLength(r),u=this._layoutInfo.paddings,c=e?t.min-u[r]:t.max+u[s];n=e?a?0:Math.PI/2:a?Math.PI:-Math.PI/2;return new Tt.visual.Dot(this,this.pvBar.anchor("center"),{noSelect:!0,noHover:!0,noClick:!0,noDoubleClick:!0,noTooltip:!0,freePosition:!0,extensionId:e?"underflowMarker":"overflowMarker",wrapper:i}).intercept("visible",function(t){var i=this.delegateExtension(); if(void 0!==i&&!i)return!1;var n=t.vars.value.value;if(null==n)return!1;var a=this.pvMark.scene.target[this.pvMark.index],s=a[r]+(n>0?a[o]:0);return e?c>s:s>c}).lock(s,null).lock("shapeSize").pvMark.shape("triangle").shapeRadius(function(){return Math.min(Math.sqrt(10),this.scene.target[this.index][l]/2)}).shapeAngle(n).lineWidth(1.5).strokeStyle("red").fillStyle("white")[r](function(){return c+(e?1:-1)*(this.shapeRadius()+2)})},renderInteractive:function(){this.pvPanel.render()},_buildScene:function(e,t,i){function n(t){var n=new Tt.visual.Scene(a,{source:t}),r=t.key;n.vars.series=jt.fromComplex(t);o.onNewScene(n,!1);i.forEach(function(t){var i=e.child(t.key),a=i&&i.child(r),l=new Tt.visual.Scene(n,{source:a}),u=l.vars.category=jt.fromComplex(i);u.group=i;s.onNewScene(l,!0);o.onNewScene(l,!0)})}var a=new Tt.visual.Scene(null,{panel:this,source:e}),r=(e.childNodes,this.visualRoles),s=new Tt.visual.RoleVarHelper(a,r.value,{roleVar:"value",hasPercentSubVar:this.stacked}),o=new Tt.visual.RoleVarHelper(a,r.color,{roleVar:"color"}); t.forEach(n);return a}});e.type("pvc.BarAbstract",Tt.CategoricalAbstract).init(function(e){this.base(e);var t=this.parent;t&&(this._valueRole=t._valueRole)}).add({_initVisualRoles:function(){this.base();this._addVisualRole("value",{isMeasure:!0,isRequired:!0,isPercent:this.options.stacked,requireSingleDimension:!0,requireIsDiscrete:!1,valueType:Number,defaultDimension:"value"});this._valueRole=this.visualRoles.value},_getCategoryRoleSpec:function(){var e=this.base();e.requireIsDiscrete=!0;return e},_initData:function(){this.base.apply(this,arguments);var e=this.data;this._valueDim=e.dimensions(this._valueRole.firstDimensionName())}});e.type("pvc.BarPanel",Tt.BarAbstractPanel).add({});e.type("pvc.BarChart",Tt.BarAbstract).add({_animatable:!0,_trendable:!0,_allowV1SecondAxis:!0,_initPlotsCore:function(){var e=this.options,t=new Tt.visual.BarPlot(this),i=t.option("Trend");if(e.plot2){var n=new Tt.visual.PointPlot(this,{name:"plot2",fixed:{DataPart:"1"},defaults:{ColorAxis:2,LinesVisible:!0,DotsVisible:!0}}); i||(i=n.option("Trend"))}this._trendable=!!i;i&&new Tt.visual.PointPlot(this,{name:"trend",fixed:{DataPart:"trend",TrendType:"none",ColorRole:"series",NullInterpolatioMode:"none"},defaults:{ColorAxis:2,LinesVisible:!0,DotsVisible:!1}})},_hasDataPartRole:function(){return!0},_createPlotPanels:function(e,t){var i=this.plots,n=i.bar,a=new Tt.BarPanel(this,e,n,Object.create(t));this.barChartPanel=a;var r=i.plot2;if(r){Tt.debug>=3&&this._log("Creating Point panel.");var s=new Tt.PointPanel(this,e,r,Object.create(t));a.pvSecondLine=s.pvLine;a.pvSecondDot=s.pvDot;s._applyV1BarSecondExtensions=!0}var o=i.trend;if(o){Tt.debug>=3&&this._log("Creating Trends Point panel.");new Tt.PointPanel(this,e,o,Object.create(t))}}});e.type("pvc.NormalizedBarPanel",Tt.BarAbstractPanel).add({_barVerticalMode:function(){return"expand"}});e.type("pvc.NormalizedBarChart",Tt.BarAbstract).add({_processOptionsCore:function(e){e.stacked=!0;this.base(e)},_getContinuousVisibleExtentConstrained:function(e,t,i){return"ortho"===e.type?{min:0,max:100,minLocked:!0,maxLocked:!0}:this.base(e,t,i) },_initPlotsCore:function(){new Tt.visual.NormalizedBarPlot(this)},_createPlotPanels:function(e,t){var i=this.plots.bar;this.barChartPanel=new Tt.NormalizedBarPanel(this,e,i,Object.create(t))}});e.type("pvc.visual.legend.WaterfallBulletGroupScene",Tt.visual.legend.BulletGroupScene).init(function(t,i){i=e.set(i,"clickMode","none");this.base(t,i);this.createItem(i)}).add({renderer:function(e){null!=e&&(this._renderer=e);return this._renderer},itemSceneType:function(){return Tt.visual.legend.WaterfallBulletItemScene}});e.type("pvc.visual.legend.WaterfallBulletItemScene",Tt.visual.legend.BulletItemScene).init(function(t,i){this.base.apply(this,arguments);var n=Tt.visual.Interactive;this._ibits=n.Interactive|n.ShowsInteraction;this.color=e.get(i,"color");this.vars.value=new jt(null,e.get(i,"label"))});e.type("pvc.WaterfallPanel",Tt.BarAbstractPanel).add({pvWaterfallLine:null,ruleData:null,_barDifferentialControl:function(){var e=this.chart._isFalling;return function(t){if(e&&!this.index)return 1; var i=t.vars.category.group,n=i._isFlattenGroup&&!i._isDegenerateFlattenGroup;return n?-2:e?-1:1}},_creating:function(){var e=this._getLegendBulletRootScene();if(e){var t=e.firstChild;if(t&&!t.hasRenderer()){var i={drawRule:!0,drawMarker:!1,rulePvProto:new At};this.extend(i.rulePvProto,"line",{constOnly:!0});t.renderer(new Tt.visual.legend.BulletItemDefaultRenderer(i))}}},_createCore:function(){this.base();var i=this.chart,n=this.isOrientationVertical(),a=n?"bottom":"left",r=this.anchorOrtho(a),s=this._buildRuleScene(),o=i.axes.ortho.scale,l=o(0),u=i.axes.ortho.sceneScale({sceneVarName:"value"}),c=i.axes.base.sceneScale({sceneVarName:"category"}),h=i.axes.base.scale,d=this.barWidth/2,f=this.barWidth,v=this.barStepWidth,p=i._isFalling,m=i._waterColor;if(this.plot.option("AreasVisible")){var g=t.Colors.category10(),b=this._buildWaterGroupScene(),_=o.range(),y=.04*(_[1]-_[0]);this.pvWaterfallGroupPanel=new Tt.visual.Panel(this,this.pvPanel,{extensionId:"group"}).lock("data",b.childNodes).pvMark.zOrder(-1).fillStyle(function(){return g(0).alpha(.15) })[r](function(e){var t=e.vars.category;return h(t.valueLeft)-v/2})[this.anchorLength(a)](function(e){var t=e.vars.category,i=Math.abs(h(t.valueRight)-h(t.valueLeft));return i+v})[a](function(e){var t=e.vars.value,n=o(t.valueBottom)-y/2;return i.animate(l,n)})[this.anchorOrthoLength(a)](function(e){var t=e.vars.value,n=o(t.valueTop)-o(t.valueBottom)+y;return i.animate(0,n)})}this.pvBar.sign.override("baseColor",function(e,i){var n=this.base(e,i);return"fill"!==i||e.vars.category.group._isFlattenGroup?n:t.color(n).alpha(.5)});this.pvWaterfallLine=new Tt.visual.Rule(this,this.pvPanel,{extensionId:"line",noTooltip:!1,noHover:!1,noSelect:!1,noClick:!1,noDoubleClick:!1}).lock("data",s.childNodes).optional("visible",function(e){return p&&!!e.previousSibling||!p&&!!e.nextSibling}).optional(a,function(e){return l+i.animate(0,u(e)-l)}).optional(this.anchorLength(a),v+f).optional(r,p?function(e){return c(e)-v-d}:function(e){return c(e)-d}).override("defaultColor",e.fun.constant(m)).pvMark.antialias(!0).lineCap("butt"); this.plot.option("TotalValuesVisible")&&(this.pvWaterfallLabel=new Tt.visual.Label(this,this.pvWaterfallLine,{extensionId:"lineLabel"}).intercept("visible",function(e){return e.vars.category.group._isFlattenGroup?!1:p||!!e.nextSibling}).pvMark[a](function(e){return l+i.animate(0,u(e)-l)})[this.anchorOrtho(a)](c).textAlign(n?"center":"left").textBaseline(function(e){if(!n)return"middle";var t=e.vars.direction;if(null==t)return"bottom";var i=!p;return i===("up"===t)?"bottom":"top"}).textStyle(t.Color.names.darkgray.darker(2)).textMargin(5).text(function(e){return e.vars.value.label}))},_buildRuleScene:function(){function t(e){var t=e.group,i=new Tt.visual.Scene(r,{source:t}),n=i.vars.category=jt.fromComplex(t);n.group=t;var a=e.offset;i.vars.value=new jt(a,this.chart._valueDim.format(a))}function i(e,t){var i=e.vars.value.value;e.vars.direction=t&&n!==i?a===i>n?"up":"down":null;n=i}var n,a,r=new Tt.visual.Scene(null,{panel:this,source:this.visibleData({ignoreNulls:!1})}),s=this.chart._ruleInfos; if(s){s.forEach(t,this);var o=e.query(r.childNodes);a=!this.chart._isFalling;a||(o=o.reverse());o.each(i,this)}return r},_buildWaterGroupScene:function(){function t(e,n){var a=e.children().where(function(e){return""!==e.key});if(a.next()){n&&i(e,n);n++;do t(a.item,n);while(a.next())}}function i(e,t){var i=new Tt.visual.Scene(u,{source:e}),o=i.vars.category=jt.fromComplex(e);o.group=e;o.level=t;var l,c,h,d,f,v=i.vars.value={},p=r[e.absKey],m=p.offset,g=p.range,b=-g.min+g.max;if(s){l=a(e);c=r[l.absKey];h=p.group.value;d=c.group.value;f=m-g.max}else{l=n(e);c=r[l.absKey];h=c.group.value;d=p.group.value;f=m-g.max}o.valueLeft=h;o.valueRight=d;v.valueHeight=b;v.valueBottom=f;v.valueTop=f+b}function n(e){var t=e.childNodes,i=t&&t[0];return i?n(i):e}function a(e){var t=e.childNodes,i=t&&t[t.length-1];return i?a(i):e}var r,s,o=this.chart,l=o._catRole.select(o.partData(this.dataPartValue),{visible:!0}),u=new Tt.visual.Scene(null,{panel:this,source:l}),c=o._ruleInfos;if(c){r=e.query(c).object({name:function(e){return e.group.absKey }});s=o._isFalling;t(l,0)}return u}});e.type("pvc.WaterfallChart",Tt.BarAbstract).init(function(e){this.base(e);var t=this.parent;t&&(this._isFalling=t._isFalling)}).add({_animatable:!0,_isFalling:!0,_ruleInfos:null,_waterColor:t.color("#1f77b4").darker(),_processOptionsCore:function(e){e.stacked=!0;e.baseAxisComposite=!1;this.base(e);e.plot2=!1},_initPlotsCore:function(){var e=(this.options,new Tt.visual.WaterfallPlot(this));this._isFalling="down"===e.option("Direction");var t=this._isFalling?"FlattenDfsPre":"FlattenDfsPost";this._catRole.setTraversalMode(Tt.visual.TraversalMode[t]);this._catRole.setRootLabel(e.option("AllCategoryLabel"))},_initLegendScenes:function(e){var i=this.plots.water,n=Tt.makeExtensionAbsId("line",i.extensionPrefixes),a=this._getConstantExtension(n,"strokeStyle");a&&(this._waterColor=t.color(a));var r=e._getBulletRootScene();new Tt.visual.legend.WaterfallBulletGroupScene(r,{extensionPrefix:Tt.buildIndexedId("",1),label:i.option("TotalLineLabel"),color:this._waterColor}); this.base(e)},_reduceStackedCategoryValueExtent:function(e,t,i){var n,a=e?e.offset:0,r=t.min+t.max;if(!e){if(t){n=a+r;this._ruleInfos=[{offset:n,group:i,range:t}];return{min:t.min,max:t.max,offset:n}}return null}var s=this._isFalling,o=i._isFlattenGroup&&!i._isDegenerateFlattenGroup;if(o){var l=-t.min;if(l>0){var u=a+l;u>e.max&&(e.max=u)}var c=-t.max;if(0>c){var h=a+c;he.max?e.max=n:nl;l++,u++){var h=n[u],f=2*l;i[f]=h;r.call(this,t,h,S&&S[f]);h.isAlone&&!o&&(o=h);h.isNull||a++;if(t){var v=s.call(this,e,t,h,u,S&&S[f-1]);if(v){i[f-1]=v;u++}}t=h}1===a&&o&&1===c&&(o.isSingle=!0);d&&(S=i)}function r(e,t,i){var a=t.vars.value.accValue;if(i){t.isNull&&!n?a=_:a+=i.vars.value.accValue;t.vars.value.accValue=a}t.basePosition=x(t);t.orthoPosition=y;t.orthoLength=b(a)-y;var r=!e||e.isNull,s=r&&!t.isNull;if(s){var o=t.nextSibling;s=!o||o.isNull}t.isAlone=s; t.isSingle=!1}function s(e,t,i,a,r){var s=t.isNull||i.isNull;if(s&&!this.areasVisible)return null;var o,l,u;if(s){if(r&&n){var c=r.vars.value;l=c.accValue;o=c[h.name]}else o=l=_;u=d&&n?i.basePosition-x.range().step/2:t.isNull?i.basePosition:t.basePosition}else{var f=t.vars.value,p=i.vars.value;o=(p.value+f.value)/2;l=(p.accValue+f.accValue)/2;u=(i.basePosition+t.basePosition)/2}var g=new Tt.visual.Scene(e,{index:a,source:i.source});g.dataIndex=i.dataIndex;g.vars.category=i.vars.category;var S=new jt(o,m.format(o),o);S.accValue=l;g.vars.value=S;g.ownerScene=i;g.isInterpolated=i.isInterpolated;g.isIntermediate=!0;g.isSingle=!1;g.isNull=s;g.isAlone=s&&i.isNull&&t.isNull;g.basePosition=u;g.orthoPosition=y;g.orthoLength=b(l)-y;v.onNewScene(g,!0);return g}function o(e){for(var t,i,n=e.childNodes,a=n.length;a&&(t=n[0]).isNull;){i=t.nextSibling;if(i&&!i.isNull)break;e.removeAt(0);a--}for(;a&&(t=n[a-1]).isNull;){i=t.previousSibling;if(i&&!i.isNull)break;e.removeAt(a-1);a--}}var l=new Tt.visual.Scene(null,{panel:this,source:t}),u=this.chart,c=this.visualRoles.series,h=this.visualRoles.value,d=this.stacked,f=new Tt.visual.RoleVarHelper(l,h,{roleVar:"value",hasPercentSubVar:d}),v=new Tt.visual.RoleVarHelper(l,this.visualRoles.color,{roleVar:"color"}),p=h.firstDimensionName(),m=t.owner.dimensions(p),g=c.isBound()?c.flatten(this.partData(),{visible:!0,isNull:u.options.ignoreNulls?!1:null}):null,b=this.axes.ortho.scale,_=e.scope(function(){var e=b.domain(),t=e[0],i=e[1]; return t*i>=0?t>=0?t:i:0}),y=b(_),x=this.axes.base.sceneScale({sceneVarName:"category"});(g?g.children():e.query([null])).each(function(n){var a=new Tt.visual.Scene(l,{source:n||t});a.vars.series=jt.fromComplex(n);v.onNewScene(a,!1);i.forEach(function(i,r){var s=t.child(i.key),o=s;o&&n&&(o=o.child(n.key));var l=new Tt.visual.Scene(a,{source:o});l.dataIndex=r;l.vars.category=jt.fromComplex(s);f.onNewScene(l,!0);var u=l.vars.value,c=u.value;u.accValue=null!=c?c:_;v.onNewScene(l,!0);var h=null!=o&&o.datums().prop("isInterpolated").any(e.truthy);l.isInterpolated=h;l.isNull=null==c;l.isIntermediate=!1},this)},this);var S,w=l.children().reverse().array();w.forEach(a,this);w.forEach(o,this);return l}});e.type("pvc.PointAbstract",Tt.CategoricalAbstract).add({_animatable:!0,_trendable:!0,_processOptionsCore:function(e){e.panelSizeRatio=1;this.base(e)},_hasDataPartRole:function(){return!0},_initVisualRoles:function(){this.base();this._addVisualRole("value",{isMeasure:!0,isRequired:!0,isPercent:this.options.stacked,requireSingleDimension:!0,requireIsDiscrete:!1,valueType:Number,defaultDimension:"value"}) },_initPlotsCore:function(){var e=this.options,t=this._createPointPlot(),i=t.option("Trend");if(e.plot2){var n=new Tt.visual.PointPlot(this,{name:"plot2",fixed:{DataPart:"1"},defaults:{ColorAxis:2,LinesVisible:!0,DotsVisible:!0}});i||(i=n.option("Trend"))}this._trendable=!!i;i&&new Tt.visual.PointPlot(this,{name:"trend",fixed:{DataPart:"trend",TrendType:"none",ColorRole:"series",NullInterpolatioMode:"none"},defaults:{ColorAxis:2,LinesVisible:!0,DotsVisible:!1}})},_initAxes:function(e){this.base(e);var t=this.axesByType.base;t&&t.forEach(function(e){var t="discrete"===e.scaleType;t||e.option.defaults({Offset:.01})});t=this.axesByType.ortho;t&&t.forEach(function(e){e.option.defaults({Offset:.04})})},_createPlotPanels:function(e,t){var i=this.plots,n=i.point;this.scatterChartPanel=new Tt.PointPanel(this,e,n,Object.create(t));var a=i.plot2;if(a){Tt.debug>=3&&this._log("Creating second Point panel.");new Tt.PointPanel(this,e,a,Object.create(t))}var r=i.trend;if(r){Tt.debug>=3&&this._log("Creating Trends Point panel."); new Tt.PointPanel(this,e,r,Object.create(t))}},defaults:{tooltipOffset:10}});e.type("pvc.DotChart",Tt.PointAbstract).add({_createPointPlot:function(){return new Tt.visual.PointPlot(this,{fixed:{DotsVisible:!0}})}});e.type("pvc.LineChart",Tt.PointAbstract).add({_createPointPlot:function(){return new Tt.visual.PointPlot(this,{fixed:{LinesVisible:!0}})}});e.type("pvc.AreaChart",Tt.PointAbstract).add({_createPointPlot:function(){return new Tt.visual.PointPlot(this,{fixed:{AreasVisible:!0}})}});Tt.mStackedLineChart=e.type("pvc.StackedLineChart",Tt.PointAbstract).add({_createPointPlot:function(){return new Tt.visual.PointPlot(this,{fixed:{LinesVisible:!0,Stacked:!0}})}});e.type("pvc.StackedDotChart",Tt.PointAbstract).add({_createPointPlot:function(){return new Tt.visual.PointPlot(this,{fixed:{DotsVisible:!0,Stacked:!0}})}});Tt.mStackedAreaChart=e.type("pvc.StackedAreaChart",Tt.PointAbstract).add({_createPointPlot:function(){return new Tt.visual.PointPlot(this,{fixed:{AreasVisible:!0,Stacked:!0},defaults:{LinesVisible:!0}}) }});e.type("pvc.HeatGridPanel",Tt.CategoricalAbstractPanel).init(function(e,t,i,n){this.base(e,t,i,n);this.axes.size=e._getAxis("size",i.option("SizeAxis")-1);var a=this.visualRoles,r=i.option("SizeRole");a.size=e.visualRole(r);this.useShapes=i.option("UseShapes");this.shape=i.option("Shape");this.nullShape=i.option("NullShape")}).add({defaultBorder:1,nullBorder:2,selectedBorder:2,_createCore:function(){var t=this;t.base();var i=t._calcCellSize(),n=t.isOrientationVertical()?"bottom":"left",a=Tt.BasePanel.relativeAnchor[n],r=Tt.BasePanel.parallelLength[n],s=Tt.BasePanel.orthogonalLength[n],o=t.visualRoles.series.flatten(t.partData(),{visible:!0,isNull:t.chart.options.ignoreNulls?!1:null}),l=t._buildScene(t.visibleData({ignoreNulls:!1}),o,i),u=l.isColorBound,c=l.isSizeBound,h=t._buildSignsWrapper(l),d=t.compatVersion()<=1,f=this.axes.base.scale,v=this.axes.ortho.scale,p=f.range().step,m=v.range().step,g=p/2,b=m/2,_=new Tt.visual.Panel(t,t.pvPanel).pvMark.data(l.childNodes)[n](function(e){return v(e.vars.series.value)-b })[s](m),y=["panel"];d&&y.push("");var x={extensionId:y,wrapper:h};if(!t.useShapes){var S=!1;e.copy(x,{noSelect:S,noHover:S,noClick:S,noDoubleClick:S,freeColor:S,noTooltip:d})}t.pvHeatGrid=new Tt.visual.Panel(t,_,x).pvMark.lock("data",function(e){return e.childNodes}).lock(a,function(e){return f(e.vars.category.value)-g}).lock(r,p).antialias(!1);t.shapes=t.useShapes?t._createShapesHeatMap(i,h,u,c):t._createNoShapesHeatMap(u);t.valuesVisible&&!t.valuesMask&&(t.valuesMask=t._getDefaultValuesMask(u,c));var w=Tt.visual.ValueLabel.maybeCreate(t,t.pvHeatGrid,{wrapper:h});w&&(t.pvHeatGridLabel=w.pvMark)},_calcCellSize:function(){var e=this.axes.x.scale,t=this.axes.y.scale,i=(e.max-e.min)/e.domain().length,n=(t.max-t.min)/t.domain().length;if(!this.isOrientationVertical()){var a=i;i=n;n=a}return{width:i,height:n}},_buildSignsWrapper:function(t){if(this.compatVersion()>1)return null;var i=e.query(t.childNodes).object({name:function(e){return""+e.vars.series.value},value:function(t){return e.query(t.childNodes).object({name:function(e){return""+e.vars.category.value },value:function(e){var t=e.vars.color;return t?""+t.value:null}})}});return function(e){return function(t){var n=i[t.vars.series.value],a=t.vars.category.rawValue,r=Object.create(this.parent),s=Object.create(this);s.parent=r;var o=t.childIndex(),l=t.parent.childIndex();r.index=o;s.index=l;return e.call(s,n,a)}}},_getDefaultValuesMask:function(e,t){var i=this.visualRoles,n=e?"color":t?"size":null;if(n){var a=i[n].firstDimensionName();return"{#"+a+"}"}},_createNoShapesHeatMap:function(e){var t=this._buildGetBaseFillColor(e);return this.pvHeatGrid.sign.override("defaultColor",function(e,i){return"stroke"===i?null:t.call(this.pvMark,e)}).override("interactiveColor",function(e,t,i){return e.isActive?t.alpha(.6):e.anySelected()&&!e.isSelected()?this.dimColor(t,i):this.base(e,t,i)}).override("dimColor",function(e){return Tt.toGrayScale(e,.6)}).pvMark.lineWidth(1.5)},_buildGetBaseFillColor:function(t){var i=this.axes.color;return t?i.sceneScale({sceneVarName:"color"}):e.fun.constant(i.option("Unbound")) },_createShapesHeatMap:function(t,i,n,a){var r=this,s=r._calcDotAreaRange(t);a&&r.axes.size.setScaleRange(s);var o={extensionId:"dot",freePosition:!0,activeSeriesAware:!1,wrapper:i,tooltipArgs:r._buildShapesTooltipArgs(n,a)},l=new Tt.visual.DotSizeColor(r,r.pvHeatGrid,o).override("dimColor",function(e){return Tt.toGrayScale(e,.6)}).pvMark;a||l.sign.override("defaultSize",e.fun.constant(s.max));return l},_calcDotAreaRange:function(t){var i=t.width,n=t.height,a=Math.min(i,n)/2;"diamond"===this.shape&&(a/=Math.SQRT2);a-=2;var r=e.sqr(a),s=12,o=r-s;if(1>=o){r=Math.max(r,2);s=1;o=r-s;Tt.debug>=2&&this._warn("Using rescue mode dot area calculation due to insufficient space.")}return{min:s,max:r,span:o}},_buildShapesTooltipArgs:function(e,t){var i=this.chart;if(this.compatVersion()<=1&&this.showsTooltip()){var n=i.options,a=n.customTooltip;a||(a=function(e,t,i){return null!=i&&void 0!==i[0]?i.join(", "):i});var r=this.visualRoles,s=r.series.grouping.dimensionNames(),o=r.category.grouping.dimensionNames(); return{buildTooltip:n.isMultiValued?function(i){var r=i.scene.group;if(!r)return"";var l=Tt.data.Complex.values(r,s),u=Tt.data.Complex.values(r,o),c=[],h=i.scene.vars;t&&(c[n.sizeValIdx||0]=h.size.value);e&&(c[n.colorValIdx||0]=h.color.value);return a.call(n,l,u,c)}:function(t){var i=t.scene.vars,r=i.series.rawValue,s=i.category.rawValue,o=i[e?"color":"size"],l=o?o.value:null;return a.call(n,r,s,l)}}}},renderInteractive:function(){this.pvPanel.render()},_buildScene:function(e,t,i){function n(e){var t=new Tt.visual.Scene(s,{source:e});t.vars.series=jt.fromComplex(e);o.forEach(function(i){a.call(r,t,i,e)})}function a(t,i,n){var a=e.child(i.key).child(n.key),r=new Tt.visual.Scene(t,{source:a});r.vars.category=jt.fromComplex(i);u.onNewScene(r,!0);c.onNewScene(r,!0)}var r=this,s=new Tt.visual.Scene(null,{panel:r,source:e}),o=e.childNodes,l=r.visualRoles,u=new Tt.visual.RoleVarHelper(s,l.color,{roleVar:"color"}),c=new Tt.visual.RoleVarHelper(s,l.size,{roleVar:"size"});s.cellSize=i;t.children().each(n); return s}});e.type("pvc.HeatGridChart",Tt.CategoricalAbstract).add({_allowColorPerCategory:!0,_interpolatable:!1,_axisCreateIfUnbound:{color:!0},_processOptionsCore:function(t){this.base(t);e.set(t,"legend",!1,"panelSizeRatio",1);var i="value",n="value2";if(this.compatVersion()<=1){switch(this.options.colorValIdx){case 0:i="value";break;case 1:i="value2";break;default:i="value"}switch(this.options.sizeValIdx){case 0:n="value";break;case 1:n="value2";break;default:n="value"}}this._colorDimName=i;this._sizeDimName=n},_getCategoryRoleSpec:function(){var e=this.base();e.requireIsDiscrete=!0;return e},_getColorRoleSpec:function(){return{isMeasure:!0,requireSingleDimension:!0,requireIsDiscrete:!1,valueType:Number,defaultDimension:this._colorDimName}},_initVisualRoles:function(){this.base();this._addVisualRole("size",{isMeasure:!0,requireSingleDimension:!0,requireIsDiscrete:!1,valueType:Number,defaultDimension:this._sizeDimName})},_initPlotsCore:function(){new Tt.visual.HeatGridPlot(this)},_createPlotPanels:function(e,t){var i=this.plots.heatGrid; this.heatGridChartPanel=new Tt.HeatGridPanel(this,e,i,Object.create(t))},defaults:{colorValIdx:0,sizeValIdx:1,measuresIndexes:[2],axisOffset:0,plotFrameVisible:!1,colorNormByCategory:!0,numSD:2}});e.type("pvc.MetricXYAbstract",Tt.CartesianAbstract).add({_processOptionsCore:function(e){this.base(e);e.panelSizeRatio=1},_initVisualRoles:function(){this.base();this._addVisualRole("x",{isMeasure:!0,isRequired:!0,requireSingleDimension:!0,requireIsDiscrete:!1,defaultDimension:"x",dimensionDefaults:{valueType:this.options.timeSeries?Date:Number}});this._addVisualRole("y",{isMeasure:!0,isRequired:!0,requireSingleDimension:!0,requireIsDiscrete:!1,defaultDimension:"y",dimensionDefaults:{valueType:Number}})},_generateTrendsDataCell:function(t,i,n){function a(i){var n=function(e){return e.atoms[c].value},a=function(e){return e.atoms[h].value},r=i.datums().sort(null,n).array(),s=e.create(l,{rows:e.query(r),x:n,y:a}),o=u.model(s);o&&r.forEach(function(r,s){var u=n(r);if(u){var p=o.sample(u,a(r),s);if(null!=p){var m=e.set(Object.create(i.atoms),c,u,h,p,v,f); t.push(new Tt.data.TrendDatum(d.owner,m,l))}}})}var r=this._serRole,s=this.visualRoles.x,o=i.role,l=i.trend,u=l.info;this._warnSingleContinuousValueRole(o);var c=s.firstDimensionName(),h=o.firstDimensionName(),d=this.visibleData(i.dataPartValue,{baseData:n}),f=this._getTrendDataPartAtom(),v=f.dimension.name;(r.isBound()?d.children():e.query([d])).each(a,this)}});e.type("pvc.data.MetricPointChartTranslationOper").add({_meaLayoutRoles:["x","y","color","size"],configureType:function(){var e=[],t=[];this.collectFreeDiscreteAndConstinuousIndexes(t,e);var i,n=[],a=e.length;if(a>0){for(var r=this._meaLayoutRoles.length,s=0;r>s&&n.length0){e.length=i;this.defReader({names:n,indexes:e})}}a=t.length;if(a>0){n.length=0;this._getUnboundRoleDefaultDimNames("series",a,n);i=n.length;if(i>0){t.length=i;this.defReader({names:n,indexes:t})}}}});e.type("pvc.MetricPointPanel",Tt.CartesianAbstractPanel).init(function(e,t,i,n){this.base(e,t,i,n); this.axes.size=e._getAxis("size",(i.option("SizeAxis")||0)-1);var a=i.option("SizeRole");this.visualRoles.size=a?e.visualRole(a):null;this.linesVisible=i.option("LinesVisible");this.dotsVisible=i.option("DotsVisible");if(!this.linesVisible&&!this.dotsVisible){this.linesVisible=!0;i.option.specify({LinesVisible:!0})}this.offsetPaddings||(this.offsetPaddings=new Vt(.01))}).add({sizeAxisRatio:.2,sizeAxisRatioTo:"minWidthHeight",autoPaddingByDotSize:!0,_v1DimRoleName:{category:"x",value:"y"},_creating:function(){var i=this.defaultLegendGroupScene();if(i&&!i.hasRenderer()){var n=i.colorAxis,a=e.nullyTo(n.option("LegendDrawMarker",!0),this.dotsVisible),r=e.nullyTo(n.option("LegendDrawLine",!0),this.linesVisible);if(a||r){var s={drawMarker:a,drawRule:r};if(a){s.markerShape=n.option("LegendShape",!0)||"circle";s.markerPvProto=(new t.Dot).lineWidth(1.5,Tt.extensionTag).shapeSize(12,Tt.extensionTag);this.extend(s.markerPvProto,"dot",{constOnly:!0})}if(r){s.rulePvProto=(new t.Line).lineWidth(1.5,Tt.extensionTag); this.extend(s.rulePvProto,"line",{constOnly:!0})}i.renderer(new Tt.visual.legend.BulletItemDefaultRenderer(s))}}},_getRootScene:function(){return e.lazy(this,"_rootScene",this._buildScene,this)},_calcLayout:function(e){var t=this._getRootScene();t.isSizeBound&&this.axes.size.setScaleRange(this._calcDotAreaRange(e));this._calcAxesPadding(e,t)},_getDotDiameterRefLength:function(t){var i=t.clientSize,n=t.paddings;switch(this.sizeAxisRatioTo){case"minWidthHeight":return Math.min(i.width+n.width,i.height+n.height);case"width":return i.width+n.width;case"height":return i.height+n.height}Tt.debug>=2&&this._log(e.format("Invalid option 'sizeAxisRatioTo' value. Assuming 'minWidthHeight'.",[this.sizeAxisRatioTo]));this.sizeRatioTo="minWidthHeight";return this._getDotDiameterRefLength(t)},_calcDotRadiusRange:function(e){var t=this._getDotDiameterRefLength(e),i=this.sizeAxisRatio/2*t,n=Math.sqrt(12);return{min:n,max:i}},_calcDotAreaRange:function(t){var i=this._calcDotRadiusRange(t);if("diamond"===this.shape){i.max/=Math.SQRT2; i.min/=Math.SQRT2}var n=e.sqr(i.max),a=e.sqr(i.min),r=n-a;if(1>=r){n=Math.max(n,2);a=1;r=n-a;i={min:Math.sqrt(a),max:Math.sqrt(n)};Tt.debug>=3&&this._log("Using rescue mode dot area calculation due to insufficient space.")}return{min:a,max:n,span:r}},_calcAxesPadding:function(t,i){var n;if(this.autoPaddingByDotSize){var a=this.axes,r=t.clientSize,s=t.paddings;n={};a.x.setScaleRange(r.width);a.y.setScaleRange(r.height);var o=this.isOrientationVertical(),l=a.x.sceneScale({sceneVarName:o?"x":"y"}),u=a.y.sceneScale({sceneVarName:o?"y":"x"}),c=a.x.scale.max,h=a.y.scale.max,d=i.isSizeBound,f=d?a.size.scale:null;if(!f){var v=e.number.as(this._getExtension("dot","shapeRadius"),0);if(0>=v){v=e.number.as(this._getExtension("dot","shapeSize"),0);0>=v&&(v=12)}else v=e.sqr(v);f=e.fun.constant(v)}n={};var p;if(this.offsetPaddings){p={};Vt.names.forEach(function(e){var t=Tt.BasePanel.orthogonalLength[e];p[e]=(this.offsetPaddings[e]||0)*(r[t]+s[t])},this)}var m=function(e,t){p&&(t+=p[e]||0);0>t&&(t=0); var i=n[e];(null==i||t>i)&&(n[e]=t)},g=function(e){var t=l(e),i=u(e),n=Math.sqrt(f(d?e.vars.size.value:0));m("left",n-t);m("bottom",n-i);m("right",t+n-c);m("top",i+n-h)};i.children().selectMany(function(e){return e.childNodes}).each(g)}else n=this._calcRequestPaddings(t);t.requestPaddings=n},_createCore:function(){var t=this;t.base();var i=t.chart,n=t._getRootScene(),a=t._buildSignsWrapper(),r=t.compatVersion()<=1;this._finalizeScene(n);t.pvPanel.zOrder(1);this.pvScatterPanel=new Tt.visual.Panel(t,t.pvPanel,{extensionId:"panel"}).lock("data",n.childNodes).pvMark;var s=i.selectableByFocusWindow(),o=n.isColorBound&&this.visualRoles.color.isDiscrete(),l=new Tt.visual.Line(t,t.pvScatterPanel,{extensionId:"line",wrapper:a,noTooltip:!1,noSelect:s,showsSelection:!s}).lockMark("data",function(e){return e.childNodes}).intercept("visible",function(e){if(!t.linesVisible)return!1;var i=this.delegateExtension();null==i&&(i=!e.isNull&&(!n.isSizeBound&&!n.isColorBound||n.isSizeBound&&null!=e.vars.size.value||n.isColorBound&&(o||null!=e.vars.color.value))); return i}).override("x",function(e){return e.basePosition}).override("y",function(e){return e.orthoPosition});t.pvLine=l.pvMark;var u=new Tt.visual.DotSizeColor(t,t.pvLine,{extensionId:"dot",wrapper:a,activeSeriesAware:t.linesVisible}).override("x",function(e){return e.basePosition}).override("y",function(e){return e.orthoPosition}).override("color",function(e,i){return t.dotsVisible||e.isActive||e.isSingle?this.base(e,i):Tt.invisibleFill});n.isSizeBound?t.autoPaddingByDotSize&&"minWidthHeight"===t.sizeAxisRatioTo||t.pvPanel.borderPanel.overflow("hidden"):u.override("baseSize",function(i){if(!t.dotsVisible&&i.isSingle){var n=Math.max(t.pvLine.scene[this.pvMark.index].lineWidth,.2)/2;return e.sqr(n)}return this.base(i)});t.pvDot=u.pvMark;t.pvDot.rubberBandSelectionMode="center";if(Tt.visual.ValueLabel.isNeeded(t)){var c=["label"];r&&c.push("lineLabel");var h=Tt.visual.ValueLabel.maybeCreate(t,t.pvDot,{extensionId:c,wrapper:a});h&&(t.pvHeatGridLabel=h.pvMark)}},_buildSignsWrapper:function(){return this.compatVersion()>1?null:function(e){return function(t){var i={category:t.vars.x.rawValue,value:t.vars.y.rawValue},n=Object.create(this); n.index=t.dataIndex;return e.call(n,i)}}},renderInteractive:function(){this.pvScatterPanel.render()},_buildScene:function(){function e(e){var t=new Tt.visual.Scene(a,{source:e});t.vars.series=jt.fromComplex(e);s.onNewScene(t,!1);e.datums().each(function(e,i){var n=e.atoms[l.name];if(null!=n.value){var a=e.atoms[u.name];if(null!=a.value){var r=new Tt.visual.Scene(t,{source:e});r.dataIndex=i;r.vars.x=jt.fromAtom(n);r.vars.y=jt.fromAtom(a);o.onNewScene(r,!0);s.onNewScene(r,!0);r.isIntermediate=!1}}})}function t(e){for(var t,n=e.childNodes,a=0,r=0,s=n.length;s>a;a++,r++){var o=n[r];o.isSingle=!t&&!o.nextSibling;if(t){var l=i(e,t,o,r);l&&r++}t=o}}function i(e,t,i,n){var a=+i.vars.y.value,r=+t.vars.y.value,c=+i.vars.x.value,h=+t.vars.x.value,d=u.type.cast.call(null,(a+r)/2),f=l.type.cast.call(null,(c+h)/2),v=new Tt.visual.Scene(e,{index:n,source:i.datum});v.dataIndex=i.dataIndex;v.vars.x=new jt(f,l.format(f),f);v.vars.y=new jt(d,u.format(d),d);o.onNewScene(v,!0);s.onNewScene(v,!0);v.ownerScene=i; v.isIntermediate=!0;v.isSingle=!1;return v}var n=this.visibleData({ignoreNulls:!1}),a=new Tt.visual.Scene(null,{panel:this,source:n}),r=this.visualRoles,s=(this.axes,new Tt.visual.RoleVarHelper(a,r.color,{roleVar:"color"})),o=new Tt.visual.RoleVarHelper(a,r.size,{roleVar:"size"}),l=n.owner.dimensions(r.x.firstDimensionName()),u=n.owner.dimensions(r.y.firstDimensionName());n.children().each(e,this);a.children().each(t,this);return a},_finalizeScene:function(e){var t=this.axes,i=t.base.sceneScale({sceneVarName:"x"}),n=t.ortho.sceneScale({sceneVarName:"y"});e.children().selectMany(function(e){return e.childNodes}).each(function(e){e.basePosition=i(e);e.orthoPosition=n(e)});return e}});e.type("pvc.MetricPointAbstract",Tt.MetricXYAbstract).add({_trendable:!0,_initPlotsCore:function(){var e=this._createPointPlot(),t=e.option("Trend");(this._trendable=!!t)&&new Tt.visual.MetricPointPlot(this,{name:"trend",fixed:{DataPart:"trend",TrendType:"none",NullInterpolatioMode:"none",ColorRole:"series",SizeRole:null,SizeAxis:null,OrthoAxis:1},defaults:{ColorAxis:2,LinesVisible:!0,DotsVisible:!1}}) },_hasDataPartRole:function(){return!0},_getColorRoleSpec:function(){return{defaultSourceRole:"series",defaultDimension:"color*",dimensionDefaults:{valueType:Number}}},_initVisualRoles:function(){this.base();this._addVisualRole("size",{isMeasure:!0,requireSingleDimension:!0,requireIsDiscrete:!1,defaultDimension:"size",dimensionDefaults:{valueType:Number}})},_getTranslationClass:function(t){return e.type(this.base(t)).add(Tt.data.MetricPointChartTranslationOper)},_createPlotPanels:function(t,i){var n=this.options,a=e.set(Object.create(i),"sizeAxisRatio",n.sizeAxisRatio,"sizeAxisRatioTo",n.sizeAxisRatioTo,"autoPaddingByDotSize",n.autoPaddingByDotSize),r=this.plots.scatter;this.scatterChartPanel=new Tt.MetricPointPanel(this,t,r,a);var s=this.plots.trend;s&&new Tt.MetricPointPanel(this,t,s,Object.create(a))},defaults:{axisOriginIsZero:!1,tooltipOffset:10}});e.type("pvc.MetricDotChart",Tt.MetricPointAbstract).add({_createPointPlot:function(){return new Tt.visual.MetricPointPlot(this,{fixed:{DotsVisible:!0}}) }});e.type("pvc.MetricLineChart",Tt.MetricPointAbstract).add({_createPointPlot:function(){return new Tt.visual.MetricPointPlot(this,{fixed:{LinesVisible:!0}})}});e.type("pvc.BulletChart",Tt.BaseChart).init(function(e){e=e||{};var t=e.dimensionGroups||(e.dimensionGroups={}),i=t.range||(t.range={});void 0===i.valueType&&(i.valueType=Number);var n=t.marker||(t.marker={});void 0===n.valueType&&(n.valueType=Number);this.base(e)}).add({bulletChartPanel:null,allowNoData:!0,_processOptionsCore:function(e){e.legend=!1;e.selectable=!1;this.base(e)},_initVisualRoles:function(){this.base();this._addVisualRole("title",{defaultDimension:"title*"});this._addVisualRole("subTitle",{defaultDimension:"subTitle*"});this._addVisualRole("value",{isMeasure:!0,requireIsDiscrete:!1,valueType:Number,defaultDimension:"value*"});this._addVisualRole("marker",{isMeasure:!0,requireIsDiscrete:!1,valueType:Number,defaultDimension:"marker*"});this._addVisualRole("range",{isMeasure:!0,requireIsDiscrete:!1,valueType:Number,defaultDimension:"range*"}) },_createTranslation:function(e){var i=this.base(e),n=i.virtualItemSize();if(n)switch(n){case 1:i.defReader({names:"value"});break;case 2:i.defReader({names:["title","value"]});break;case 3:i.defReader({names:["title","value","marker"]});break;default:i.defReader({names:["title","subTitle","value","marker"]});n>4&&i.defReader({names:"range",indexes:t.range(4,n)})}return i},_initPlotsCore:function(){new Tt.visual.BulletPlot(this)},_createContent:function(e){var t=this.plots.bullet;this.bulletChartPanel=new Tt.BulletChartPanel(this,this.basePanel,t,e)},defaults:{compatVersion:1,orientation:"horizontal",bulletSize:30,bulletSpacing:50,bulletMargin:100,bulletTitle:"Title",bulletSubtitle:"",bulletTitlePosition:"left",tooltipFormat:function(e,t,i){return this.chart.options.valueFormat(i)},crosstabMode:!1,seriesInRows:!1}});e.type("pvc.BulletChartPanel",Tt.PlotPanel).add({pvBullets:null,pvBullet:null,data:null,onSelectionChange:null,_createCore:function(e){var i,n,a,r,s,o,l,u,c,h=this.chart,d=h.options,f=this.buildData(),v="horizontal"==d.orientation?"left":"bottom"; if("horizontal"==d.orientation){i=e.clientSize.width-this.chart.options.bulletMargin-20;n=0;switch(d.bulletTitlePosition){case"top":l=this.chart.options.bulletMargin;r=0;a="left";s=-12;c=parseInt(d.titleSize/2,10);break;case"bottom":l=this.chart.options.bulletMargin;r=0;a="left";s=d.bulletSize+32;c=0;break;case"right":l=5;r=i+5;a="left";s=parseInt(d.bulletSize/2,10);c=0;break;case"left":default:l=this.chart.options.bulletMargin;r=0;s=parseInt(d.bulletSize/2,10);a="right";c=0}o="bottom";u=function(){return this.index*(d.bulletSize+d.bulletSpacing)+c}}else{i=e.clientSize.height-this.chart.options.bulletMargin-20;switch(d.bulletTitlePosition){case"top":l=this.chart.options.bulletMargin;r=0;a="left";s=-20;n=0;u=void 0;break;case"bottom":l=this.chart.options.bulletMargin;r=0;a="left";s=i+20;n=0;u=20;break;case"right":l=5;r=this.chart.options.bulletSize+40;a="left";s=i;n=-Math.PI/2;u=void 0;break;case"left":default:l=this.chart.options.bulletMargin;r=-12;s=this.height-this.chart.options.bulletMargin-20; a="left";n=-Math.PI/2;u=void 0}o="right";l=function(){return d.bulletMargin+this.index*(d.bulletSize+d.bulletSpacing)}}this.pvBullets=this.pvPanel.add(t.Panel).data(f)[Tt.BasePanel.orthogonalLength[v]](i)[Tt.BasePanel.parallelLength[v]](this.chart.options.bulletSize).margin(20).left(l).top(u);this.pvBullet=this.pvBullets.add(t.Layout.Bullet).orient(v).ranges(function(e){return e.ranges}).measures(function(e){return e.measures}).markers(function(e){return e.markers});if(h.clickable()&&this.clickAction){var p=this;this.pvBullet.cursor("pointer").event("click",function(e){var i=e.title,n=e.subtitle,a=t.event;return p.clickAction(i,n,e.measures,a)})}this.pvBulletRange=this.pvBullet.range.add(t.Bar);this.pvBulletMeasure=this.pvBullet.measure.add(t.Bar).text(function(e,t){return t.formattedMeasures[this.index]});this.pvBulletMarker=this.pvBullet.marker.add(t.Dot).shape("square").fillStyle("white").text(function(e,t){return t.formattedMarkers[this.index]});if(this.showsTooltip()){var m=this;this.pvBulletMeasure.localProperty("tooltip").tooltip(function(e,t){var i=t.title,n=t.subtitle; return h.options.tooltipFormat.call(m,i,n,e)});this.pvBulletMarker.localProperty("tooltip").tooltip(function(e,t){var i=t.title,n=t.subtitle;return h.options.tooltipFormat.call(m,i,n,e)});this.pvBulletMeasure.event("mouseover",t.Behavior.tipsy(this.chart._tooltipOptions));this.pvBulletMarker.event("mouseover",t.Behavior.tipsy(this.chart._tooltipOptions))}this.pvBulletRule=this.pvBullet.tick.add(t.Rule);this.pvBulletRuleLabel=this.pvBulletRule.anchor(o).add(t.Label).text(this.pvBullet.x.tickFormat);this.pvBulletTitle=this.pvBullet.anchor(v).add(t.Label).font("bold 12px sans-serif").textAngle(n).left(-10).textAlign(a).textBaseline("bottom").left(r).top(s).text(function(e){return e.formattedTitle});this.pvBulletSubtitle=this.pvBullet.anchor(v).add(t.Label).textStyle("#666").textAngle(n).textAlign(a).textBaseline("top").left(r).top(s).text(function(e){return e.formattedSubtitle});var g="function"==typeof d.axisDoubleClickAction?function(e,t){d.axisDoubleClickAction(e,t)}:null;if(h.doubleClickable()&&g){this.pvBulletTitle.cursor("pointer").events("all").event("dblclick",function(e){g(e,arguments[arguments.length-1]) });this.pvBulletSubtitle.cursor("pointer").events("all").event("dblclick",function(e){g(e,arguments[arguments.length-1])})}},applyExtensions:function(){this.base();this.extend(this.pvBullets,"bulletsPanel");this.extend(this.pvBullet,"bulletPanel");this.extend(this.pvBulletRange,"bulletRange");this.extend(this.pvBulletMeasure,"bulletMeasure");this.extend(this.pvBulletMarker,"bulletMarker");this.extend(this.pvBulletRule,"bulletRule");this.extend(this.pvBulletRuleLabel,"bulletRuleLabel");this.extend(this.pvBulletTitle,"bulletTitle");this.extend(this.pvBulletSubtitle,"bulletSubtitle")},_getExtensionId:function(){return[{abs:"content"}].concat(this.base())},buildData:function(){var t,i=this.chart,n=i.options,a=i.visualRoles.title,r=a.grouping,s=i.visualRoles.subTitle,o=s.grouping,l=i.visualRoles.value,u=l.grouping,c=i.visualRoles.marker,h=c.grouping,d=i.visualRoles.range,f=d.grouping,v={title:n.bulletTitle,formattedTitle:n.bulletTitle,subtitle:n.bulletSubtitle,formattedSubtitle:n.bulletSubtitle,ranges:e.array.to(n.bulletRanges)||[],measures:e.array.to(n.bulletMeasures)||[],markers:e.array.to(n.bulletMarkers)||[]}; e.set(v,"formattedRanges",v.ranges.map(String),"formattedMeasures",v.measures.map(String),"formattedMarkers",v.markers.map(String));t=u||r||h||o||f?i.data.datums().select(function(e){var t,i=Object.create(v);if(u){t=u.view(e);i.measures=t.values();i.formattedMeasures=t.labels()}if(r){t=r.view(e);i.title=t.value;i.formattedTitle=t.label}if(o){t=o.view(e);i.subtitle=t.value;i.formattedSubtitle=t.label}if(h){t=h.view(e);i.markers=t.values();i.formattedMarkers=t.labels()}if(f){t=f.view(e);i.ranges=t.values();i.formattedRanges=t.labels()}return i},this).array():[v];return t}});e.type("pvc.ParallelCoordinates",Tt.BaseChart).init(function(e){e=e||{};e.dimensions=e.dimensions||{};e.dimensions.value||(e.dimensions.value={valueType:null});this.base(e)}).add({parCoordPanel:null,_createContent:function(t){this.parCoordPanel=new Tt.ParCoordPanel(this,this.basePanel,e.create(t,{topRuleOffset:this.options.topRuleOffset,botRuleOffset:this.options.botRuleOffset,leftRuleOffset:this.options.leftRuleOffset,rightRuleOffset:this.options.rightRuleOffset,sortCategorical:this.options.sortCategorical,mapAllDimensions:this.options.mapAllDimensions,numDigits:this.options.numDigits})) },defaults:e.create(Tt.BaseChart.prototype.defaults,{compatVersion:1,topRuleOffset:30,botRuleOffset:30,leftRuleOffset:60,rightRuleOffset:60,sortCategorical:!0,mapAllDimensions:!0,numDigits:0})});e.type("pvc.ParCoordPanel",Tt.BasePanel).add({anchor:"fill",pvParCoord:null,dimensions:null,dimensionDescr:null,data:null,retrieveData:function(){var e=this.chart.data,t=this.chart.options.numDigits;this.dimensions=e.getVisibleCategories();var i=e.getValues(),n=e.getVisibleSeriesIndexes(),a=e.getVisibleCategoriesIndexes(),r=e.getCategories(),s=a.map(this.chart.options.mapAllDimensions?function(e){return isNaN(i[e][0])?{categorical:!0,len:0,map:[]}:{categorical:!1,len:0,map:[],displayValue:[]}}:function(e){return isNaN(i[e][0])?{categorical:!0,len:0,map:[]}:null}),o=function(e,i){var n=s[e],a=null;if(n.categorical){a=n.map[i];if(null==a){a=n.len;n.len++;n.map[i]=a}}else{var r=i.toFixed(t);a=n.map[r];if(null==a){a=n.len;n.len++;n.map[r]=a;n.displayValue[r]=i}}return a};for(var l in s)s.hasOwnProperty(l)&&s[l]&&s[l].categorical&&(s[l].displayValue=s[l].map); var u,c,h;if(this.chart.options.sortCategorical||this.chart.options.mapAllDimensions)for(u=0;u1?i[1]:"";return t});for(u=0;uh;h++){S=s[g].displayValue[i[g][h]];if(b>S){y=b;b=S}if(S>_){x=_;_=S}}}else{b=_=y=x=i[g][0];for(h=1;w>h;h++){S=i[g][h];if(b>S){y=b;b=S}if(S>_){x=_;_=S}}}var C=(_-x+(y-b))/2;c.min=b;c.max=_;c.step=C;c.categorical=!1;if(s[g]){c.map=s[g].map;c.mapLength=s[g].len;c.categorical=s[g].categorical; if(!c.categorical){c.orgValue=[];var k=s[g].map;for(var D in k)k.hasOwnProperty(D)&&(c.orgValue[k[D]]=0+D)}}}var P=function(e,t){for(var i={},n=0;n=x[t].min&&n<=x[t].max})}:function(e){return f.every(function(t){return e[t]>=x[t].min&&e[t]<=x[t].max})};this.pvParCoord=this.pvPanel.add(t.Panel).data(n.data).visible(w).add(t.Line).data(f).left(function(e){return b(e)}).bottom(function(e,t){var i=_[e](t[e]);return i}).strokeStyle("#ddd").lineWidth(1).antialias(!1);var C=this.pvPanel.add(t.Rule).data(f).left(b).top(s).bottom(o);C.anchor("top").add(t.Label).top(d).font("bold 10px sans-serif").text(function(e){return v[e].name });var k=[],D=6,P=3;for(var I in v)if(v.hasOwnProperty(I)){var R=v[I];if(R.categorical){var M=b(R.id)+D;for(var T in R.map)R.map.hasOwnProperty(T)&&(k[k.length]={x:M,y:_[R.id](R.map[T])+P,label:T})}}var A=(this.pvPanel.add(t.Panel).data(k).add(t.Label).left(function(e){return e.x}).bottom(function(e){return e.y}).text(function(e){return e.label}).textAlign("left"),this.pvPanel.add(t.Panel)),L=(A.add(t.Panel).data(n.data).visible(w).add(t.Line).data(f).left(function(e){return b(e)}).bottom(function(e,t){return _[e](t[e])}).strokeStyle(function(e,t){var i=v[S],n=i.orgValue&&!i.categorical?i.orgValue[t[S]]:t[S];return y[S](n)}).lineWidth(1),A.add(t.Panel).data(f.map(function(e){return{y:o,dy:h,dim:e}})).left(function(e){return b(e.dim)-30}).width(60).fillStyle("rgba(0,0,0,.001)").cursor("crosshair").event("mousedown",t.Behavior.select()).event("select",e).event("selectend",i).add(t.Bar).left(25).top(function(e){return e.y}).width(10).height(function(e){return e.dy}).fillStyle(function(e){return e.dim==S?y[e.dim]((x[e.dim].max+x[e.dim].min)/2):"hsla(0,0,50%,.5)" }).strokeStyle("white").cursor("move").event("mousedown",t.Behavior.drag()).event("dragstart",e).event("drag",e));L.anchor("bottom").add(t.Label).textBaseline("top").text(function(e){return v[e.dim].categorical?"":x[e.dim].min.toFixed(r)+v[e.dim].unit});L.anchor("top").add(t.Label).textBaseline("bottom").text(function(e){return v[e.dim].categorical?"":x[e.dim].max.toFixed(r)+v[e.dim].unit});this.extend(this.pvParCoord,"parCoord");this.extend(this.pvPanel,"chart")}});e.type("pvc.DataTree",Tt.BaseChart).init(function(e){e=e||{};e.dimensionGroups=e.dimensionGroups||{};e.dimensionGroups.value||(e.dimensionGroups.value={valueType:null});this.base(e)}).add({structEngine:null,structMetadata:null,structDataset:null,DataTreePanel:null,_getColorRoleSpec:function(){return{isRequired:!0,defaultSourceRole:"category",requireIsDiscrete:!0}},setStructData:function(e){this.structDataset=e.resultset;this.structDataset.length||this._log("Warning: Structure-dataset is empty");this.structMetadata=e.metadata; this.structMetadata.length||this._log("Warning: Structure-Metadata is empty")},_createContent:function(t){var i=this.structEngine,n=i?i.type:new Tt.data.ComplexType;n.addDimension("value",{});var a={seriesInRows:!0,crosstabMode:!0},r=new Tt.data.CrosstabTranslationOper(n,this.structDataset,this.structMetadata,a);r.configureType();i||(i=this.structEngine=new Tt.data.Data({type:n}));i.load(r.execute(i));Tt.debug>=3&&this._log(this.structEngine.getInfo());this.dataTreePanel=new Tt.DataTreePanel(this,this.basePanel,e.create(t,{topRuleOffset:this.options.topRuleOffset,botRuleOffset:this.options.botRuleOffset,leftRuleOffset:this.options.leftRuleOffset,rightRuleOffset:this.options.rightRuleOffset,boxplotColor:this.options.boxplotColor,valueFontsize:this.options.valueFontsize,headerFontsize:this.options.headerFontsize,border:this.options.border,perpConnector:this.options.perpConnector,numDigits:this.options.numDigits,minVerticalSpace:this.options.minVerticalSpace,connectorSpace:this.options.connectorSpace,minAspectRatio:this.options.minAspectRatio})) },defaults:{compatVersion:1,topRuleOffset:30,botRuleOffset:30,leftRuleOffset:60,rightRuleOffset:60,boxplotColor:"grey",headerFontsize:16,valueFontsize:20,border:2,perpConnector:!1,numDigits:0,connectorSpace:.15,minVerticalSpace:.05,minAspectRatio:2}});e.type("pvc.DataTreePanel",Tt.PlotPanel).add({pvDataTree:null,treeElements:null,structMap:null,structArr:null,hRules:null,vRules:null,rules:null,generatePerpConnectors:function(e){this.hRules=[];this.vRules=[];this.rules=[];for(var t in this.structMap){var i=this.structMap[t];if(null!=i.children){var n=1e4,a=-1e4,r=i.left+i.width;this.hRules.push({left:r,width:e,bottom:i.bottom+i.height/2});r+=e;for(var s in i.children){var o=this.structMap[i.children[s]],l=o.bottom+o.height/2;l>a&&(a=l);n>l&&(n=l);this.hRules.push({left:r,width:o.left-r,bottom:l})}a>n&&this.vRules.push({left:r,bottom:n,height:a-n})}}},generateLineSegment:function(e,t,i,n){var a=[];a.push({x:e,y:t});a.push({x:i,y:n});this.rules.push(a)},generateConnectors:function(e){this.hRules=[]; this.vRules=[];if(this.chart.options.perpConnector)this.generatePerpConnectors(e);else{this.rules=[];for(var t in this.structMap){var i=this.structMap[t];if(null!=i.children){var n,a,r,s=1e4,o=-1e4;for(r in i.children){a=this.structMap[i.children[r]];n=a.bottom+a.height/2;n>o&&(o=n);s>n&&(s=n)}var l=(o+s)/2,u=i.left+i.width,c=u+e;this.generateLineSegment(u,i.bottom+i.height/2,c,l);for(r in i.children){a=this.structMap[i.children[r]];n=a.bottom+a.height/2;this.generateLineSegment(c,l,a.left,n)}}}}},retrieveStructure:function(){var e=this.chart.structEngine,t=this.chart.options,i=e.getVisibleCategories();this.treeElements=e.getVisibleSeries();var n,a=e.getValues(),r=i.length>4;for(n in this.treeElements)this.treeElements[n]=$.trim(this.treeElements[n]);var s=[];s.getElement=function(e){null==s[e]&&(s[e]={min:1e4,max:-1e4});return s[e]};s.addValue=function(e,t){var i=s.getElement(e);ti.max&&(i.max=t);return i};var o,l,u,c;for(n in this.treeElements){u=this.treeElements[n]; o=u[0];l=o.charCodeAt(0);c=parseInt(u.slice(1),10);s.addValue("__cols",l);s.addValue(o,c)}var h=s.getElement("__cols"),d=this.innerWidth/(h.max-h.min+1),f=t.connectorSpace*d,v=d-f,p=v/t.minAspectRatio,m=h.min;delete s.__cols;for(n in s){h=s[n];if("function"!=typeof h){var g=h.max-h.min+1;h.gridHeight=this.innerHeight/g;h.cellHeight=h.gridHeight*(1-t.minVerticalSpace);h.cellHeight>p&&(h.cellHeight=p);h.relBottom=(h.gridHeight-h.cellHeight)/2;h.numRows=g}}var b=new RegExp("[\\s\"']+","g");this.structMap={};for(n in this.treeElements){var _={};u=this.treeElements[n];_.box_id=u;this.structMap[u]=_;o=u[0];l=o.charCodeAt(0);c=parseInt(u.slice(1),10);h=s.getElement(o);_.colIndex=l-m;_.rowIndex=h.numRows-(c-h.min)-1;_.left=this.leftOffs+_.colIndex*d;_.width=v;if(r){_.bottom=a[4][n];_.height=a[5][n]}else{_.bottom=this.botOffs+_.rowIndex*h.gridHeight+h.relBottom;_.height=h.cellHeight}_.label=a[0][n];_.selector=a[1][n];_.aggregation=a[2][n];var y=(a[3][n]||"").replace(b," ");_.children=" "===y||""===y?null:y.split(" ") }this.generateConnectors((d-v)/2);this.structArr=[];for(n in this.structMap){u=this.structMap[n];this.structArr.push(u)}},findDataValue:function(e,t){for(var i=0;ir[0])a.hScale=t.Scale.linear(r[0],r[4]);else{l=!0;a.hScale=t.Scale.linear(r[0]-1e-10,r[0]+1e-10)}a.hScale.range(n.left+o,n.left+n.width-o);var u,c=""+r[2]; for(u=0;ue;e++)l.values.push([]);r[l.selector]=l}var u={};for(e in n){var c=r[n[e]];if("undefined"!=typeof c)for(var h in a)c.values[h].push(a[h][e]);else u[n[e]]=!0}for(var d in u)this._log("Could'nt find box for selector: "+d);this.generateBoxPlots();var f=new RegExp("[\\s\"']+","g");if(i.selectParam){var v=i.selectParam.replace(f,"");if("undefined"!=v&&v.length>0&&"undefined"!=typeof window[v]){v=window[v];this.addDataPoint(v)}}},_createCore:function(){var e=this,i=this.chart.options;i.smValueFontsize=Math.round(.6*i.valueFontsize);i.smValueFont=""+i.smValueFontsize+"px sans-serif"; i.valueFont=""+i.valueFontsize+"px sans-serif";var n=i.topRuleOffset,a=i.botRuleOffset,r=i.leftRuleOffset;this.innerWidth=this.width-r-i.rightRuleOffset;this.innerHeight=this.height-n-a;this.botOffs=a;this.leftOffs=r;this.retrieveStructure();this.retrieveData();var s,o=i.headerFontsize+3,l=this.rules;for(s=0;s=3&&this._log("Creating Point panel.");var s=new Tt.PointPanel(this,e,r,Object.create(t));s._v1DimRoleName.value=r.option("OrthoRole")}},defaults:{crosstabMode:!1}}).addStatic({measureRolesNames:["median","lowerQuartil","upperQuartil","minimum","maximum"]});e.type("pvc.visual.TreemapDiscreteColorAxis",Tt.visual.ColorAxis).init(function(e,t,i,n){this.base(e,t,i,n);this.isByParent="byparent"===e.plots.treemap.option("ColorMode") }).add({domainItemValueProp:function(){return this.role&&this.role.grouping.isSingleDimension?"value":"absKey"},domainGroupOperator:function(){return"select"},_calcAvgColor:function(e){var i=e.length;if(i>1){var n=0,a=0,r=0,s=0;e.forEach(function(e){var t=e.rgb();n+=t.r;a+=t.g;r+=t.b;s+=t.a});var o=Math.floor;return t.rgb(o(n/i),o(a/i),o(r/i),o(s/i))}var l=e[0];return i?l.darker(.7):l},_getBaseScheme:function(){var t=this,i=function(e){return null!=e.value},n=function(e){return e.children().where(i)},a=function(e){return n(e).any()},r=function(e){return n(e).any(a)},s=e.query(this.domainData().nodes()).where(r).array(),o=t.option("Colors");return function(i){var a=i instanceof Array?i:e.array.copy(arguments),r=e.query(s).object({name:function(e){return t.domainItemValue(e)}});e.array.removeIf(a,function(t){return e.hasOwnProp.call(r,t)});var l=o(a),u={},c=function(i){var a,s=t.domainItemValue(i);if(e.hasOwnProp.call(r,s)){a=e.getOwn(u,s);if(!a){var o=n(i).select(c).array();if(!o.length)throw e.assert("Should have at least one child that is also a parent."); a=u[s]=t._calcAvgColor(o)}}else a=l(s);return a};s.forEach(c);var h=function(t){return e.getOwn(u,t)||l(t)};e.copy(h,l);var d,f;h.domain=function(){if(arguments.length)throw e.error.operationInvalid("The scale cannot be modified.");return d||(d=e.array.append(e.ownKeys(u),a))};h.range=function(){if(arguments.length)throw e.error.operationInvalid("The scale cannot be modified.");return f||(f=e.array.append(e.own(u),l.range()))};return h}},_selectDomainItems:function(t){var i=e.query(t.nodes()),n=function(e){return null!=e.value},a=function(e){return e.children().where(n)},r=function(e){return a(e).any()},s=function(e){return!r(e)};return i.where(this.isByParent?function(e){return e.parent?n(e)&&r(e):s(e)||a(e).any(s)}:function(e){return(!e.parent||n(e))&&s(e)})}});e.type("pvc.data.TreemapChartTranslationOper").add({_configureTypeCore:function(){var t=[],i=[],n=[];this.collectFreeDiscreteAndConstinuousIndexes(n,i);var a=n.length,r=i.length;a&&this._getUnboundRoleDefaultDimNames("category",a,t); r&&e.query(["size","color"]).take(r).each(function(e){this._getUnboundRoleDefaultDimNames(e,1,t)},this);t.length&&this.defReader({names:t})}});e.type("pvc.TreemapPanel",Tt.PlotPanel).init(function(e,t,i,n){this.base(e,t,i,n);this.axes.size=e._getAxis("size",(i.option("SizeAxis")||0)-1);this.visualRoles.size=e.visualRole(i.option("SizeRole"));this.layoutMode=i.option("LayoutMode")}).add({_createCore:function(i){var n=this,a=i.clientSize,r=n._buildScene();if(r){if(!r.childNodes.length&&!this.visualRoles.multiChart.isBound())throw new InvalidDataException("Unable to create a treemap chart, please check the data values.");var s=e.number.to(n._getConstantExtension("leaf","lineWidth"),1),o=s,l=o/2,u=n.visualRoles.size.isBound()?n.axes.size.scale.by1(function(e){return e.vars.size.value}):100,c=n.pvTreemapPanel=new Tt.visual.Panel(n,n.pvPanel,{panelType:t.Layout.Treemap,extensionId:"panel"}).pvMark.lock("visible",!0).lock("nodes",r.nodes()).lock("left",l).lock("top",l).lock("width",a.width-o).lock("height",a.height-o).lock("size",u).lock("mode",n.layoutMode).lock("order",null).lock("round",!1); c.node.left(function(e){return e.x+l}).top(function(e){return e.y+l}).width(function(e){return e.dx-o}).height(function(e){return e.dy-o});var h,d=n.axes.color;h=n.visualRoles.color.isBound()?d.sceneScale({sceneVarName:"color"}):e.fun.constant(d.option("Unbound"));var f=new Tt.visual.Bar(n,c.leaf,{extensionId:"leaf"}).lockMark("visible").override("defaultColor",function(e){return h(e)}).override("defaultStrokeWidth",function(){return s}).pvMark.antialias(!1).lineCap("round").strokeDasharray(function(e){return e.vars.size.value<0?"dash":null});new Tt.visual.Bar(n,c.node,{extensionId:"ascendant",noHover:!0,noSelect:!0,noClick:!0,noDoubleClick:!0}).intercept("visible",function(e){return!!e.parent&&!!e.firstChild&&this.delegateExtension(!0)}).override("anyInteraction",function(e){return e.anyInteraction()||e.isActiveDescendantOrSelf()}).override("defaultStrokeWidth",function(){return 1.5*o}).override("interactiveStrokeWidth",function(e,t){this.showsActivity()&&e.isActiveDescendantOrSelf()&&(t=1.5*Math.max(1,t)); return t}).override("defaultColor",function(e){return h(e)}).override("normalColor",e.fun.constant(null)).override("interactiveColor",function(e,i,n){if("stroke"===n){if(this.showsActivity()){if(e.isActiveDescendantOrSelf())return t.color(i).brighter(.5);if(e.anyActive())return null}if(this.showsSelection()&&e.isSelectedDescendantOrSelf())return t.color(i).brighter(.5)}return null}).pvMark.antialias(!1);var v=Tt.visual.ValueLabel.maybeCreate(n,c.label,{noAnchor:!0});v&&v.pvMark.textMargin(3).sign.optional("textAngle",function(e){var i=this.defaultText(e),n=this.pvMark;return e.dx-2*n.textMargin()>t.Text.measureWidth(i,n.font())?0:e.dx>=e.dy?0:-Math.PI/2}).override("calcTextFitInfo",function(e,i){var n=this.pvMark,a=n.textMargin();if(!(-1e-6>a)){var r=n.textAngle();isHorizText=Math.abs(Math.sin(r))<1e-6,isVertiText=!isHorizText&&Math.abs(Math.cos(r))<1e-6;if(isHorizText||isVertiText){var s,o=!1,l=t.Text.measure(i,n.font()),u=.75*l.height,c=e[isVertiText?"dx":"dy"];"middle"!==n.textBaseline()&&(c/=2); c-=2*a;o|=u>c;var s=e[isVertiText?"dy":"dx"];"center"!==n.textAlign()&&(s/=2);s-=2*a;o|=0>=s||this.hideOverflowed&&l.width>s;return{hide:o,widthMax:s}}}}).override("getAnchoredToMark",function(){return f})}},_getExtensionId:function(){var e=[{abs:this.chart.parent?"smallContent":"content"}];return e.concat(this.base())},renderInteractive:function(){this.pvTreemapPanel.render()},_buildScene:function(){var e=this.visibleData({ignoreNulls:!1});if(!e.childCount())return null;var t=this.visualRoles,i=new Tt.visual.Scene(null,{panel:this,source:e}),n=new Tt.visual.RoleVarHelper(i,t.size,{roleVar:"size",allowNestedVars:!0,hasPercentSubVar:!0}),a=t.size.isBound(),r=t.color&&t.color.grouping,s=r&&"byparent"===this.plot.option("ColorMode"),o=function(e){var t=e.group;e.vars.category=jt.fromComplex(t);n.onNewScene(e,!0);if(a&&!e.vars.size.value){e.parentNode&&e.parentNode.removeChild(e);return e}var i=t.children().where(function(e){return null!=e.value}).array();if(r){var l=s&&!i.length?t.parent:t; if(l){var u=r.view(l);e.vars.color=new jt(u.keyTrimmed(),u.label)}else e.vars.color=new jt(null,"")}else e.parent||(e.vars.color=new jt(null,""));i.length&&i.forEach(function(t){o(new Tt.visual.Scene(e,{source:t}))});return e};return o(i)}});e.type("pvc.TreemapChart",Tt.BaseChart).add({_animatable:!1,_axisClassByType:{size:Tt.visual.NormalizedAxis},_axisCreateIfUnbound:{color:!0},_getColorRoleSpec:function(){return{defaultSourceRole:"category",defaultDimension:"color*"}},_initVisualRoles:function(){this.base();this._addVisualRole("category",{isRequired:!0,defaultDimension:"category*",autoCreateDimension:!0});this._addVisualRole("size",{isMeasure:!0,isRequired:!1,isPercent:!0,requireSingleDimension:!0,requireIsDiscrete:!1,valueType:Number,defaultDimension:"size"})},_getTranslationClass:function(t){return e.type(this.base(t)).add(Tt.data.TreemapChartTranslationOper)},_getIsNullDatum:e.fun.constant(),_initPlotsCore:function(){var e=new Tt.visual.TreemapPlot(this);null==this.options.legend&&(this.options.legend="byparent"===e.option("ColorMode")); var t=e.option("RootCategoryLabel");this.visualRoles.category.setRootLabel(t);this.visualRoles.color.setRootLabel(t)},_initAxes:function(t){if(this.visualRoles.color.isDiscrete()){e.hasOwnProp.call(this,"_axisClassByType")||(this._axisClassByType=Object.create(this._axisClassByType));this._axisClassByType.color=Tt.visual.TreemapDiscreteColorAxis}else delete this._axisClassByType;return this.base(t)},_createContent:function(e){this.base();var t=this.plots.treemap;new Tt.TreemapPanel(this,this.basePanel,t,e)},_createVisibleData:function(e,t){return this.visualRoles.category.select(e,t)},defaults:{legend:null}});e.type("pvc.visual.SunburstDiscreteColorAxis",Tt.visual.ColorAxis).add({_getOptionsDefinition:function(){return ui},domainItemValueProp:function(){return this.role&&this.role.grouping.isSingleDimension?"value":"absKey"},domainGroupOperator:function(){return"select"},_selectDomainItems:function(t){var i=e.query(t.nodes()),n=function(e){return null!=e.value};return i.where(function(e){return e.parent?n(e)&&!e.parent.parent:!1 })}});var ui=e.create(ri,{SliceBrightnessFactor:{resolve:"_resolveFull",cast:Tt.castNonNegativeNumber,value:1}});e.type("pvc.visual.SunburstSlice",Tt.visual.Sign).init(function(i,n,a){var r=n.add(t.Wedge);a=e.setDefaults(a,"freeColor",!1);this.base(i,r,a);this._bindProperty("lineWidth","strokeWidth")}).prototype.property("strokeWidth").constructor.add({defaultStrokeWidth:e.fun.constant(.5),interactiveStrokeWidth:function(e,t){return this.showsActivity()&&e.isActiveDescendantOrSelf()?2*Math.max(1,t):t},defaultColor:function(e){return e.color},normalColor:function(e,t,i){return t&&"stroke"===i?t.darker():t},interactiveColor:function(e,t,i){if(this.showsActivity())if("stroke"===i){if(e.isActiveDescendantOrSelf())return t.brighter(2).alpha(.7)}else if(e.isActive)return t.brighter(.2).alpha(.8);return this.mayShowNotAmongSelected(e)?this.dimColor(t,i):this.normalColor(e,t,i)}});e.type("pvc.data.SunburstChartTranslationOper").add({_configureTypeCore:function(){var e=[],t=[],i=[];this.collectFreeDiscreteAndConstinuousIndexes(i,t); var n=i.length,a=t.length;n&&this._getUnboundRoleDefaultDimNames("category",n,e);a&&this._getUnboundRoleDefaultDimNames("size",1,e);e.length&&this.defReader({names:e})}});e.type("pvc.SunburstPanel",Tt.PlotPanel).init(function(e,t,i,n){this.base(e,t,i,n);this.axes.size=e._getAxis("size",(i.option("SizeAxis")||0)-1);this.visualRoles.size=e.visualRole(i.option("SizeRole"));this.sliceOrder=i.option("SliceOrder");this.emptySlicesVisible=i.option("EmptySlicesVisible");this.emptySlicesLabel=this.emptySlicesVisible?i.option("EmptySlicesLabel"):""}).add({_createCore:function(i){var n=this._getConstantExtension("label","font");e.string.is(n)&&(this.valuesFont=n);var a=this,r=(i.clientSize,a._buildScene());if(r){if(!r.childNodes.length&&!this.visualRoles.multiChart.isBound())throw new InvalidDataException("Unable to create a sunburst chart, please check the data values.");var s=a.visualRoles.size.isBound()?a.axes.size.scale.by1(function(e){return e.vars.size.value}):e.fun.constant(100),o=a.pvSunburstPanel=new Tt.visual.Panel(a,a.pvPanel,{panelType:t.Layout.Partition.Fill,extensionId:"panel"}).pvMark.lock("visible",!0).lock("nodes",r.nodes()).lock("size",s).lock("orient","radial"),l=new Tt.visual.SunburstSlice(this,o.node,{extensionId:"slice",tooltipArgs:{options:{useCorners:!0,gravity:function(){var e=this.midAngle(),t=Math.cos(e)>=0,i=Math.sin(e)>=0; return t?i?"nw":"sw":i?"ne":"se"}}}}),u=Tt.visual.ValueLabel.maybeCreate(a,o.label,{noAnchor:!0});u&&u.override("defaultText",function(e){return e.isRoot()?"":this.base(e)}).override("calcTextFitInfo",function(e,i){var n=this.pvMark,a=n.textMargin();if(!(-1e-6>a)&&"center"===n.textAlign()&&i){var r=Tt.normAngle(e.midAngle),s=Tt.normAngle(n.textAngle()),o=Math.abs(r-s)<1e-6,l=!1;if(!o){var u=Tt.normAngle(s+Math.PI);l=Math.abs(r-u)<1e-6}if(o||l){var c,h=e.innerRadius,d=h,f=e.outerRadius,a=n.textMargin(),v=e.angle,p=t.Text.measure(i,n.font()),m=!1;if(v=c;c-=a;m|=this.hideOverflowed&&p.width>c;return{hide:m,widthMax:c}}}}).override("getAnchoredToMark",function(){return l.pvMark})}},_getExtensionId:function(){var e=[{abs:this.chart.parent?"smallContent":"content"}];return e.concat(this.base())},renderInteractive:function(){this.pvSunburstPanel.render()},_buildScene:function(){var t=this.visibleData({ignoreNulls:!1}),i=this.emptySlicesVisible,n=this.emptySlicesLabel; if(!t.childCount())return null;var a,r=this.visualRoles,s=new Tt.visual.SunburstScene(null,{panel:this,source:t}),o=r.size.isBound(),l=new Tt.visual.RoleVarHelper(s,r.size,{roleVar:"size",allowNestedVars:!0,hasPercentSubVar:!0}),u=r.color&&r.color.grouping,c=this.axes.color,h=c.option("SliceBrightnessFactor");a=r.color.isBound()?c.sceneScale({sceneVarName:"color"}):e.fun.constant(c.option("Unbound"));var d=function(e){var t=e.group,a=e.vars.category=jt.fromComplex(t);n&&null==a.value&&(a.value=n);l.onNewScene(e,!0);if(o&&!e.vars.size.value){e.parentNode&&e.parentNode.removeChild(e);return e}var r=t.children();i||(r=r.where(function(e){return null!=e.value}));if(u){var s=u.view(t);e.vars.color=new jt(s.keyTrimmed(),s.label)}else e.vars.color=new jt(null,"");r.each(function(t){d(new Tt.visual.SunburstScene(e,{source:t}))});return e},f=function(e,t,i){var n=null,r=e.parent;if(r){n=a(e);if(!r.isRoot()&&!n.isFixedColor){n=r.color;t&&h&&(n=n.brighter(h*t/(i-1)))}}e.color=n;var s=e.childNodes,o=s.length; s.forEach(function(e,t){f(e,t,o)})};d(s);if(this.sliceOrder&&o&&"none"!==this.sliceOrder){var v="bysizeascending"===this.sliceOrder?e.ascending:e.descending;s.sort(function(t,i){return v(t.vars.size.value,i.vars.size.value)||e.ascending(t.childIndex(),i.childIndex())})}f(s,0);return s}});e.type("pvc.visual.SunburstScene",Tt.visual.Scene).add({_createSelectedInfo:function(){var e=this.chart().data.owner.selectedCount()>0,t=e&&this.datums().all(Gt);return{any:e,is:t}}});e.type("pvc.SunburstChart",Tt.BaseChart).add({_animatable:!1,_axisClassByType:{size:Tt.visual.NormalizedAxis},_axisCreateIfUnbound:{color:!0},_getColorRoleSpec:function(){return{defaultSourceRole:"category",defaultDimension:"color*",requireIsDiscrete:!0}},_initVisualRoles:function(){this.base();this._addVisualRole("category",{isRequired:!0,defaultDimension:"category*",autoCreateDimension:!0});this._addVisualRole("size",{isMeasure:!0,isRequired:!1,isPercent:!0,requireSingleDimension:!0,requireIsDiscrete:!1,valueType:Number,defaultDimension:"size"}) },_getTranslationClass:function(t){return e.type(this.base(t)).add(Tt.data.SunburstChartTranslationOper)},_getIsNullDatum:e.fun.constant(),_initPlotsCore:function(){var e=new Tt.visual.SunburstPlot(this);this.options.legend=!1;var t=e.option("RootCategoryLabel");this.visualRoles.category.setRootLabel(t);this.visualRoles.color.setRootLabel(t)},_initAxes:function(t){e.hasOwnProp.call(this,"_axisClassByType")||(this._axisClassByType=Object.create(this._axisClassByType));this._axisClassByType.color=Tt.visual.SunburstDiscreteColorAxis;return this.base(t)},_createContent:function(e){this.base();var t=this.plots.sunburst;new Tt.SunburstPanel(this,this.basePanel,t,e)},_createVisibleData:function(e,t){return this.visualRoles.category.select(e,t)}});return Tt}(def,pv);