@gm-pc/vision 1.25.0-beta.0 → 1.25.0

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.
@@ -1,9 +1,9 @@
1
- import { Base } from '../../base/index'
2
- import { processor } from './config'
3
-
4
- export default class Line extends Base {
5
- name = 'line'
6
- getProcessor() {
7
- return processor
8
- }
9
- }
1
+ import { Base } from '../../base/index'
2
+ import { processor } from './config'
3
+
4
+ export default class Line extends Base {
5
+ name = 'line'
6
+ getProcessor() {
7
+ return processor
8
+ }
9
+ }
@@ -1,49 +1,49 @@
1
- import _ from 'lodash'
2
- import { ChartOptions } from '../../../types/common'
3
-
4
- export function flatData(data: any, x: string, position: string[] | string[][]) {
5
- const result: { [key: string]: any }[] = []
6
- _.forEach(data, (item) => {
7
- _.forEach(position, (pos) => {
8
- let y = ''
9
- let type = y
10
- if (_.isArray(pos)) {
11
- type = pos[1]
12
- y = pos[0]
13
- } else {
14
- y = (pos as string).split('*')[1]
15
- }
16
-
17
- result.push({
18
- [x]: item[x],
19
- value: item[y],
20
- type,
21
- })
22
- })
23
- })
24
- return result
25
- }
26
-
27
- export function getPosition(xFieldName: string, yFieldName: string[][]) {
28
- const position: string[] = []
29
- yFieldName.map((field) => {
30
- const name = field[0]
31
- position.push(`${xFieldName}*${name}`)
32
- })
33
- return position
34
- }
35
-
36
- export function getPositionAndColor(params: ChartOptions) {
37
- const { options } = params
38
- const { position, color, xFieldName, theme } = options
39
- const x = position ? position[0].split('*')[0] : xFieldName
40
-
41
- if (_.isArray(position) || !position) {
42
- return {
43
- position: `${x}*value`,
44
- color: 'type',
45
- }
46
- } else {
47
- return { position, color }
48
- }
49
- }
1
+ import _ from 'lodash'
2
+ import { ChartOptions } from '../../../types/common'
3
+
4
+ export function flatData(data: any, x: string, position: string[] | string[][]) {
5
+ const result: { [key: string]: any }[] = []
6
+ _.forEach(data, (item) => {
7
+ _.forEach(position, (pos) => {
8
+ let y = ''
9
+ let type = y
10
+ if (_.isArray(pos)) {
11
+ type = pos[1]
12
+ y = pos[0]
13
+ } else {
14
+ y = (pos as string).split('*')[1]
15
+ }
16
+
17
+ result.push({
18
+ [x]: item[x],
19
+ value: item[y],
20
+ type,
21
+ })
22
+ })
23
+ })
24
+ return result
25
+ }
26
+
27
+ export function getPosition(xFieldName: string, yFieldName: string[][]) {
28
+ const position: string[] = []
29
+ yFieldName.map((field) => {
30
+ const name = field[0]
31
+ position.push(`${xFieldName}*${name}`)
32
+ })
33
+ return position
34
+ }
35
+
36
+ export function getPositionAndColor(params: ChartOptions) {
37
+ const { options } = params
38
+ const { position, color, xFieldName, theme } = options
39
+ const x = position ? position[0].split('*')[0] : xFieldName
40
+
41
+ if (_.isArray(position) || !position) {
42
+ return {
43
+ position: `${x}*value`,
44
+ color: 'type',
45
+ }
46
+ } else {
47
+ return { position, color }
48
+ }
49
+ }
@@ -1,12 +1,12 @@
1
- import React, { FC, forwardRef, useRef, useEffect } from 'react'
2
- import _Line from './core'
3
- import useChart from '../../common/hooks/useChart'
4
- import { ChartProps, ChartOptions } from '../../types/common'
5
-
6
- const Line: FC<ChartProps> = forwardRef((props, ref) => {
7
- const { container } = useChart(_Line, props)
8
-
9
- return <div ref={container} />
10
- })
11
-
12
- export { Line }
1
+ import React, { FC, forwardRef, useRef, useEffect } from 'react'
2
+ import _Line from './core'
3
+ import useChart from '../../common/hooks/useChart'
4
+ import { ChartProps, ChartOptions } from '../../types/common'
5
+
6
+ const Line: FC<ChartProps> = forwardRef((props, ref) => {
7
+ const { container } = useChart(_Line, props)
8
+
9
+ return <div ref={container} />
10
+ })
11
+
12
+ export { Line }
@@ -1,234 +1,234 @@
1
- import React from 'react'
2
- import { Line as LineChart } from '../../index'
3
-
4
- const data = [
5
- {
6
- percent: 5,
7
- year: '2009',
8
- name: '天然气',
9
- },
10
- {
11
- percent: 10,
12
- year: '2010',
13
- name: '天然气',
14
- },
15
- {
16
- percent: 12,
17
- year: '2011',
18
- name: '天然气',
19
- },
20
- {
21
- percent: 20,
22
- year: '2012',
23
- name: '天然气',
24
- },
25
- {
26
- percent: 25,
27
- year: '2013',
28
- name: '天然气',
29
- },
30
- {
31
- percent: 40,
32
- year: '2014',
33
- name: '天然气',
34
- },
35
- {
36
- percent: 31,
37
- year: '2015',
38
- name: '天然气',
39
- },
40
- {
41
- percent: 43,
42
- year: '2016',
43
- name: '天然气',
44
- },
45
- {
46
- percent: 55,
47
- year: '2017',
48
- name: '天然气',
49
- },
50
- {
51
- percent: 50,
52
- year: '2018',
53
- name: '天然气',
54
- },
55
-
56
- {
57
- percent: 30,
58
- year: '2009',
59
- name: '煤气',
60
- },
61
- {
62
- percent: 31,
63
- year: '2010',
64
- name: '煤气',
65
- },
66
- {
67
- percent: 42,
68
- year: '2011',
69
- name: '煤气',
70
- },
71
- {
72
- percent: 37,
73
- year: '2012',
74
- name: '煤气',
75
- },
76
- {
77
- percent: 36,
78
- year: '2013',
79
- name: '煤气',
80
- },
81
- {
82
- percent: 30,
83
- year: '2014',
84
- name: '煤气',
85
- },
86
- {
87
- percent: 20,
88
- year: '2015',
89
- name: '煤气',
90
- },
91
- {
92
- percent: 15,
93
- year: '2016',
94
- name: '煤气',
95
- },
96
- {
97
- percent: 10,
98
- year: '2017',
99
- name: '煤气',
100
- },
101
- {
102
- percent: 12,
103
- year: '2018',
104
- name: '煤气',
105
- },
106
-
107
- {
108
- percent: 10,
109
- year: '2009',
110
- name: '太阳能',
111
- },
112
- {
113
- percent: 12,
114
- year: '2010',
115
- name: '太阳能',
116
- },
117
- {
118
- percent: 15,
119
- year: '2011',
120
- name: '太阳能',
121
- },
122
- {
123
- percent: 20,
124
- year: '2012',
125
- name: '太阳能',
126
- },
127
- {
128
- percent: 32,
129
- year: '2013',
130
- name: '太阳能',
131
- },
132
- {
133
- percent: 31,
134
- year: '2014',
135
- name: '太阳能',
136
- },
137
- {
138
- percent: 35,
139
- year: '2015',
140
- name: '太阳能',
141
- },
142
- {
143
- percent: 40,
144
- year: '2016',
145
- name: '太阳能',
146
- },
147
- {
148
- percent: 45,
149
- year: '2017',
150
- name: '太阳能',
151
- },
152
- {
153
- percent: 47,
154
- year: '2018',
155
- name: '太阳能',
156
- },
157
- ]
158
-
159
- export const Line = () => (
160
- <div>
161
- <h1>Basic</h1>
162
- <LineChart
163
- data={data}
164
- options={{
165
- width: '100%',
166
- height: 300,
167
- position: 'year*percent',
168
- color: 'name',
169
- legend: false, // 取消图例
170
- annotation: {
171
- text: '预警线',
172
- // 预警线位置
173
- value: (data) => {
174
- return data[8].percent
175
- },
176
- },
177
- }}
178
- />
179
- <h1>多个Y轴(数据结构不同)</h1>
180
- <LineChart
181
- data={[
182
- {
183
- year: '2009',
184
- tr: 5,
185
- tyn: 12,
186
- },
187
- {
188
- year: '2010',
189
- tr: 10,
190
- tyn: 15,
191
- },
192
- ]}
193
- options={{
194
- width: '100%',
195
- height: 300,
196
- xFieldName: 'year',
197
- yFieldName: [
198
- ['tr', '天然气'],
199
- ['tyn', '太阳能'],
200
- ],
201
- scale: {
202
- value: {
203
- formatter: (text) => text + 'L',
204
- min: 0,
205
- max: 20,
206
- },
207
- },
208
- }}
209
- />
210
- <h1>深蓝主题</h1>
211
- <LineChart
212
- data={data}
213
- options={{
214
- width: '100%',
215
- height: 300,
216
- theme: 'ocean',
217
- position: 'year*percent',
218
- color: 'name',
219
- legend: false, // 取消图例
220
- annotation: {
221
- text: '预警线',
222
- // 预警线位置
223
- value: (data) => {
224
- return data[8].percent
225
- },
226
- },
227
- }}
228
- />
229
- </div>
230
- )
231
-
232
- export default {
233
- title: 'Chart/折线图 Line',
234
- }
1
+ import React from 'react'
2
+ import { Line as LineChart } from '../../index'
3
+
4
+ const data = [
5
+ {
6
+ percent: 5,
7
+ year: '2009',
8
+ name: '天然气',
9
+ },
10
+ {
11
+ percent: 10,
12
+ year: '2010',
13
+ name: '天然气',
14
+ },
15
+ {
16
+ percent: 12,
17
+ year: '2011',
18
+ name: '天然气',
19
+ },
20
+ {
21
+ percent: 20,
22
+ year: '2012',
23
+ name: '天然气',
24
+ },
25
+ {
26
+ percent: 25,
27
+ year: '2013',
28
+ name: '天然气',
29
+ },
30
+ {
31
+ percent: 40,
32
+ year: '2014',
33
+ name: '天然气',
34
+ },
35
+ {
36
+ percent: 31,
37
+ year: '2015',
38
+ name: '天然气',
39
+ },
40
+ {
41
+ percent: 43,
42
+ year: '2016',
43
+ name: '天然气',
44
+ },
45
+ {
46
+ percent: 55,
47
+ year: '2017',
48
+ name: '天然气',
49
+ },
50
+ {
51
+ percent: 50,
52
+ year: '2018',
53
+ name: '天然气',
54
+ },
55
+
56
+ {
57
+ percent: 30,
58
+ year: '2009',
59
+ name: '煤气',
60
+ },
61
+ {
62
+ percent: 31,
63
+ year: '2010',
64
+ name: '煤气',
65
+ },
66
+ {
67
+ percent: 42,
68
+ year: '2011',
69
+ name: '煤气',
70
+ },
71
+ {
72
+ percent: 37,
73
+ year: '2012',
74
+ name: '煤气',
75
+ },
76
+ {
77
+ percent: 36,
78
+ year: '2013',
79
+ name: '煤气',
80
+ },
81
+ {
82
+ percent: 30,
83
+ year: '2014',
84
+ name: '煤气',
85
+ },
86
+ {
87
+ percent: 20,
88
+ year: '2015',
89
+ name: '煤气',
90
+ },
91
+ {
92
+ percent: 15,
93
+ year: '2016',
94
+ name: '煤气',
95
+ },
96
+ {
97
+ percent: 10,
98
+ year: '2017',
99
+ name: '煤气',
100
+ },
101
+ {
102
+ percent: 12,
103
+ year: '2018',
104
+ name: '煤气',
105
+ },
106
+
107
+ {
108
+ percent: 10,
109
+ year: '2009',
110
+ name: '太阳能',
111
+ },
112
+ {
113
+ percent: 12,
114
+ year: '2010',
115
+ name: '太阳能',
116
+ },
117
+ {
118
+ percent: 15,
119
+ year: '2011',
120
+ name: '太阳能',
121
+ },
122
+ {
123
+ percent: 20,
124
+ year: '2012',
125
+ name: '太阳能',
126
+ },
127
+ {
128
+ percent: 32,
129
+ year: '2013',
130
+ name: '太阳能',
131
+ },
132
+ {
133
+ percent: 31,
134
+ year: '2014',
135
+ name: '太阳能',
136
+ },
137
+ {
138
+ percent: 35,
139
+ year: '2015',
140
+ name: '太阳能',
141
+ },
142
+ {
143
+ percent: 40,
144
+ year: '2016',
145
+ name: '太阳能',
146
+ },
147
+ {
148
+ percent: 45,
149
+ year: '2017',
150
+ name: '太阳能',
151
+ },
152
+ {
153
+ percent: 47,
154
+ year: '2018',
155
+ name: '太阳能',
156
+ },
157
+ ]
158
+
159
+ export const Line = () => (
160
+ <div>
161
+ <h1>Basic</h1>
162
+ <LineChart
163
+ data={data}
164
+ options={{
165
+ width: '100%',
166
+ height: 300,
167
+ position: 'year*percent',
168
+ color: 'name',
169
+ legend: false, // 取消图例
170
+ annotation: {
171
+ text: '预警线',
172
+ // 预警线位置
173
+ value: (data) => {
174
+ return data[8].percent
175
+ },
176
+ },
177
+ }}
178
+ />
179
+ <h1>多个Y轴(数据结构不同)</h1>
180
+ <LineChart
181
+ data={[
182
+ {
183
+ year: '2009',
184
+ tr: 5,
185
+ tyn: 12,
186
+ },
187
+ {
188
+ year: '2010',
189
+ tr: 10,
190
+ tyn: 15,
191
+ },
192
+ ]}
193
+ options={{
194
+ width: '100%',
195
+ height: 300,
196
+ xFieldName: 'year',
197
+ yFieldName: [
198
+ ['tr', '天然气'],
199
+ ['tyn', '太阳能'],
200
+ ],
201
+ scale: {
202
+ value: {
203
+ formatter: (text) => text + 'L',
204
+ min: 0,
205
+ max: 20,
206
+ },
207
+ },
208
+ }}
209
+ />
210
+ <h1>深蓝主题</h1>
211
+ <LineChart
212
+ data={data}
213
+ options={{
214
+ width: '100%',
215
+ height: 300,
216
+ theme: 'ocean',
217
+ position: 'year*percent',
218
+ color: 'name',
219
+ legend: false, // 取消图例
220
+ annotation: {
221
+ text: '预警线',
222
+ // 预警线位置
223
+ value: (data) => {
224
+ return data[8].percent
225
+ },
226
+ },
227
+ }}
228
+ />
229
+ </div>
230
+ )
231
+
232
+ export default {
233
+ title: 'Chart/折线图 Line',
234
+ }