@orbcharts/core 3.0.0-beta.3 → 3.0.0-beta.4

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.
Files changed (77) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-core.es.js +2623 -2338
  3. package/dist/orbcharts-core.umd.js +4 -4
  4. package/dist/src/utils/d3Scale.d.ts +28 -0
  5. package/dist/src/utils/gridObservables.d.ts +29 -19
  6. package/dist/src/utils/index.d.ts +1 -1
  7. package/dist/src/utils/multiGridObservables.d.ts +2 -2
  8. package/dist/src/utils/multiValueObservables.d.ts +73 -0
  9. package/dist/src/utils/orbchartsUtils.d.ts +19 -5
  10. package/dist/src/utils/seriesObservables.d.ts +4 -4
  11. package/dist/src/utils/treeObservables.d.ts +2 -5
  12. package/lib/core-types.ts +7 -7
  13. package/package.json +42 -42
  14. package/src/AbstractChart.ts +57 -57
  15. package/src/GridChart.ts +24 -24
  16. package/src/MultiGridChart.ts +24 -24
  17. package/src/MultiValueChart.ts +24 -24
  18. package/src/RelationshipChart.ts +24 -24
  19. package/src/SeriesChart.ts +24 -24
  20. package/src/TreeChart.ts +24 -24
  21. package/src/base/createBaseChart.ts +505 -505
  22. package/src/base/createBasePlugin.ts +153 -153
  23. package/src/base/validators/chartOptionsValidator.ts +23 -23
  24. package/src/base/validators/chartParamsValidator.ts +133 -133
  25. package/src/base/validators/elementValidator.ts +13 -13
  26. package/src/base/validators/pluginsValidator.ts +14 -14
  27. package/src/defaults.ts +235 -232
  28. package/src/defineGridPlugin.ts +3 -3
  29. package/src/defineMultiGridPlugin.ts +3 -3
  30. package/src/defineMultiValuePlugin.ts +3 -3
  31. package/src/defineNoneDataPlugin.ts +4 -4
  32. package/src/defineRelationshipPlugin.ts +3 -3
  33. package/src/defineSeriesPlugin.ts +3 -3
  34. package/src/defineTreePlugin.ts +3 -3
  35. package/src/grid/computedDataFn.ts +129 -129
  36. package/src/grid/contextObserverCallback.ts +176 -155
  37. package/src/grid/dataFormatterValidator.ts +101 -101
  38. package/src/grid/dataValidator.ts +12 -12
  39. package/src/index.ts +20 -20
  40. package/src/multiGrid/computedDataFn.ts +123 -123
  41. package/src/multiGrid/contextObserverCallback.ts +41 -41
  42. package/src/multiGrid/dataFormatterValidator.ts +115 -115
  43. package/src/multiGrid/dataValidator.ts +12 -12
  44. package/src/multiValue/computedDataFn.ts +110 -176
  45. package/src/multiValue/contextObserverCallback.ts +160 -12
  46. package/src/multiValue/dataFormatterValidator.ts +9 -9
  47. package/src/multiValue/dataValidator.ts +9 -9
  48. package/src/relationship/computedDataFn.ts +125 -125
  49. package/src/relationship/contextObserverCallback.ts +12 -12
  50. package/src/relationship/dataFormatterValidator.ts +9 -9
  51. package/src/relationship/dataValidator.ts +9 -9
  52. package/src/series/computedDataFn.ts +88 -88
  53. package/src/series/contextObserverCallback.ts +100 -100
  54. package/src/series/dataFormatterValidator.ts +41 -41
  55. package/src/series/dataValidator.ts +12 -12
  56. package/src/tree/computedDataFn.ts +129 -130
  57. package/src/tree/contextObserverCallback.ts +58 -61
  58. package/src/tree/dataFormatterValidator.ts +13 -13
  59. package/src/tree/dataValidator.ts +13 -13
  60. package/src/utils/commonUtils.ts +55 -55
  61. package/src/utils/d3Scale.ts +198 -0
  62. package/src/utils/errorMessage.ts +42 -42
  63. package/src/utils/gridObservables.ts +671 -614
  64. package/src/utils/index.ts +9 -9
  65. package/src/utils/multiGridObservables.ts +392 -366
  66. package/src/utils/multiValueObservables.ts +643 -0
  67. package/src/utils/observables.ts +219 -219
  68. package/src/utils/orbchartsUtils.ts +377 -352
  69. package/src/utils/seriesObservables.ts +175 -175
  70. package/src/utils/treeObservables.ts +105 -94
  71. package/src/utils/validator.ts +126 -125
  72. package/tsconfig.base.json +13 -13
  73. package/tsconfig.json +2 -2
  74. package/vite-env.d.ts +6 -6
  75. package/vite.config.js +22 -22
  76. package/dist/src/utils/d3Utils.d.ts +0 -19
  77. package/src/utils/d3Utils.ts +0 -108
