OcttKB/Wiki-OcttKB/plugins/echarts/$__plugins_Gk0Wk_echarts_wi...

9 lines
8.7 KiB
JSON
Raw Permalink Normal View History

2023-06-11 22:14:59 +02:00
[
{
"title": "$:/plugins/Gk0Wk/echarts/widget.js",
"text": "\"use strict\";var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__copyProps=(e,i,r,s)=>{if(i&&\"object\"==typeof i||\"function\"==typeof i)for(let t of __getOwnPropNames(i))__hasOwnProp.call(e,t)||t===r||__defProp(e,t,{get:()=>i[t],enumerable:!(s=__getOwnPropDesc(i,t))||s.enumerable});return e},__toESM=(t,e,i)=>(i=null!=t?__create(__getProtoOf(t)):{},__copyProps(!e&&t&&t.__esModule?i:__defProp(i,\"default\",{value:t,enumerable:!0}),t)),import_widget=require(\"$:/core/modules/widgets/widget.js\"),ECharts=__toESM(require(\"$:/plugins/Gk0Wk/echarts/echarts.min.js\")),echartWidgets=new Set,Function_=Function;if($tw.browser){globalThis.echarts=ECharts;try{$tw.modules.forEachModuleOfType(\"echarts-extension\",(t,e)=>{var i,r,s,n,h;\"$:/plugins/Gk0Wk/echarts-stat/ecStat.min.js\"===t&&(({transform:{histogram:r,clustering:s,regression:n},statistics:h}=e),null!=(i=ECharts.registerTransform)&&i(r),null!=(r=ECharts.registerTransform)&&r(s),null!=(i=ECharts.registerTransform)&&i(n),globalThis.EChartsStat=h)})}catch(error){console.error(error)}setInterval(()=>{var t=[];for(const i of echartWidgets)document.contains(i.containerDom)||(unmountAddon(i.tiddlerTitle,i.state,i.echartsInstance),i.clearInstance(),t.push(i));var e=t.length;for(let r=0;r<e;r++)echartWidgets[\"delete\"](t[r])},1e3)}var unmountAddon=(t,e,i)=>{var r,s,n,h,a;try{i.off(\"restore\"),t&&\"application/javascript\"===(null==(s=null==(r=$tw.wiki.getTiddler(t))?void 0:r.fields)?void 0:s.type)&&(a=(null!=(n=(h=require(t))[\"default\"])?n:h)[\"onUnmount\"],\"function\"==typeof a)&&a(e)}catch(error){console.error(error)}},nextId=0,EChartsWidget=class extends import_widget.widget{constructor(){super(...arguments),this.uuid=\"gk0wk-echarts-container-\"+nextId++,this.width=\"100%\",this.height=\"300px\",this[\"class\"]=\"gk0wk-echarts-body\",this.fillSidebar=!0,this.renderer=\"canvas\"}initialise(t,e){super.initialise(t,e),this.computeAttributes()}execute(){switch(this.tiddlerTitle=this.getAttribute(\"$tiddler\",\"\")||void 0,this.width=this.getAttribute(\"$width\",\"100%\"),this.height=this.getAttribute(\"$height\",\"300px\"),this[\"class\"]=this.getAttribute(\"$class\",\"gk0wk-echarts-body\"),this.fillSidebar=\"true\"===this.getAttribute(\"$fillSidebar\",\"true\").toLowerCase(),this.getAttribute(\"$theme\",\"auto\")){case\"light\":this.theme=void 0;break;case\"dark\":this.theme=\"dark\";break;default:this.theme=0<$tw.wiki.filterTiddlers(\"[{$:/palette}field:color-scheme[dark]]\").length?\"dark\":void 0}this.renderer=\"svg\"===this.getAttribute(\"$renderer\",\"canvas\")?\"svg\":\"canvas\",this.text=this.getAttribute(\"$text\",\"\").trim()||void 0,this.throttle=Math.max($tw.utils.getAnimationDuration()||100,100)}render(t,e){this.parentDomNode=t,this.execute(),this.containerDom=$tw.utils.domMaker(\"div\",{\"class\":this[\"class\"],document:this.document,style:{width:this.width,height:this.height}}),this.containerDom.id=this.uuid,t.insertBefore(this.containerDom,e),this.domNodes.push(this.containerDom);try{if(!(this.tiddlerTitle&&$tw.wiki.getTiddler(this.tiddlerTitle)||this.text))throw new Error(\"Widget need either $tiddler or $text attribute!\");var i=t.isTiddlyWikiFakeDom;this.rebuildInstance(i),this.initAddon(),this.renderAddon(),i?(Number.isSafeInteger(Number(this.width.replace(\"px\",\"\")))&&Number.isSafeInteger(Number(this.height.replace(\"px\",\"\")))||console.error(\"If you require SSR(server side render), you need to define $height and $width with format like '300px'\"),this.parentDomNode.innerHTML=this.echartsInstance.renderToSVGString()):echartWidgets.add(this)}catch(error){console.error(error),this.containerDom.innerText=String(error),this.containerDom.style.color=\"white\",this.containerDom.style.background=\"red\",this.containerDom.style.fontSize=\"12px\"}}refresh(s){return this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0;var t,e=this
"Modern.TiddlyDev#Origin": "widget.ts",
"module-type": "widget",
"type": "application/javascript"
}
]