@xiee/utils
Version:
Miscellaneous tools and utilities to manipulate HTML pages
2 lines • 2.21 kB
JavaScript
G2.register("data.column",e=>{const{value:t}=e;return async()=>{let e=t;if("string"==typeof t){const o=await fetch(t);e=await o.json()}const o=Object.keys(e);return 0===o.length?[]:Array.isArray(e[o[0]])?e[o[0]].map((t,r)=>o.reduce((t,o)=>(t[o]=e[o][r],t),{})):[e]}}),(()=>{const e=4/3,t=/[fF]ontSize$/,o=e=>e&&"object"==typeof e&&!Array.isArray(e),r=n=>{if(o(n))for(const[s,a]of Object.entries(n))o(a)?r(a):"number"==typeof a&&t.test(s)&&(n[s]=a*e)},n=t=>{if(r(t),o(t.legendCategory)&&"number"==typeof t.legendCategory.itemMarkerSize&&(t.legendCategory.itemMarkerSize*=e),o(t.point))for(const e of Object.values(t.point))o(e)&&"number"==typeof e.r&&(e.r=4);return o(t.axis)&&(t.axis.gridStrokeOpacity=.25),t.inset=16,t};for(const e of["Light","Dark","Classic","ClassicDark","Academy"]){const t=G2[e];if("function"!=typeof t)continue;let o;const r=(...e)=>o??=n(t(...e)),s="theme."+e[0].toLowerCase()+e.slice(1),a=e=>null===e||"object"!=typeof e?e:Array.isArray(e)?e.map(a):Object.fromEntries(Object.entries(e).map(([e,t])=>[e,a(t)])),c=(...e)=>a(r(...e));G2[e]=c;try{G2.register(s,c)}catch(e){}}const s=()=>(e,t)=>{if(void 0!==t.encode.size)return[e,t];const o=[];for(const t of e)o[t]=4;return[e,{...t,encode:{...t.encode,size:{type:"column",value:o,visual:!0}}}]};s.props={};const a=G2.corelib();for(const e of["mark.point","mark.beeswarm"])for(const[t,o]of(a[e]?.props?.postInference??[]).entries())o.type===G2.MaybeSize&&(a[e].props.postInference[t]={type:s});for(const e of["mark.point","mark.beeswarm"]){const t=a[e];if(!t?.props?.shape)continue;t.props.defaultShape="point";const o=Object.fromEntries(Object.entries(t.props.shape).sort(([e],[t])=>/^hollow/.test(e)-/^hollow/.test(t)));t.props.shape=o;for(const e of t.props.channels||[])"shape"===e.name&&(e.range=Object.keys(o))}const c=G2.graphlib?.()??{};for(const t of["mark.sankey","mark.chord","mark.treemap"]){const o=c[t];if("function"!=typeof o)continue;const r=function(...t){const r=o.apply(this,t);for(const t of Array.isArray(r)?r:[r])if(Array.isArray(t?.labels))for(const o of t.labels)"number"==typeof o?.fontSize&&(o.fontSize*=e);return r};r.props=o.props;try{G2.register(t,r)}catch(e){}}})();
//# sourceMappingURL=g2-patches.min.js.map