1.31 财务分析,财务数据模块完善,产业链桑基图展示
This commit is contained in:
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/canvas.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/canvas.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../../../common/vendor.js"),t=require("./utils.js"),s={};class i{constructor(){this.__events={}}on(e,t){if(!e||!t)return;const s=this.__events[e]||[];s.push(t),this.__events[e]=s}emit(e,t){if(e.constructor===Object&&(e=(t=e)&&t.type),!e)return;const s=this.__events[e];s&&s.length&&s.forEach((e=>{e.call(this,t)}))}off(e,t){const s=this.__events,i=s[e];if(i&&i.length)if(t)for(let a=0,r=i.length;a<r;a++)i[a]===t&&(i.splice(a,1),a--);else delete s[e]}}class a{constructor(){this.currentSrc=null,this.naturalHeight=0,this.naturalWidth=0,this.width=0,this.height=0,this.tagName="IMG"}set src(t){this.currentSrc=t,e.index.getImageInfo({src:t,success:e=>{this.naturalWidth=this.width=e.width,this.naturalHeight=this.height=e.height,this.onload()},fail:()=>{this.onerror()}})}get src(){return this.currentSrc}}class r{constructor(e,t,s){this.tagName="canvas",this.com=t,this.canvasId=s,this.ctx=e}set width(e){this.com.offscreenWidth=e}set height(e){this.com.offscreenHeight=e}get width(){return this.com.offscreenWidth||0}get height(){return this.com.offscreenHeight||0}getContext(e){return this.ctx}getImageData(){return new Promise(((t,s)=>{this.com.$nextTick((()=>{e.index.canvasGetImageData({x:0,y:0,width:this.com.offscreenWidth,height:this.com.offscreenHeight,canvasId:this.canvasId,success:e=>{t(e)},fail:e=>{s(e)}},this.com)}))}))}}exports.Canvas=class{constructor(e,t,a,r={}){s[t.canvasId]={ctx:e},this.canvasId=t.canvasId,this.chart=null,this.isNew=a,this.tagName="canvas",this.canvasNode=r,this.com=t,a||this._initStyle(e),this._initEvent(),this._ee=new i}getContext(e){if("2d"===e)return this.ctx}setAttribute(e,t){"aria-label"===e&&(this.com.ariaLabel=t)}setChart(e){this.chart=e}createOffscreenCanvas(t){if(!this.children){this.com.isOffscreenCanvas=!0,this.com.offscreenWidth=t.width||300,this.com.offscreenHeight=t.height||300;const s=this.com,i=this.com.offscreenCanvasId,a=e.index.createCanvasContext(i,this.com);this._initStyle(a),this.children=new r(a,s,i)}return this.children}appendChild(e){console.log("child",e)}dispatchEvent(e,t){return"object"==typeof e?this._ee.emit(e.type,e):this._ee.emit(e,t),!0}attachEvent(){}detachEvent(){}addEventListener(e,t){this._ee.on(e,t)}removeEventListener(e,t){this._ee.off(e,t)}_initCanvas(e,t){}_initStyle(e,s){if(["fillStyle","strokeStyle","fontSize","globalAlpha","opacity","textAlign","textBaseline","shadow","lineWidth","lineCap","lineJoin","lineDash","miterLimit"].forEach((t=>{Object.defineProperty(e,t,{set:s=>{"opacity"!==t?("fillStyle"!==t&&"strokeStyle"!==t||"none"!==s&&null!==s)&&e["set"+t.charAt(0).toUpperCase()+t.slice(1)](s):e.setGlobalAlpha(s)}})})),this.isNew||s||(e.uniDrawImage=e.drawImage,e.drawImage=(...t)=>{t[0]=t[0].src,e.uniDrawImage(...t)}),e.createRadialGradient||(e.createRadialGradient=function(){return e.createCircularGradient(...[...arguments].slice(-3))}),e.strokeText||(e.strokeText=(...t)=>{e.fillText(...t)}),!e.measureText||"harmonyos"==t.getDeviceInfo().osName){e._measureText=e.measureText;const t=e=>{let t=0;for(let s=0;s<e.length;s++)e.charCodeAt(s)>0&&e.charCodeAt(s)<128?t++:t+=2;return t};e.measureText=(s,i)=>{var a;let r=(null==(a=null==e?void 0:e.state)?void 0:a.fontSize)||12;i&&(r=parseInt(i.match(/([\d\.]+)px/)[1])),r/=2;const n=r>=16?1.3:1;return{width:t(s)*r*n}}}}_initEvent(e){this.event={};[{wxName:"touchStart",ecName:"mousedown"},{wxName:"touchMove",ecName:"mousemove"},{wxName:"touchEnd",ecName:"mouseup"},{wxName:"touchEnd",ecName:"click"}].forEach((e=>{this.event[e.wxName]=t=>{const s=t.touches[0];this.chart.getZr().handler.dispatch(e.ecName,{zrX:"tap"===e.wxName?s.clientX:s.x,zrY:"tap"===e.wxName?s.clientY:s.y})}}))}set width(e){this.canvasNode.width=e}set height(e){this.canvasNode.height=e}get width(){return this.canvasNode.width||0}get height(){return this.canvasNode.height||0}get ctx(){return s[this.canvasId].ctx||null}set chart(e){s[this.canvasId].chart=e}get chart(){return s[this.canvasId].chart||null}},exports.dispatch=function(e,{x:t,y:s,wheelDelta:i}){this.dispatch(e,{zrX:t,zrY:s,zrDelta:i,preventDefault:()=>{},stopPropagation:()=>{}})},exports.setCanvasCreator=function(t,{canvas:s,node:i}){if(t&&!t.registerPreprocessor)return console.warn("echarts 版本不对或未传入echarts,vue3请使用esm格式");t.registerPreprocessor((e=>{e&&e.series&&(e.series.length>0?e.series.forEach((e=>{e.progressive=0})):"object"==typeof e.series&&(e.series.progressive=0))})),t.setPlatformAPI?t.setPlatformAPI({loadImage:s.setChart?function(e,t,s){let r=null;return i&&i.createImage?(r=i.createImage(),r.onload=t.bind(r),r.onerror=s.bind(r),r.src=e,r):(r=new a,r.onload=t.bind(r),r.onerror=s.bind(r),r.src=e,r)}:null,createCanvas(){const t="createOffscreenCanvas";return e.index.canIUse(t)&&e.index[t]?e.index[t]({type:"2d"}):s}}):t.setCanvasCreator&&t.setCanvasCreator((()=>s))};
|
||||
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/l-echart.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/l-echart.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/l-echart.json
vendored
Normal file
4
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/l-echart.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/l-echart.wxml
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/l-echart.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view wx:if="{{a}}" class="lime-echart" style="{{C}}" ref="limeEchart" aria-label="{{D}}"><canvas wx:if="{{b}}" class="lime-echart__canvas" type="2d" id="{{c}}" style="{{d}}" disable-scroll="{{e}}" bindtouchstart="{{f}}" bindtouchmove="{{g}}" bindtouchend="{{h}}"/><block wx:else><canvas wx:if="{{r0}}" class="lime-echart__canvas" width="{{i}}" height="{{j}}" style="{{k}}" canvas-id="{{l}}" id="{{m}}" disable-scroll="{{n}}" bindtouchstart="{{o}}" bindtouchmove="{{p}}" bindtouchend="{{q}}"/></block><view wx:if="{{r}}" class="lime-echart__mask" bindmousedown="{{s}}" bindmousemove="{{t}}" bindmouseup="{{v}}" bindtouchstart="{{w}}" bindtouchmove="{{x}}" bindtouchend="{{y}}"></view><canvas wx:if="{{z}}" style="{{A}}" canvas-id="{{B}}"></canvas></view>
|
||||
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/l-echart.wxss
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/l-echart.wxss
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.lime-echart{position:relative;width:100%;height:100%}.lime-echart__canvas{width:100%;height:100%}.lime-echart__mask{position:absolute;width:100%;height:100%;left:0;top:0;z-index:1}
|
||||
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/utils.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/components/l-echart/utils.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../../../common/vendor.js");function n(){return e.index.getDeviceInfo||e.index.canIUse("getDeviceInfo")?e.index.getDeviceInfo():e.index.getSystemInfoSync()}function t(t){const{platform:o}=n();let{SDKVersion:r}=e.index.getAppBaseInfo||e.index.canIUse("getAppBaseInfo")?e.index.getAppBaseInfo():e.index.getSystemInfoSync();return"mac"!==o&&function(e,n){e=e.split("."),n=n.split(".");const t=Math.max(e.length,n.length);for(;e.length<t;)e.push("0");for(;n.length<t;)n.push("0");for(let o=0;o<t;o++){const t=parseInt(e[o],10),r=parseInt(n[o],10);if(t>r)return 1;if(t<r)return-1}return 0}(r,t)>=0}function o(e){return Array.isArray(e)?e:"object"==typeof e&&null!==e?Object.values(e):e}const r=(e.index.getWindowInfo||e.index.canIUse("getWindowInfo")?e.index.getWindowInfo():e.index.getSystemInfoSync()).pixelRatio;exports.canIUseCanvas2d=function(){return t("2.9.0")},exports.convertTouchesToArray=o,exports.devicePixelRatio=r,exports.getDeviceInfo=n,exports.getRect=function(n,t,o){return new Promise(((r,s)=>{const i=e.index.createSelectorQuery().in(t).select(n),c=e=>{e?r(e):s()};o?i.fields({node:!0,size:!0,rect:!0},c).exec():i.boundingClientRect(c).exec()}))},exports.sleep=function(e){return new Promise((n=>{setTimeout((()=>{n(!0)}),e)}))},exports.wrapTouch=function(e){e.touches=o(e.touches);for(let n=0;n<e.touches.length;++n){const t=e.touches[n];t.offsetX=t.x,t.offsetY=t.y}return e};
|
||||
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/ecStat.min.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/ecStat.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/echarts.min.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/echarts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
129
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/index.html
vendored
Normal file
129
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/index.html
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title></title>
|
||||
<style type="text/css">
|
||||
html,
|
||||
body,
|
||||
.canvas {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
overflow-y: hidden;
|
||||
background-color: transparent;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="canvas" id="limeChart"></div>
|
||||
<script type="text/javascript" src="./uni.webview.1.5.3.js"></script>
|
||||
<script type="text/javascript" src="./echarts.min.js"></script>
|
||||
<script type="text/javascript" src="./ecStat.min.js"></script>
|
||||
<!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-liquidfill@latest/dist/echarts-liquidfill.min.js"></script> -->
|
||||
<script>
|
||||
let chart = null;
|
||||
let cache = [];
|
||||
console.log = function(...agrs) {
|
||||
postMessage(agrs)
|
||||
}
|
||||
function emit(event, data) {
|
||||
let dataStr = JSON.stringify(data, stringify)
|
||||
postMessage({
|
||||
event,
|
||||
data: dataStr
|
||||
})
|
||||
cache = []
|
||||
}
|
||||
function postMessage(data) {
|
||||
uni.postMessage({
|
||||
data
|
||||
});
|
||||
}
|
||||
function stringify(key, value) {
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
if (cache.indexOf(value) !== -1) {
|
||||
return;
|
||||
}
|
||||
cache.push(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function parse(name, callback, options) {
|
||||
const optionNameReg = /[\w]+\.setOption\(([\w]+\.)?([\w]+)\)/
|
||||
if (optionNameReg.test(callback)) {
|
||||
const optionNames = callback.match(optionNameReg)
|
||||
if(optionNames[1]) {
|
||||
const _this = optionNames[1].split('.')[0]
|
||||
window[_this] = {}
|
||||
window[_this][optionNames[2]] = options
|
||||
return optionNames[2]
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
function init(callback, options, opts = {}, theme = null) {
|
||||
if(!chart) {
|
||||
chart = echarts.init(document.getElementById('limeChart'), theme, opts)
|
||||
if(options) {
|
||||
chart.setOption(options)
|
||||
}
|
||||
// const name = parse('a', callback, options)
|
||||
// console.log('options::', callback)
|
||||
// if(name) this[name] = options
|
||||
// eval(`a = ${callback};`)
|
||||
// if(a) {a(chart)}
|
||||
}
|
||||
}
|
||||
|
||||
function setChart(callback, options) {
|
||||
if(!callback) return
|
||||
if(chart && callback && options) {
|
||||
var r = null
|
||||
const name = parse('r', callback, options)
|
||||
if(name) this[name] = options
|
||||
eval(`r = ${callback};`)
|
||||
if(r) {r(chart)}
|
||||
}
|
||||
}
|
||||
function setOption(data) {
|
||||
if (chart) chart.setOption(data[0], data[1])
|
||||
}
|
||||
function showLoading(data) {
|
||||
if (chart) chart.showLoading(data[0], data[1])
|
||||
}
|
||||
|
||||
function hideLoading() {
|
||||
if (chart) chart.hideLoading()
|
||||
}
|
||||
|
||||
function clear() {
|
||||
if (chart) chart.clear()
|
||||
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
if (chart) chart.dispose()
|
||||
}
|
||||
function resize(size) {
|
||||
if (chart) chart.resize(size)
|
||||
}
|
||||
|
||||
function canvasToTempFilePath(opt = {}) {
|
||||
if (chart) {
|
||||
const src = chart.getDataURL(opt)
|
||||
postMessage({
|
||||
file: true,
|
||||
data: src
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
177
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/nvue.html
vendored
Normal file
177
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/nvue.html
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title></title>
|
||||
<style type="text/css">
|
||||
html,
|
||||
body,
|
||||
.canvas {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
overflow-y: hidden;
|
||||
background-color: transparent;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="canvas" id="limeChart"></div>
|
||||
<script type="text/javascript" src="./uni.webview.1.5.3.js"></script>
|
||||
<script type="text/javascript" src="./echarts.min.js"></script>
|
||||
<script type="text/javascript" src="./ecStat.min.js"></script>
|
||||
<!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-liquidfill@latest/dist/echarts-liquidfill.min.js"></script> -->
|
||||
<script>
|
||||
let chart = null;
|
||||
let cache = [];
|
||||
console.log = function(...agrs) {
|
||||
postMessage(agrs)
|
||||
}
|
||||
|
||||
function emit(event, data) {
|
||||
let dataStr = JSON.stringify(data, stringify)
|
||||
postMessage({
|
||||
event,
|
||||
data: dataStr
|
||||
})
|
||||
cache = []
|
||||
}
|
||||
|
||||
function postMessage(data) {
|
||||
uni.postMessage({
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
function stringify(key, value) {
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
if (cache.indexOf(value) !== -1) {
|
||||
return;
|
||||
}
|
||||
cache.push(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function parse(name, callback, options) {
|
||||
const optionNameReg = /[\w]+\.setOption\(([\w]+\.)?([\w]+)\)/
|
||||
if (optionNameReg.test(callback)) {
|
||||
const optionNames = callback.match(optionNameReg)
|
||||
if (optionNames[1]) {
|
||||
const _this = optionNames[1].split('.')[0]
|
||||
window[_this] = {}
|
||||
window[_this][optionNames[2]] = options
|
||||
return optionNames[2]
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function init(callback, options, opts = {}, theme = null) {
|
||||
if (!chart) {
|
||||
chart = echarts.init(document.getElementById('limeChart'), theme, opts)
|
||||
if (options) {
|
||||
chart.setOption(options)
|
||||
}
|
||||
// const name = parse('a', callback, options)
|
||||
// console.log('options::', callback)
|
||||
// if(name) this[name] = options
|
||||
// eval(`a = ${callback};`)
|
||||
// if(a) {a(chart)}
|
||||
}
|
||||
}
|
||||
|
||||
function setChart(callback, options) {
|
||||
if (!callback) return
|
||||
if (chart && callback && options) {
|
||||
var r = null
|
||||
const name = parse('r', callback, options)
|
||||
if (name) this[name] = options
|
||||
eval(`r = ${callback};`)
|
||||
if (r) {
|
||||
r(chart)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setOption(data) {
|
||||
if (chart) chart.setOption(data[0], data[1])
|
||||
}
|
||||
|
||||
function showLoading(data) {
|
||||
if (chart) chart.showLoading(data[0], data[1])
|
||||
}
|
||||
|
||||
function hideLoading() {
|
||||
if (chart) chart.hideLoading()
|
||||
}
|
||||
|
||||
function clear() {
|
||||
if (chart) chart.clear()
|
||||
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
if (chart) chart.dispose()
|
||||
}
|
||||
|
||||
function resize(size) {
|
||||
if (chart) chart.resize(size)
|
||||
}
|
||||
|
||||
function canvasToTempFilePath(opt = {}) {
|
||||
if (chart) {
|
||||
const src = chart.getDataURL(opt)
|
||||
postMessage({
|
||||
file: true,
|
||||
data: src
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function on(data) {
|
||||
if (chart && data.length > 0) {
|
||||
const [type, query] = data
|
||||
const useQuery = query && typeof query != 'function'
|
||||
const key = `${type}${useQuery ? JSON.stringify(query): '' }`
|
||||
if (query) {
|
||||
chart.on(type, query, (options) => {
|
||||
const obj = {}
|
||||
Object.keys(options).forEach(key => {
|
||||
if (key != 'event') {
|
||||
obj[key] = options[key]
|
||||
}
|
||||
})
|
||||
emit(`@${key}`, {
|
||||
event: key,
|
||||
options: obj
|
||||
})
|
||||
})
|
||||
} else {
|
||||
chart.on(type, (options) => {
|
||||
|
||||
const obj = {}
|
||||
Object.keys(options).forEach(key => {
|
||||
if (key != 'event') {
|
||||
obj[key] = options[key]
|
||||
}
|
||||
|
||||
})
|
||||
emit(`@${key}`, {
|
||||
event: key,
|
||||
options: obj
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/uni.webview.1.5.3.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/uni.webview.1.5.3.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/uni.webview.1.5.5.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/uni.webview.1.5.5.js
vendored
Normal file
File diff suppressed because one or more lines are too long
184
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/uvue.html
vendored
Normal file
184
unpackage/dist/build/mp-weixin/uni_modules/lime-echart/static/uvue.html
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title></title>
|
||||
<style type="text/css">
|
||||
html,
|
||||
body {
|
||||
overflow: hidden;
|
||||
/* 隐藏滚动条 */
|
||||
overscroll-behavior: none;
|
||||
/* 禁止橡皮筋效果 */
|
||||
}
|
||||
html,
|
||||
body,
|
||||
.canvas {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
overflow-y: hidden;
|
||||
background-color: transparent;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="canvas" id="limeChart"></div>
|
||||
<script type="text/javascript" src="./uni.webview.1.5.5.js"></script>
|
||||
<script type="text/javascript" src="./echarts.min.js"></script>
|
||||
<script type="text/javascript" src="./ecStat.min.js"></script>
|
||||
<!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-liquidfill@latest/dist/echarts-liquidfill.min.js"></script> -->
|
||||
<script>
|
||||
let chart = null;
|
||||
let cache = [];
|
||||
console.log = function() {
|
||||
emit('log', {
|
||||
log: arguments,
|
||||
})
|
||||
}
|
||||
|
||||
function emit(event, data) {
|
||||
postMessage({
|
||||
event,
|
||||
data
|
||||
})
|
||||
cache = []
|
||||
}
|
||||
|
||||
function postMessage(data) {
|
||||
uni.webView.postMessage({
|
||||
data
|
||||
})
|
||||
// window.__uniapp_x_.postMessage(JSON.stringify(data))
|
||||
};
|
||||
|
||||
function stringify(key, value) {
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
if (cache.indexOf(value) !== -1) {
|
||||
return;
|
||||
}
|
||||
cache.push(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function parse(name, callback, options) {
|
||||
const optionNameReg = /[\w]+\.setOption\(([\w]+\.)?([\w]+)\)/
|
||||
if (optionNameReg.test(callback)) {
|
||||
const optionNames = callback.match(optionNameReg)
|
||||
if (optionNames[1]) {
|
||||
const _this = optionNames[1].split('.')[0]
|
||||
window[_this] = {}
|
||||
window[_this][optionNames[2]] = options
|
||||
return optionNames[2]
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function init(callback, options, opts, theme) {
|
||||
if (!chart) {
|
||||
chart = echarts.init(document.getElementById('limeChart'), theme, opts)
|
||||
|
||||
if (options) {
|
||||
chart.setOption(options)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function on(data) {
|
||||
if (chart && data.length > 0) {
|
||||
const [type, query] = data
|
||||
const key = `${type}${JSON.stringify(query||'')}`
|
||||
if (query) {
|
||||
chart.on(type, query, function(options) {
|
||||
var obj = {};
|
||||
Object.keys(options).forEach(function(key) {
|
||||
if (key != 'event') {
|
||||
obj[key] = options[key];
|
||||
}
|
||||
});
|
||||
emit(key, {
|
||||
event: key,
|
||||
options: obj,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
chart.on(type, function(options) {
|
||||
var obj = {};
|
||||
Object.keys(options).forEach(function(key) {
|
||||
if (key != 'event') {
|
||||
obj[key] = options[key];
|
||||
}
|
||||
});
|
||||
emit(key, {
|
||||
event: key,
|
||||
options: obj,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function setChart(callback, options) {
|
||||
if (!callback) return
|
||||
if (chart && callback && options) {
|
||||
var r = null
|
||||
const name = parse('r', callback, options)
|
||||
if (name) this[name] = options
|
||||
eval(`r = ${callback};`)
|
||||
if (r) {
|
||||
r(chart)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setOption(data) {
|
||||
if (chart) chart.setOption(data[0], data[1])
|
||||
}
|
||||
|
||||
function showLoading(data) {
|
||||
if (chart) chart.showLoading(data[0], data[1])
|
||||
}
|
||||
|
||||
function hideLoading() {
|
||||
if (chart) chart.hideLoading()
|
||||
}
|
||||
|
||||
function clear() {
|
||||
if (chart) chart.clear()
|
||||
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
if (chart) chart.dispose()
|
||||
}
|
||||
|
||||
function resize(size) {
|
||||
if (chart) chart.resize(size)
|
||||
}
|
||||
|
||||
function canvasToTempFilePath(opt) {
|
||||
if (chart) {
|
||||
delete opt.success
|
||||
const src = chart.getDataURL(opt)
|
||||
postMessage({
|
||||
// event: 'file',
|
||||
file: src
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('touchmove', () => {
|
||||
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user