@ecan-bi/tools 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +6 -0
- package/lib/index.es.js +1 -0
- package/package.json +15 -27
- package/rollup.config.js +30 -0
- package/src/hooks/useTransformChartDataByAttrKey.ts +77 -0
- package/src/hooks/useTransformChartDataByAttrValue.ts +61 -0
- package/src/hooks/useValueFormatter.ts +27 -0
- package/src/hooks/useVariablesInText.ts +44 -0
- package/src/index.ts +22 -0
- package/src/indicator.ts +1215 -0
- package/src/utils/constant.ts +1 -0
- package/src/utils/runCode.ts +26 -0
- package/src/utils/transformProps.ts +901 -0
- package/src/utils/util.ts +195 -0
- package/tsconfig.json +38 -0
- package/dist/index.es.js +0 -1740
- package/dist/index.es.js.map +0 -1
- package/dist/index.umd.js +0 -6
- package/dist/index.umd.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MODEL_KEY_LIST = ['table', 'bar', 'combograph', 'line', 'pie', 'radar', 'scatter', 'list', 'circulate']
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import dayjs from 'dayjs'
|
|
2
|
+
const runCode = (code: string, data?: { [key:string]: any }) => {
|
|
3
|
+
const useFn = {
|
|
4
|
+
dayjs,
|
|
5
|
+
...data
|
|
6
|
+
}
|
|
7
|
+
let paramsStr = ''
|
|
8
|
+
const params: any = []
|
|
9
|
+
for (const key in useFn) {
|
|
10
|
+
paramsStr += `${key},`
|
|
11
|
+
params.push(useFn[key])
|
|
12
|
+
}
|
|
13
|
+
paramsStr = paramsStr.replace(/,$/, '')
|
|
14
|
+
const runFn = `function (${paramsStr}){return ${code}}`
|
|
15
|
+
let result
|
|
16
|
+
try {
|
|
17
|
+
// eslint-disable-next-line no-new-func
|
|
18
|
+
result = Function(`"use strict";return (${runFn})`)()(...params)
|
|
19
|
+
} catch (e) {
|
|
20
|
+
// console.error()
|
|
21
|
+
return code
|
|
22
|
+
}
|
|
23
|
+
return result
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default runCode
|