@@ -1,130 +1,129 @@
1
- import type { DataTree, DataTreeObj, DataTreeDatum, ComputedDataFn, ComputedDataTree } from '../../lib/core-types'
2
- import { isPlainObject } from '../utils/commonUtils'
3
- import { seriesColorPredicate } from '../utils/orbchartsUtils'
4
-
5
- export const computedDataFn: ComputedDataFn<'tree'> = (context) => {
6
- const { data = [], dataFormatter, chartParams } = context
7
-
8
- // <categoryLabel, categoryIndex>
9
- const CategoryIndexMap = new Map<string, number>(
10
- dataFormatter.categoryLabels.map((label, index) => [label, index])
11
- )
12
-
13
- let computedBranchData: ComputedDataTree = {
14
- id: '',
15
- index: 0,
16
- label: '',
17
- description: '',
18
- categoryIndex: 0,
19
- categoryLabel: '',
20
- color: '',
21
- visible: true,
22
- // tooltipContent: '',
23
- data: {},
24
- value: 0,
25
- level: 0,
26
- seq: 0,
27
- children: []
28
- }
29
-
30
- try {
31
- // 建立樹狀結構資料
32
- const dataTreeObj: DataTreeObj = (function () {
33
- if (isPlainObject(data) === true) {
34
- // 原本就是樹狀結構則直接複製
35
- // return structuredClone(data) as DataTreeObj
36
- return JSON.parse(JSON.stringify(data)) as DataTreeObj
37
- } else if (Array.isArray(data) === false) {
38
- return {
39
- id: ''
40
- }
41
- }
42
- // -- 陣列格式轉物件 --
43
- // let rootId = ''
44
- let root: DataTreeDatum | undefined = undefined
45
- // const DataMap: Map<string, DataTreeDatum> = new Map()
46
- const ChildrenMap: Map<string, DataTreeDatum[]> = new Map()
47
- ;(data as DataTreeDatum[]).forEach(d => {
48
- // DataMap.set(d.id, d)
49
-
50
- if (!d.parent) {
51
- // rootId = d.id
52
- root = d
53
- } else {
54
- const children: DataTreeDatum[] = ChildrenMap.get(d.parent) ?? []
55
- children.push(d)
56
- ChildrenMap.set(d.parent!, children)
57
- }
58
- })
59
-
60
- const createBranchData = (root: DataTreeDatum): DataTreeObj => {
61
- return {
62
- id: root.id,
63
- label: root.label,
64
- data: root.data,
65
- // tooltipContent: root.tooltipContent,
66
- value: root.value,
67
- categoryLabel: root.categoryLabel,
68
- children: (ChildrenMap.get(root.id) ?? []).map(d => {
69
- // 遞迴
70
- return createBranchData(d)
71
- })
72
- }
73
- }
74
- if (root) {
75
- return createBranchData(root)
76
- } else {
77
- return {
78
- id: ''
79
- }
80
- }
81
- })()
82
-
83
- let index = 0
84
-
85
- const formatBranchData = (branch: DataTreeObj, level: number, seq: number): ComputedDataTree => {
86
- const childLayer = level + 1
87
- const categoryLabel: string | null = branch.categoryLabel ?? null
88
- let categoryIndex = 0
89
- if (categoryLabel != null) {
90
- if (!CategoryIndexMap.has(categoryLabel)) {
91
- CategoryIndexMap.set(categoryLabel, CategoryIndexMap.size)
92
- }
93
- categoryIndex = CategoryIndexMap.get(categoryLabel) ?? 0
94
- }
95
-
96
- const currentIndex = index
97
- index++
98
- const formattedBranchData: ComputedDataTree = {
99
- id: branch.id,
100
- index: currentIndex,
101
- level,
102
- seq,
103
- label: branch.label ?? '',
104
- description: branch.description ?? '',
105
- categoryIndex,
106
- categoryLabel,
107
- color: seriesColorPredicate(categoryIndex, chartParams),
108
- data: branch.data ?? {},
109
- // tooltipContent: branch.tooltipContent ? branch.tooltipContent : dataFormatter.tooltipContentFormat(branch, level, seq, context),
110
- value: branch.value,
111
- visible: true, // 先給預設值
112
- children: (branch.children ?? []).map((d, i) => {
113
- // 遞迴
114
- return formatBranchData(d, childLayer, i)
115
- })
116
- }
117
-
118
- formattedBranchData.visible = dataFormatter.visibleFilter(formattedBranchData, context)
119
-
120
- return formattedBranchData
121
- }
122
- computedBranchData = formatBranchData(dataTreeObj, 0, 0)
123
- } catch (e) {
124
- // console.error(e)
125
- throw Error(e)
126
- }
127
-
128
- return computedBranchData
129
-
130
- }
1
+ import type { DataTree, DataTreeObj, DataTreeDatum, ComputedDataFn, ComputedDataTree } from '../../lib/core-types'
2
+ import { isPlainObject } from '../utils/commonUtils'
3
+ import { seriesColorPredicate, createDefaultCategoryLabel } from '../utils/orbchartsUtils'
4
+
5
+ export const computedDataFn: ComputedDataFn<'tree'> = (context) => {
6
+ const { data = [], dataFormatter, chartParams } = context
7
+
8
+ const defaultCategoryLabel = createDefaultCategoryLabel()
9
+
10
+ // <categoryLabel, categoryIndex>
11
+ const CategoryIndexMap = new Map<string, number>(
12
+ dataFormatter.categoryLabels.map((label, index) => [label, index])
13
+ )
14
+
15
+ let computedBranchData: ComputedDataTree = {
16
+ id: '',
17
+ index: 0,
18
+ label: '',
19
+ description: '',
20
+ categoryIndex: -1,
21
+ categoryLabel: '',
22
+ color: '',
23
+ visible: true,
24
+ // tooltipContent: '',
25
+ data: {},
26
+ value: 0,
27
+ level: 0,
28
+ seq: 0,
29
+ children: []
30
+ }
31
+
32
+ try {
33
+ // 建立樹狀結構資料
34
+ const dataTreeObj: DataTreeObj = (function () {
35
+ if (isPlainObject(data) === true) {
36
+ // 原本就是樹狀結構則直接複製
37
+ // return structuredClone(data) as DataTreeObj
38
+ return JSON.parse(JSON.stringify(data)) as DataTreeObj
39
+ } else if (Array.isArray(data) === false) {
40
+ return {
41
+ id: ''
42
+ }
43
+ }
44
+ // -- 陣列格式轉物件 --
45
+ // let rootId = ''
46
+ let root: DataTreeDatum | undefined = undefined
47
+ // const DataMap: Map<string, DataTreeDatum> = new Map()
48
+ const ChildrenMap: Map<string, DataTreeDatum[]> = new Map()
49
+ ;(data as DataTreeDatum[]).forEach(d => {
50
+ // DataMap.set(d.id, d)
51
+
52
+ if (!d.parent) {
53
+ // rootId = d.id
54
+ root = d
55
+ } else {
56
+ const children: DataTreeDatum[] = ChildrenMap.get(d.parent) ?? []
57
+ children.push(d)
58
+ ChildrenMap.set(d.parent!, children)
59
+ }
60
+ })
61
+
62
+ const createBranchData = (root: DataTreeDatum): DataTreeObj => {
63
+ return {
64
+ id: root.id,
65
+ label: root.label,
66
+ data: root.data,
67
+ // tooltipContent: root.tooltipContent,
68
+ value: root.value,
69
+ categoryLabel: root.categoryLabel ?? defaultCategoryLabel,
70
+ children: (ChildrenMap.get(root.id) ?? []).map(d => {
71
+ // 遞迴
72
+ return createBranchData(d)
73
+ })
74
+ }
75
+ }
76
+ if (root) {
77
+ return createBranchData(root)
78
+ } else {
79
+ return {
80
+ id: ''
81
+ }
82
+ }
83
+ })()
84
+
85
+ let index = 0
86
+
87
+ const formatBranchData = (branch: DataTreeObj, level: number, seq: number): ComputedDataTree => {
88
+ const childLayer = level + 1
89
+ const categoryLabel: string = branch.categoryLabel ?? defaultCategoryLabel
90
+ if (!CategoryIndexMap.has(categoryLabel)) {
91
+ CategoryIndexMap.set(categoryLabel, CategoryIndexMap.size)
92
+ }
93
+ const categoryIndex = CategoryIndexMap.get(categoryLabel) ?? 0
94
+
95
+ const currentIndex = index
96
+ index++
97
+ const formattedBranchData: ComputedDataTree = {
98
+ id: branch.id,
99
+ index: currentIndex,
100
+ level,
101
+ seq,
102
+ label: branch.label ?? '',
103
+ description: branch.description ?? '',
104
+ categoryIndex,
105
+ categoryLabel,
106
+ color: seriesColorPredicate(categoryIndex, chartParams),
107
+ data: branch.data ?? {},
108
+ // tooltipContent: branch.tooltipContent ? branch.tooltipContent : dataFormatter.tooltipContentFormat(branch, level, seq, context),
109
+ value: branch.value,
110
+ visible: true, // 先給預設值
111
+ children: (branch.children ?? []).map((d, i) => {
112
+ // 遞迴
113
+ return formatBranchData(d, childLayer, i)
114
+ })
115
+ }
116
+
117
+ formattedBranchData.visible = dataFormatter.visibleFilter(formattedBranchData, context)
118
+
119
+ return formattedBranchData
120
+ }
121
+ computedBranchData = formatBranchData(dataTreeObj, 0, 0)
122
+ } catch (e) {
123
+ // console.error(e)
124
+ throw Error(e)
125
+ }
126
+
127
+ return computedBranchData
128
+
129
+ }
@@ -1,61 +1,58 @@
1
- import { map, shareReplay } from 'rxjs'
2
- import type { ContextObserverCallback } from '../../lib/core-types'
3
- import { highlightObservable, categoryDataMapObservable, textSizePxObservable } from '../utils/observables'
4
- import {
5
- nodeListObservable,
6
- existCategoryLabelsObservable,
7
- treeVisibleComputedDataObservable
8
- } from '../utils/treeObservables'
9
-
10
- export const contextObserverCallback: ContextObserverCallback<'tree'> = ({ subject, observer }) => {
11
-
12
- const textSizePx$ = textSizePxObservable(observer.fullChartParams$).pipe(
13
- shareReplay(1)
14
- )
15
-
16
- const nodeList$ = nodeListObservable({
17
- computedData$: observer.computedData$
18
- }).pipe(
19
- shareReplay(1)
20
- )
21
-
22
- const treeHighlight$ = highlightObservable({
23
- datumList$: nodeList$,
24
- fullChartParams$: observer.fullChartParams$,
25
- event$: subject.event$
26
- }).pipe(
27
- shareReplay(1)
28
- )
29
-
30
- const existCategoryLabels$ = existCategoryLabelsObservable({
31
- nodeList$,
32
- fullDataFormatter$: observer.fullDataFormatter$
33
- }).pipe(
34
- shareReplay(1)
35
- )
36
-
37
- const CategoryDataMap$ = categoryDataMapObservable({
38
- datumList$: nodeList$
39
- }).pipe(
40
- shareReplay(1)
41
- )
42
-
43
- const visibleComputedData$ = treeVisibleComputedDataObservable({
44
- computedData$: observer.computedData$
45
- }).pipe(
46
- shareReplay(1)
47
- )
48
-
49
- return {
50
- fullParams$: observer.fullParams$,
51
- fullChartParams$: observer.fullChartParams$,
52
- fullDataFormatter$: observer.fullDataFormatter$,
53
- computedData$: observer.computedData$,
54
- layout$: observer.layout$,
55
- textSizePx$,
56
- treeHighlight$,
57
- existCategoryLabels$,
58
- CategoryDataMap$,
59
- visibleComputedData$
60
- }
61
- }
1
+ import { map, shareReplay } from 'rxjs'
2
+ import type { ContextObserverCallback } from '../../lib/core-types'
3
+ import { highlightObservable, categoryDataMapObservable, textSizePxObservable } from '../utils/observables'
4
+ import {
5
+ nodeListObservable,
6
+ categoryLabelsObservable,
7
+ treeVisibleComputedDataObservable
8
+ } from '../utils/treeObservables'
9
+
10
+ export const contextObserverCallback: ContextObserverCallback<'tree'> = ({ subject, observer }) => {
11
+
12
+ const textSizePx$ = textSizePxObservable(observer.fullChartParams$).pipe(
13
+ shareReplay(1)
14
+ )
15
+
16
+ const nodeList$ = nodeListObservable({
17
+ computedData$: observer.computedData$
18
+ }).pipe(
19
+ shareReplay(1)
20
+ )
21
+
22
+ const treeHighlight$ = highlightObservable({
23
+ datumList$: nodeList$,
24
+ fullChartParams$: observer.fullChartParams$,
25
+ event$: subject.event$
26
+ }).pipe(
27
+ shareReplay(1)
28
+ )
29
+
30
+ const CategoryDataMap$ = categoryDataMapObservable({
31
+ datumList$: nodeList$
32
+ }).pipe(
33
+ shareReplay(1)
34
+ )
35
+
36
+ const categoryLabels$ = categoryLabelsObservable(CategoryDataMap$).pipe(
37
+ shareReplay(1)
38
+ )
39
+
40
+ const visibleComputedData$ = treeVisibleComputedDataObservable({
41
+ computedData$: observer.computedData$
42
+ }).pipe(
43
+ shareReplay(1)
44
+ )
45
+
46
+ return {
47
+ fullParams$: observer.fullParams$,
48
+ fullChartParams$: observer.fullChartParams$,
49
+ fullDataFormatter$: observer.fullDataFormatter$,
50
+ computedData$: observer.computedData$,
51
+ layout$: observer.layout$,
52
+ textSizePx$,
53
+ treeHighlight$,
54
+ categoryLabels$,
55
+ CategoryDataMap$,
56
+ visibleComputedData$
57
+ }
58
+ }
@@ -1,14 +1,14 @@
1
- import type { DataFormatterValidator, DataFormatterTypeMap } from '../../lib/core-types'
2
- import { validateColumns } from '../utils/validator'
3
-
4
- export const dataFormatterValidator: DataFormatterValidator<'tree'> = (dataFormatter: DataFormatterTypeMap<'tree'>) => {
5
- const result = validateColumns(dataFormatter, {
6
- visibleFilter: {
7
- toBeTypes: ['Function']
8
- },
9
- categoryLabels: {
10
- toBeTypes: ['string[]']
11
- }
12
- })
13
- return result
1
+ import type { DataFormatterValidator, DataFormatterTypeMap } from '../../lib/core-types'
2
+ import { validateColumns } from '../utils/validator'
3
+
4
+ export const dataFormatterValidator: DataFormatterValidator<'tree'> = (dataFormatter: DataFormatterTypeMap<'tree'>) => {
5
+ const result = validateColumns(dataFormatter, {
6
+ visibleFilter: {
7
+ toBeTypes: ['Function']
8
+ },
9
+ categoryLabels: {
10
+ toBeTypes: ['string[]']
11
+ }
12
+ })
13
+ return result
14
14
  }
@@ -1,14 +1,14 @@
1
- import type { DataValidator, DataTypeMap } from '../../lib/core-types'
2
- import { validateColumns } from '../utils/validator'
3
- import { isPlainObject } from '../utils'
4
-
5
- export const dataValidator: DataValidator<'tree'> = (data: DataTypeMap<'tree'>) => {
6
- const result = validateColumns({ data }, {
7
- data: {
8
- toBe: 'DataTreeObj | DataTreeDatum[]',
9
- // 畢免資料量過大檢查不完,不深度檢查
10
- test: (value) => isPlainObject(value) && value.id !== undefined
11
- }
12
- })
13
- return result
1
+ import type { DataValidator, DataTypeMap } from '../../lib/core-types'
2
+ import { validateColumns } from '../utils/validator'
3
+ import { isPlainObject } from '../utils'
4
+
5
+ export const dataValidator: DataValidator<'tree'> = (data: DataTypeMap<'tree'>) => {
6
+ const result = validateColumns({ data }, {
7
+ data: {
8
+ toBe: 'DataTreeObj | DataTreeDatum[]',
9
+ // 畢免資料量過大檢查不完,不深度檢查
10
+ test: (value) => isPlainObject(value) && value.id !== undefined
11
+ }
12
+ })
13
+ return result
14
14
  }
@@ -1,55 +1,55 @@
1
-
2
- // 是否為原始物件
3
- export function isPlainObject(variable: any) {
4
- return Object.prototype.toString.call(variable) === "[object Object]";
5
- }
6
-
7
- // 是否為function
8
- export function isFunction(fn: any) {
9
- // return !!fn && !fn.nodename && fn.constructor != String && fn.constructor != RegExp && fn.constructor != Array && /function/i.test(fn + "");
10
- return Object.prototype.toString.call(fn) === '[object Function]'
11
- }
12
-
13
- // 是否為dom
14
- export function isDom(obj: any) {
15
- return !!(obj && obj.nodeType);
16
- }
17
-
18
- // 將可選的參數和預設值合併
19
- export function mergeOptionsWithDefault<Options extends { [key: string]: any; }> (options: {[key: string]: any}, defaultOptions: Options): Options {
20
- if (isPlainObject(options) === false || isPlainObject(defaultOptions) === false) {
21
- return Object.assign({}, defaultOptions)
22
- }
23
- const mergeObjColumns = (_options: {[key: string]: any}, _defaultOptions: {[key: string]: any}) => {
24
- const obj: Options = (Object.assign({}, _defaultOptions) as any)
25
- for (let key of Object.keys(_options)) {
26
- if ((key in _defaultOptions) == false) {
27
- continue
28
- }
29
- let objValue: any = undefined
30
- // 下一層的plain object
31
- if (isPlainObject(_options[key]) && isPlainObject(_defaultOptions[key])) {
32
- objValue = mergeObjColumns(_options[key], _defaultOptions[key])
33
- obj[key as keyof Options] = objValue
34
- }
35
- // 不是plain object直接賦值
36
- else {
37
- obj[key as keyof Options] = _options[key]
38
- }
39
- }
40
- return obj
41
- }
42
-
43
- return mergeObjColumns(options, defaultOptions)
44
- }
45
-
46
- // 加上千分位 ,
47
- export function formatCommaNumber (num = 0): string {
48
- try {
49
- let parts = num.toString().split('.');
50
- parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
51
- return parts.join('.');
52
- } catch (e: any) {
53
- console.error(e)
54
- }
55
- }
1
+
2
+ // 是否為原始物件
3
+ export function isPlainObject(variable: any) {
4
+ return Object.prototype.toString.call(variable) === "[object Object]";
5
+ }
6
+
7
+ // 是否為function
8
+ export function isFunction(fn: any) {
9
+ // return !!fn && !fn.nodename && fn.constructor != String && fn.constructor != RegExp && fn.constructor != Array && /function/i.test(fn + "");
10
+ return Object.prototype.toString.call(fn) === '[object Function]'
11
+ }
12
+
13
+ // 是否為dom
14
+ export function isDom(obj: any) {
15
+ return !!(obj && obj.nodeType);
16
+ }
17
+
18
+ // 將可選的參數和預設值合併
19
+ export function mergeOptionsWithDefault<Options extends { [key: string]: any; }> (options: {[key: string]: any}, defaultOptions: Options): Options {
20
+ if (isPlainObject(options) === false || isPlainObject(defaultOptions) === false) {
21
+ return Object.assign({}, defaultOptions)
22
+ }
23
+ const mergeObjColumns = (_options: {[key: string]: any}, _defaultOptions: {[key: string]: any}) => {
24
+ const obj: Options = (Object.assign({}, _defaultOptions) as any)
25
+ for (let key of Object.keys(_options)) {
26
+ if ((key in _defaultOptions) == false) {
27
+ continue
28
+ }
29
+ let objValue: any = undefined
30
+ // 下一層的plain object
31
+ if (isPlainObject(_options[key]) && isPlainObject(_defaultOptions[key])) {
32
+ objValue = mergeObjColumns(_options[key], _defaultOptions[key])
33
+ obj[key as keyof Options] = objValue
34
+ }
35
+ // 不是plain object直接賦值
36
+ else {
37
+ obj[key as keyof Options] = _options[key]
38
+ }
39
+ }
40
+ return obj
41
+ }
42
+
43
+ return mergeObjColumns(options, defaultOptions)
44
+ }
45
+
46
+ // 加上千分位 ,
47
+ export function formatCommaNumber (num = 0): string {
48
+ try {
49
+ let parts = num.toString().split('.');
50
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
51
+ return parts.join('.');
52
+ } catch (e: any) {
53
+ console.error(e)
54
+ }
55
+ }