@gravity-ui/chartkit 1.0.0 → 1.1.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.
- package/CHANGELOG.md +47 -81
- package/README.md +3 -3
- package/build/plugins/index.d.ts +1 -1
- package/build/plugins/index.js +1 -0
- package/build/plugins/yagr/__stories__/mocks/line10.js +0 -2
- package/build/plugins/yagr/__tests__/utils.test.d.ts +1 -0
- package/build/plugins/yagr/__tests__/utils.test.js +26 -0
- package/build/plugins/yagr/renderer/tooltip/renderTooltip.d.ts +1 -1
- package/build/plugins/yagr/renderer/useWidgetData.d.ts +1 -2
- package/build/plugins/yagr/renderer/useWidgetData.js +2 -24
- package/build/plugins/yagr/renderer/utils.d.ts +9 -3
- package/build/plugins/yagr/renderer/utils.js +37 -1
- package/build/plugins/yagr/types.d.ts +3 -2
- package/build/plugins/yagr/types.js +1 -1
- package/build/types/widget.d.ts +1 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,237 +1,203 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [1.
|
|
4
|
-
|
|
3
|
+
## [1.1.0](https://github.com/gravity-ui/chartkit/compare/v1.0.0...v1.1.0) (2022-12-08)
|
|
5
4
|
|
|
6
|
-
### ⚠ BREAKING CHANGES
|
|
7
|
-
|
|
8
|
-
* update yagr to v2 ([#82](https://github.com/gravity-ui/chartkit/issues/82))
|
|
9
5
|
|
|
10
6
|
### Features
|
|
11
7
|
|
|
12
|
-
*
|
|
8
|
+
* useWidgetData fixes ([54c47af](https://github.com/gravity-ui/chartkit/commit/54c47afb0c519fe8d500d993069e4c660c04550e))
|
|
13
9
|
|
|
10
|
+
## [1.0.0](https://github.com/gravity-ui/chartkit/compare/v0.13.0...v1.0.0) (2022-12-07)
|
|
14
11
|
|
|
15
|
-
###
|
|
12
|
+
### ⚠ BREAKING CHANGES
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
- update Yagr to v2. Read more about [changes](https://github.com/yandex-cloud/yagr/blob/master/CHANGELOG.md#200-19-04-2022)
|
|
18
15
|
|
|
19
16
|
## [0.13.0](https://github.com/gravity-ui/chartkit/compare/v0.12.3...v0.13.0) (2022-12-05)
|
|
20
17
|
|
|
21
|
-
|
|
22
18
|
### Features
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
- remove direct import @gravity-ui/uikit styles in ChartKit component ([#80](https://github.com/gravity-ui/chartkit/issues/80)) ([49642d7](https://github.com/gravity-ui/chartkit/commit/49642d7cfbd358a399ead674b2d3a040b05bf669))
|
|
25
21
|
|
|
26
22
|
## [0.12.3](https://github.com/gravity-ui/chartkit/compare/v0.12.2...v0.12.3) (2022-12-01)
|
|
27
23
|
|
|
28
|
-
|
|
29
24
|
### Bug Fixes
|
|
30
25
|
|
|
31
|
-
|
|
26
|
+
- **Yagr:** added common no-data case handling ([#78](https://github.com/gravity-ui/chartkit/issues/78)) ([100efaa](https://github.com/gravity-ui/chartkit/commit/100efaaff20e03048146ca084ee91c2be2568640))
|
|
32
27
|
|
|
33
28
|
## [0.12.2](https://github.com/gravity-ui/chartkit/compare/v0.12.1...v0.12.2) (2022-11-30)
|
|
34
29
|
|
|
35
|
-
|
|
36
30
|
### Bug Fixes
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
- **ChartKit:** id not to be new on every render ([#76](https://github.com/gravity-ui/chartkit/issues/76)) ([230a992](https://github.com/gravity-ui/chartkit/commit/230a992fe99a176bbf85cbef363ccac45db7b3b4))
|
|
39
33
|
|
|
40
34
|
## [0.12.1](https://github.com/gravity-ui/chartkit/compare/v0.12.0...v0.12.1) (2022-11-22)
|
|
41
35
|
|
|
42
|
-
|
|
43
36
|
### Bug Fixes
|
|
44
37
|
|
|
45
|
-
|
|
38
|
+
- **Highcharts plugin:** remove style for chart background color ([#73](https://github.com/gravity-ui/chartkit/issues/73)) ([481b2f5](https://github.com/gravity-ui/chartkit/commit/481b2f5fe07d818f37ba220f70fbad14690b39ba))
|
|
46
39
|
|
|
47
40
|
## [0.12.0](https://github.com/gravity-ui/chartkit/compare/v0.11.1...v0.12.0) (2022-11-22)
|
|
48
41
|
|
|
49
|
-
|
|
50
42
|
### Features
|
|
51
43
|
|
|
52
|
-
|
|
44
|
+
- add support border color setting ([defdcf7](https://github.com/gravity-ui/chartkit/commit/defdcf768d33fe11f9de8dc14a1e9561c034f6ea))
|
|
53
45
|
|
|
54
46
|
## [0.11.1](https://github.com/gravity-ui/chartkit/compare/v0.11.0...v0.11.1) (2022-11-21)
|
|
55
47
|
|
|
56
|
-
|
|
57
48
|
### Bug Fixes
|
|
58
49
|
|
|
59
|
-
|
|
50
|
+
- **Highcharts plugin:** fix tooltip holidays handling ([#69](https://github.com/gravity-ui/chartkit/issues/69)) ([9bc3f8c](https://github.com/gravity-ui/chartkit/commit/9bc3f8c7a62d3b269626be87a46de1d8a6949f57))
|
|
60
51
|
|
|
61
52
|
## [0.11.0](https://github.com/gravity-ui/chartkit/compare/v0.10.1...v0.11.0) (2022-11-18)
|
|
62
53
|
|
|
63
|
-
|
|
64
54
|
### Features
|
|
65
55
|
|
|
66
|
-
|
|
56
|
+
- types improvements ([#67](https://github.com/gravity-ui/chartkit/issues/67)) ([33b4f07](https://github.com/gravity-ui/chartkit/commit/33b4f07a24abdfde52005ddbbf17fb7a25817beb))
|
|
67
57
|
|
|
68
58
|
## [0.10.1](https://github.com/gravity-ui/chartkit/compare/v0.10.0...v0.10.1) (2022-11-18)
|
|
69
59
|
|
|
70
|
-
|
|
71
60
|
### Bug Fixes
|
|
72
61
|
|
|
73
|
-
|
|
62
|
+
- **Highcharts plugin:** add Highcharts lib type export ([#65](https://github.com/gravity-ui/chartkit/issues/65)) ([de24a26](https://github.com/gravity-ui/chartkit/commit/de24a264197441b21261438808838e5fbd0a8402))
|
|
74
63
|
|
|
75
64
|
## [0.10.0](https://github.com/gravity-ui/chartkit/compare/v0.9.1...v0.10.0) (2022-11-18)
|
|
76
65
|
|
|
77
|
-
|
|
78
66
|
### Features
|
|
79
67
|
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
- add highcharts plugin ([#61](https://github.com/gravity-ui/chartkit/issues/61)) ([9329ede](https://github.com/gravity-ui/chartkit/commit/9329edeaba8c4ef84b1fc30bb7196ba350dc3abd))
|
|
82
69
|
|
|
83
70
|
### Bug Fixes
|
|
84
71
|
|
|
85
|
-
|
|
72
|
+
- yagr & indicator types fixes ([#64](https://github.com/gravity-ui/chartkit/issues/64)) ([479c552](https://github.com/gravity-ui/chartkit/commit/479c552f5ce1890451f3f104fc8efb730f2baf67))
|
|
86
73
|
|
|
87
74
|
## [0.9.1](https://github.com/gravity-ui/chartkit/compare/v0.9.0...v0.9.1) (2022-11-14)
|
|
88
75
|
|
|
89
|
-
|
|
90
76
|
### Bug Fixes
|
|
91
77
|
|
|
92
|
-
|
|
78
|
+
- fix yagr theme initialization ([#59](https://github.com/gravity-ui/chartkit/issues/59)) ([7247873](https://github.com/gravity-ui/chartkit/commit/724787380b8d81f6dfdaae1f6e5c1b806af32e3c))
|
|
93
79
|
|
|
94
80
|
## [0.9.0](https://github.com/gravity-ui/chartkit/compare/v0.8.0...v0.9.0) (2022-11-08)
|
|
95
81
|
|
|
96
|
-
|
|
97
82
|
### Features
|
|
98
83
|
|
|
99
|
-
|
|
84
|
+
- add isMobile property ([#57](https://github.com/gravity-ui/chartkit/issues/57)) ([a2e87ed](https://github.com/gravity-ui/chartkit/commit/a2e87edf1d05705fb92c2571b5a71496c48d9215))
|
|
100
85
|
|
|
101
86
|
## [0.8.0](https://github.com/gravity-ui/chartkit/compare/v0.7.2...v0.8.0) (2022-10-04)
|
|
102
87
|
|
|
103
|
-
|
|
104
88
|
### Features
|
|
105
89
|
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
- move to @gravity-ui/i18n ([#45](https://github.com/gravity-ui/chartkit/issues/45)) ([ad401d8](https://github.com/gravity-ui/chartkit/commit/ad401d85bf50ab4ceb0ae8a837c4b11cd36a4acd))
|
|
108
91
|
|
|
109
92
|
### Bug Fixes
|
|
110
93
|
|
|
111
|
-
|
|
94
|
+
- add ChartKitOnError type export ([#54](https://github.com/gravity-ui/chartkit/issues/54)) ([7660be7](https://github.com/gravity-ui/chartkit/commit/7660be756cd3ec1057aa9fd4bb45226c9632e80f))
|
|
112
95
|
|
|
113
96
|
## [0.7.2](https://github.com/gravity-ui/chartkit/compare/v0.7.1...v0.7.2) (2022-10-03)
|
|
114
97
|
|
|
115
|
-
|
|
116
98
|
### Bug Fixes
|
|
117
99
|
|
|
118
|
-
|
|
100
|
+
- package.json fixes ([#50](https://github.com/gravity-ui/chartkit/issues/50)) ([aca306d](https://github.com/gravity-ui/chartkit/commit/aca306dc8872951a48c1db0362ae1912138d72ed))
|
|
119
101
|
|
|
120
102
|
## [0.7.1](https://github.com/gravity-ui/chartkit/compare/v0.7.0...v0.7.1) (2022-10-03)
|
|
121
103
|
|
|
122
|
-
|
|
123
104
|
### Bug Fixes
|
|
124
105
|
|
|
125
|
-
|
|
106
|
+
- move to gravity-ui configs ([#48](https://github.com/gravity-ui/chartkit/issues/48)) ([620587b](https://github.com/gravity-ui/chartkit/commit/620587b41febade698f12e67506aab683934e7b3))
|
|
126
107
|
|
|
127
108
|
## [0.7.0](https://github.com/yandex-cloud/chartkit/compare/v0.6.0...v0.7.0) (2022-10-01)
|
|
128
109
|
|
|
129
|
-
|
|
130
110
|
### Features
|
|
131
111
|
|
|
132
|
-
|
|
112
|
+
- use gravity-ui/uikit instead of yandex-cloud/uikit ([#46](https://github.com/yandex-cloud/chartkit/issues/46)) ([afb2300](https://github.com/yandex-cloud/chartkit/commit/afb230036bb26573159e5f03e0972653b6692d86))
|
|
133
113
|
|
|
134
114
|
## [0.6.0](https://github.com/yandex-cloud/chartkit/compare/v0.5.4...v0.6.0) (2022-08-12)
|
|
135
115
|
|
|
136
|
-
|
|
137
116
|
### Features
|
|
138
117
|
|
|
139
|
-
|
|
118
|
+
- remove uikit css variables proxing ([#43](https://github.com/yandex-cloud/chartkit/issues/43)) ([4d5131e](https://github.com/yandex-cloud/chartkit/commit/4d5131e0d77270e44bef94f0ba05c9fc5c317704))
|
|
140
119
|
|
|
141
120
|
## [0.5.4](https://github.com/yandex-cloud/chartkit/compare/v0.5.3...v0.5.4) (2022-08-08)
|
|
142
121
|
|
|
143
|
-
|
|
144
122
|
### Bug Fixes
|
|
145
123
|
|
|
146
|
-
|
|
147
|
-
|
|
124
|
+
- add Yagr type export ([#42](https://github.com/yandex-cloud/chartkit/issues/42)) ([a8b9475](https://github.com/yandex-cloud/chartkit/commit/a8b94755bbb0d42652db3e4266e0ca04481ad99f))
|
|
125
|
+
- npm vulnerabilities fixes ([#40](https://github.com/yandex-cloud/chartkit/issues/40)) ([1509bcf](https://github.com/yandex-cloud/chartkit/commit/1509bcf87a50d9281c3ea47074c694db429ad5d4))
|
|
148
126
|
|
|
149
127
|
## [0.5.3](https://github.com/yandex-cloud/chartkit/compare/v0.5.2...v0.5.3) (2022-08-01)
|
|
150
128
|
|
|
151
|
-
|
|
152
129
|
### Bug Fixes
|
|
153
130
|
|
|
154
|
-
|
|
131
|
+
- dev and peer dependencies fixes ([#36](https://github.com/yandex-cloud/chartkit/issues/36)) ([faeccd9](https://github.com/yandex-cloud/chartkit/commit/faeccd9aca9b84ee02edeadef3db2d2abeedb143))
|
|
155
132
|
|
|
156
133
|
## [0.5.2](https://github.com/yandex-cloud/chartkit/compare/v0.5.1...v0.5.2) (2022-07-28)
|
|
157
134
|
|
|
158
|
-
|
|
159
135
|
### Bug Fixes
|
|
160
136
|
|
|
161
|
-
|
|
137
|
+
- Indicator onLoad invocation fixes ([#34](https://github.com/yandex-cloud/chartkit/issues/34)) ([95fafc3](https://github.com/yandex-cloud/chartkit/commit/95fafc381bbafe47173f802310a67e7ced243d80))
|
|
162
138
|
|
|
163
139
|
## [0.5.1](https://github.com/yandex-cloud/chartkit/compare/v0.5.0...v0.5.1) (2022-07-27)
|
|
164
140
|
|
|
165
|
-
|
|
166
141
|
### Bug Fixes
|
|
167
142
|
|
|
168
|
-
|
|
143
|
+
- error handling fixes ([#31](https://github.com/yandex-cloud/chartkit/issues/31)) ([e20fb9d](https://github.com/yandex-cloud/chartkit/commit/e20fb9df1d811efa08a8a68110b1a6819a384af4))
|
|
169
144
|
|
|
170
145
|
## [0.5.0](https://github.com/yandex-cloud/chartkit/compare/v0.4.0...v0.5.0) (2022-07-25)
|
|
171
146
|
|
|
172
|
-
|
|
173
147
|
### Features
|
|
174
148
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
149
|
+
- add chartkit-error ([#28](https://github.com/yandex-cloud/chartkit/issues/28)) ([8342073](https://github.com/yandex-cloud/chartkit/commit/83420738dd431fa1ce2b96f18631f84ca36ed4af))
|
|
150
|
+
- add indicator chart ([#30](https://github.com/yandex-cloud/chartkit/issues/30)) ([4f465de](https://github.com/yandex-cloud/chartkit/commit/4f465de3afdee721f96868d975f3aee647177f76))
|
|
151
|
+
- change error handling ([#29](https://github.com/yandex-cloud/chartkit/issues/29)) ([993958a](https://github.com/yandex-cloud/chartkit/commit/993958a68e1c4376e037bd006d6b19f013b58cfb))
|
|
179
152
|
|
|
180
153
|
### Bug Fixes
|
|
181
154
|
|
|
182
|
-
|
|
155
|
+
- remove react-dom from peer dependencies ([#26](https://github.com/yandex-cloud/chartkit/issues/26)) ([22b6525](https://github.com/yandex-cloud/chartkit/commit/22b6525c767104e56cc51cf5dee5340253f7c080))
|
|
183
156
|
|
|
184
157
|
## [0.4.0](https://github.com/yandex-cloud/chartkit/compare/v0.3.1...v0.4.0) (2022-07-18)
|
|
185
158
|
|
|
186
|
-
|
|
187
159
|
### Features
|
|
188
160
|
|
|
189
|
-
|
|
161
|
+
- add onError property ([#24](https://github.com/yandex-cloud/chartkit/issues/24)) ([0b51f19](https://github.com/yandex-cloud/chartkit/commit/0b51f195612cb80ab8e40b5d115eb7650f986888))
|
|
190
162
|
|
|
191
163
|
## [0.3.1](https://github.com/yandex-cloud/chartkit/compare/v0.3.0...v0.3.1) (2022-07-14)
|
|
192
164
|
|
|
193
|
-
|
|
194
165
|
### Bug Fixes
|
|
195
166
|
|
|
196
|
-
|
|
197
|
-
|
|
167
|
+
- add test for settings ([#21](https://github.com/yandex-cloud/chartkit/issues/21)) ([b848503](https://github.com/yandex-cloud/chartkit/commit/b8485032d9ab14edda0a8f193f9174e3a6c687bf))
|
|
168
|
+
- build task fixes ([#23](https://github.com/yandex-cloud/chartkit/issues/23)) ([2f13233](https://github.com/yandex-cloud/chartkit/commit/2f13233005d8fe7d10d496464ec3aed0a9ea5743))
|
|
198
169
|
|
|
199
170
|
## [0.3.0](https://github.com/yandex-cloud/chartkit/compare/v0.2.0...v0.3.0) (2022-07-13)
|
|
200
171
|
|
|
201
|
-
|
|
202
172
|
### Features
|
|
203
173
|
|
|
204
|
-
|
|
174
|
+
- add root types export ([#18](https://github.com/yandex-cloud/chartkit/issues/18)) ([06265a1](https://github.com/yandex-cloud/chartkit/commit/06265a10f518836ac63f2b847e73dd19b3e2e8ca))
|
|
205
175
|
|
|
206
176
|
## [0.2.0](https://github.com/yandex-cloud/chartkit/compare/v0.1.1...v0.2.0) (2022-07-11)
|
|
207
177
|
|
|
208
|
-
|
|
209
178
|
### Features
|
|
210
179
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
180
|
+
- add cn lib ([#10](https://github.com/yandex-cloud/chartkit/issues/10)) ([796bdda](https://github.com/yandex-cloud/chartkit/commit/796bdda22fbf69ea8fc37965486e358ea3779a7e))
|
|
181
|
+
- add i18n ([#13](https://github.com/yandex-cloud/chartkit/issues/13)) ([3f0204b](https://github.com/yandex-cloud/chartkit/commit/3f0204bb949aeb596632b3479d7e5ee130d91225))
|
|
182
|
+
- add reflow handler ([#15](https://github.com/yandex-cloud/chartkit/issues/15)) ([80210af](https://github.com/yandex-cloud/chartkit/commit/80210af775ca7476f107f6ecc2ae9983baa9a8e3))
|
|
183
|
+
- add yagr plugin types export ([#17](https://github.com/yandex-cloud/chartkit/issues/17)) ([6e4cf1d](https://github.com/yandex-cloud/chartkit/commit/6e4cf1dc5cc584a9bda99b39122f489ed35f90e2))
|
|
184
|
+
- change lib structure ([#7](https://github.com/yandex-cloud/chartkit/issues/7)) ([dfb6ed8](https://github.com/yandex-cloud/chartkit/commit/dfb6ed839fd49a13006e75bca77abfd43849653b))
|
|
217
185
|
|
|
218
186
|
### Bug Fixes
|
|
219
187
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
188
|
+
- change cn workflow ([#12](https://github.com/yandex-cloud/chartkit/issues/12)) ([aba5148](https://github.com/yandex-cloud/chartkit/commit/aba5148237aa0dd0bfd89744c77e30ebbcbcb90e))
|
|
189
|
+
- downgrade i18n to v0.5.0 ([#16](https://github.com/yandex-cloud/chartkit/issues/16)) ([454985a](https://github.com/yandex-cloud/chartkit/commit/454985a6c339775ebc0a96d77a20792b31b305c7))
|
|
190
|
+
- move all storybook decorators into one ([#14](https://github.com/yandex-cloud/chartkit/issues/14)) ([de1e8e9](https://github.com/yandex-cloud/chartkit/commit/de1e8e90325142e41ece8edc785119440b49fa0c))
|
|
223
191
|
|
|
224
192
|
### [0.1.1](https://www.github.com/yandex-cloud/ChartKit/compare/v0.1.0...v0.1.1) (2022-02-17)
|
|
225
193
|
|
|
226
|
-
|
|
227
194
|
### Bug Fixes
|
|
228
195
|
|
|
229
|
-
|
|
196
|
+
- add publishConfig ([5cfdfff](https://www.github.com/yandex-cloud/ChartKit/commit/5cfdfffbdcafb8baeb05338ef07dd3a602c51797))
|
|
230
197
|
|
|
231
198
|
## 0.1.0 (2022-02-17)
|
|
232
199
|
|
|
233
|
-
|
|
234
200
|
### Bug Fixes
|
|
235
201
|
|
|
236
|
-
|
|
237
|
-
|
|
202
|
+
- init ([2804dac](https://www.github.com/yandex-cloud/ChartKit/commit/2804dacfd0f11e15cda6a84ca22172bf2d74b532))
|
|
203
|
+
- init ([4b747d4](https://www.github.com/yandex-cloud/ChartKit/commit/4b747d409122fc4ae330040e75e273ee9a602bcf))
|
package/README.md
CHANGED
|
@@ -36,21 +36,21 @@ const data: YagrWidgetData = {
|
|
|
36
36
|
id: '0',
|
|
37
37
|
name: 'Serie 1',
|
|
38
38
|
color: '#6c59c2',
|
|
39
|
-
visible: true,
|
|
40
39
|
data: [25, 52, 89, 72, 39, 49, 82, 59, 36, 5],
|
|
41
40
|
},
|
|
42
41
|
{
|
|
43
42
|
id: '1',
|
|
44
43
|
name: 'Serie 2',
|
|
45
44
|
color: '#6e8188',
|
|
46
|
-
visible: true,
|
|
47
45
|
data: [37, 6, 51, 10, 65, 35, 72, 0, 94, 54],
|
|
48
46
|
},
|
|
49
47
|
],
|
|
50
48
|
},
|
|
51
49
|
libraryConfig: {
|
|
52
50
|
chart: {
|
|
53
|
-
|
|
51
|
+
series: {
|
|
52
|
+
type: 'line',
|
|
53
|
+
},
|
|
54
54
|
},
|
|
55
55
|
title: {
|
|
56
56
|
text: 'line: random 10 pts',
|
package/build/plugins/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { YagrPlugin } from './yagr';
|
|
2
|
-
export
|
|
2
|
+
export * from './yagr/types';
|
|
3
3
|
export { IndicatorPlugin } from './indicator';
|
|
4
4
|
export type { IndicatorWidgetData } from './indicator/types';
|
|
5
5
|
export { HighchartsPlugin } from './highcharts';
|
package/build/plugins/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { shapeYagrConfig } from '../renderer/utils';
|
|
2
|
+
const DATA = {
|
|
3
|
+
timeline: [1],
|
|
4
|
+
graphs: [{ data: [45] }],
|
|
5
|
+
};
|
|
6
|
+
describe('plugins/yagr/utils', () => {
|
|
7
|
+
describe('shapeYagrConfig > check chart property', () => {
|
|
8
|
+
test.each([
|
|
9
|
+
[{}, { appereance: { locale: 'en', theme: 'dark' } }],
|
|
10
|
+
[{ appereance: { locale: 'ru' } }, { appereance: { locale: 'ru', theme: 'dark' } }],
|
|
11
|
+
[{ appereance: { theme: 'light' } }, { appereance: { locale: 'en', theme: 'light' } }],
|
|
12
|
+
[
|
|
13
|
+
{ series: { type: 'dots' }, select: { zoom: false }, timeMultiplier: 1 },
|
|
14
|
+
{
|
|
15
|
+
appereance: { locale: 'en', theme: 'dark' },
|
|
16
|
+
series: { type: 'dots' },
|
|
17
|
+
select: { zoom: false },
|
|
18
|
+
timeMultiplier: 1,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
])('(args: %j)', (chart, expected) => {
|
|
22
|
+
const config = shapeYagrConfig({ data: DATA, libraryConfig: { chart }, theme: 'dark' });
|
|
23
|
+
expect(config.chart).toEqual(expected);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TooltipRenderOptions } from '
|
|
1
|
+
import type { TooltipRenderOptions } from '../../types';
|
|
2
2
|
export declare const renderTooltip: (data: TooltipRenderOptions) => string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { MinimalValidConfig } from 'yagr';
|
|
2
1
|
import type { YagrChartProps } from 'yagr/dist/react';
|
|
3
|
-
import type { YagrWidgetData } from '../types';
|
|
2
|
+
import type { YagrWidgetData, MinimalValidConfig } from '../types';
|
|
4
3
|
export declare const useWidgetData: (args: YagrWidgetData & {
|
|
5
4
|
id: string;
|
|
6
5
|
}) => {
|
|
@@ -1,32 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useThemeType } from '@gravity-ui/uikit';
|
|
3
|
-
import {
|
|
4
|
-
import { settings } from '../../../libs';
|
|
5
|
-
import { renderTooltip } from './tooltip';
|
|
6
|
-
import { getXAxisFormatter } from './utils';
|
|
3
|
+
import { shapeYagrConfig } from './utils';
|
|
7
4
|
export const useWidgetData = (args) => {
|
|
8
5
|
const { id, data, sources, libraryConfig } = args;
|
|
9
6
|
const theme = useThemeType();
|
|
10
|
-
const config = React.useMemo(() => {
|
|
11
|
-
var _a, _b, _c;
|
|
12
|
-
const result = Object.assign(Object.assign({}, libraryConfig), { timeline: data.timeline, series: data.graphs });
|
|
13
|
-
result.chart = Object.assign({ appereance: Object.assign({ locale: settings.get('lang'), theme }, (_a = result.chart) === null || _a === void 0 ? void 0 : _a.appereance) }, result.chart);
|
|
14
|
-
if (((_b = result.tooltip) === null || _b === void 0 ? void 0 : _b.show) !== false) {
|
|
15
|
-
result.tooltip = result.tooltip || {};
|
|
16
|
-
result.tooltip.render = ((_c = result.tooltip) === null || _c === void 0 ? void 0 : _c.render) || renderTooltip;
|
|
17
|
-
}
|
|
18
|
-
result.axes = result.axes || {};
|
|
19
|
-
const xAxis = result.axes[defaults.DEFAULT_X_SCALE];
|
|
20
|
-
if (xAxis && !xAxis.values) {
|
|
21
|
-
xAxis.values = getXAxisFormatter(result.chart.timeMultiplier);
|
|
22
|
-
}
|
|
23
|
-
if (!xAxis) {
|
|
24
|
-
result.axes[defaults.DEFAULT_X_SCALE] = {
|
|
25
|
-
values: getXAxisFormatter(result.chart.timeMultiplier),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
return result;
|
|
29
|
-
}, [data, libraryConfig, theme]);
|
|
7
|
+
const config = React.useMemo(() => shapeYagrConfig({ data, libraryConfig, theme }), [data, libraryConfig, theme]);
|
|
30
8
|
const debug = React.useMemo(() => {
|
|
31
9
|
const filename = sources
|
|
32
10
|
? Object.values(sources)
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Yagr, YagrWidgetData, YagrTheme, MinimalValidConfig } from '../types';
|
|
2
|
+
declare type ShapeYagrConfigArgs = {
|
|
3
|
+
data: YagrWidgetData['data'];
|
|
4
|
+
libraryConfig: YagrWidgetData['libraryConfig'];
|
|
5
|
+
theme: YagrTheme;
|
|
6
|
+
};
|
|
2
7
|
export declare const synchronizeTooltipTablesCellsWidth: (tooltipContainer: HTMLElement) => void;
|
|
3
8
|
export declare const checkFocus: (args: {
|
|
4
9
|
tooltip: HTMLElement;
|
|
@@ -10,6 +15,7 @@ export declare const detectClickOutside: (args: {
|
|
|
10
15
|
pin: (state: boolean) => void;
|
|
11
16
|
hide: () => void;
|
|
12
17
|
};
|
|
13
|
-
yagr?: Yagr<
|
|
18
|
+
yagr?: Yagr<MinimalValidConfig> | undefined;
|
|
14
19
|
}) => (event: MouseEvent) => void;
|
|
15
|
-
export declare const
|
|
20
|
+
export declare const shapeYagrConfig: (args: ShapeYagrConfigArgs) => MinimalValidConfig;
|
|
21
|
+
export {};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import moment from 'moment';
|
|
2
|
+
import merge from 'lodash/merge';
|
|
3
|
+
import { defaults } from 'yagr';
|
|
4
|
+
import { settings } from '../../../libs';
|
|
5
|
+
import { renderTooltip } from './tooltip';
|
|
2
6
|
const TOOLTIP_HEADER_CLASS_NAME = '_tooltip-header';
|
|
3
7
|
const TOOLTIP_LIST_CLASS_NAME = '_tooltip-list';
|
|
4
8
|
export const synchronizeTooltipTablesCellsWidth = (tooltipContainer) => {
|
|
@@ -68,7 +72,7 @@ export const detectClickOutside = (args) => (event) => {
|
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
};
|
|
71
|
-
|
|
75
|
+
const getXAxisFormatter = (msm = 1) => (_, ticks) => {
|
|
72
76
|
const range = (ticks[ticks.length - 1] - ticks[0]) / msm;
|
|
73
77
|
return ticks.map((rawValue) => {
|
|
74
78
|
const d = moment(rawValue / msm);
|
|
@@ -78,3 +82,35 @@ export const getXAxisFormatter = (msm = 1) => (_, ticks) => {
|
|
|
78
82
|
return d.format(range < 300 ? 'HH:mm:ss' : 'HH:mm');
|
|
79
83
|
});
|
|
80
84
|
};
|
|
85
|
+
export const shapeYagrConfig = (args) => {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
const { data, libraryConfig, theme } = args;
|
|
88
|
+
const config = Object.assign(Object.assign({}, libraryConfig), { timeline: data.timeline, series: data.graphs });
|
|
89
|
+
const chart = {
|
|
90
|
+
appereance: {
|
|
91
|
+
locale: settings.get('lang'),
|
|
92
|
+
theme,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
merge(chart, config.chart);
|
|
96
|
+
config.chart = chart;
|
|
97
|
+
if ((_a = config.tooltip) === null || _a === void 0 ? void 0 : _a.show) {
|
|
98
|
+
config.tooltip = config.tooltip || {};
|
|
99
|
+
config.tooltip.render = ((_b = config.tooltip) === null || _b === void 0 ? void 0 : _b.render) || renderTooltip;
|
|
100
|
+
if (!config.tooltip.className) {
|
|
101
|
+
// "className" property prevent default yagr styles adding
|
|
102
|
+
config.tooltip.className = 'chartkit-yagr-tooltip';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
config.axes = config.axes || {};
|
|
106
|
+
const xAxis = config.axes[defaults.DEFAULT_X_SCALE];
|
|
107
|
+
if (xAxis && !xAxis.values) {
|
|
108
|
+
xAxis.values = getXAxisFormatter(config.chart.timeMultiplier);
|
|
109
|
+
}
|
|
110
|
+
if (!xAxis) {
|
|
111
|
+
config.axes[defaults.DEFAULT_X_SCALE] = {
|
|
112
|
+
values: getXAxisFormatter(config.chart.timeMultiplier),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return config;
|
|
116
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
1
|
+
import type { RawSerieData, YagrConfig } from 'yagr';
|
|
2
|
+
export type { default as Yagr } from 'yagr';
|
|
3
|
+
export * from 'yagr/dist/types';
|
|
3
4
|
export declare type YagrWidgetData = {
|
|
4
5
|
data: {
|
|
5
6
|
graphs: RawSerieData[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from 'yagr/dist/types';
|
package/build/types/widget.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type Yagr from 'yagr';
|
|
2
|
-
import type { YagrWidgetData } from '../plugins/yagr/types';
|
|
1
|
+
import type { Yagr, YagrWidgetData } from '../plugins/yagr/types';
|
|
3
2
|
import type { IndicatorWidgetData } from '../plugins/indicator/types';
|
|
4
3
|
import type { Highcharts, HighchartsWidgetData, StringParams } from '../plugins/highcharts/types';
|
|
5
4
|
export interface ChartKitWidget {
|
package/package.json
CHANGED