@oanda/labs-order-book-widget 1.0.173 → 1.0.174
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 +684 -0
- package/dist/main/OrderBookWidget/ChartWithData.js +4 -4
- package/dist/main/OrderBookWidget/ChartWithData.js.map +1 -1
- package/dist/main/OrderBookWidget/Main.js +11 -11
- package/dist/main/OrderBookWidget/Main.js.map +1 -1
- package/dist/main/OrderBookWidget/OrderBookWidget.js +9 -9
- package/dist/main/OrderBookWidget/OrderBookWidget.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/Chart.js +14 -14
- package/dist/main/OrderBookWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/formatters.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/getOption.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/types.js.map +1 -1
- package/dist/main/OrderBookWidget/config.js.map +1 -1
- package/dist/main/OrderBookWidget/render.js +9 -9
- package/dist/main/OrderBookWidget/render.js.map +1 -1
- package/dist/main/OrderBookWidget/types.js.map +1 -1
- package/dist/main/gql/getOrderPositionBooks.js +5 -1
- package/dist/main/gql/getOrderPositionBooks.js.map +1 -1
- package/dist/main/gql/types/fragment-masking.js.map +1 -1
- package/dist/main/gql/types/gql.js +1 -1
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +114 -114
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/main/gql/types/index.js.map +1 -1
- package/dist/main/index.js +8 -8
- package/dist/main/index.js.map +1 -1
- package/dist/main/translations/index.js +1 -1
- package/dist/main/translations/index.js.map +1 -1
- package/dist/main/translations/translations.js.map +1 -1
- package/dist/module/OrderBookWidget/ChartWithData.js +4 -4
- package/dist/module/OrderBookWidget/ChartWithData.js.map +1 -1
- package/dist/module/OrderBookWidget/Main.js +10 -10
- package/dist/module/OrderBookWidget/Main.js.map +1 -1
- package/dist/module/OrderBookWidget/OrderBookWidget.js +9 -9
- package/dist/module/OrderBookWidget/OrderBookWidget.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/Chart.js +14 -14
- package/dist/module/OrderBookWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/formatters.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/getOption.js +1 -1
- package/dist/module/OrderBookWidget/components/Chart/getOption.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/types.js.map +1 -1
- package/dist/module/OrderBookWidget/config.js +1 -1
- package/dist/module/OrderBookWidget/config.js.map +1 -1
- package/dist/module/OrderBookWidget/render.js +10 -10
- package/dist/module/OrderBookWidget/render.js.map +1 -1
- package/dist/module/OrderBookWidget/types.js.map +1 -1
- package/dist/module/gql/getOrderPositionBooks.js +5 -1
- package/dist/module/gql/getOrderPositionBooks.js.map +1 -1
- package/dist/module/gql/types/fragment-masking.js.map +1 -1
- package/dist/module/gql/types/gql.js +1 -1
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +114 -114
- package/dist/module/gql/types/graphql.js.map +1 -1
- package/dist/module/gql/types/index.js +2 -2
- package/dist/module/gql/types/index.js.map +1 -1
- package/dist/module/index.js +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/translations/index.js +1 -1
- package/dist/module/translations/index.js.map +1 -1
- package/dist/module/translations/translations.js.map +1 -1
- package/dist/types/OrderBookWidget/ChartWithData.d.ts +2 -2
- package/dist/types/OrderBookWidget/Main.d.ts +1 -1
- package/dist/types/OrderBookWidget/OrderBookWidget.d.ts +1 -1
- package/dist/types/OrderBookWidget/components/Chart/Chart.d.ts +1 -1
- package/dist/types/OrderBookWidget/components/Chart/formatters.d.ts +1 -1
- package/dist/types/OrderBookWidget/components/Chart/getOption.d.ts +1 -1
- package/dist/types/OrderBookWidget/components/Chart/types.d.ts +2 -2
- package/dist/types/OrderBookWidget/config.d.ts +1 -1
- package/dist/types/OrderBookWidget/types.d.ts +2 -2
- package/dist/types/gql/types/gql.d.ts +2 -2
- package/dist/types/gql/types/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/translations/index.d.ts +2 -2
- package/package.json +3 -3
- package/src/OrderBookWidget/ChartWithData.tsx +40 -39
- package/src/OrderBookWidget/Main.tsx +48 -30
- package/src/OrderBookWidget/OrderBookWidget.tsx +8 -8
- package/src/OrderBookWidget/components/Chart/Chart.tsx +41 -29
- package/src/OrderBookWidget/components/Chart/formatters.ts +11 -4
- package/src/OrderBookWidget/components/Chart/getOption.ts +205 -188
- package/src/OrderBookWidget/components/Chart/types.ts +10 -13
- package/src/OrderBookWidget/config.ts +76 -53
- package/src/OrderBookWidget/render.tsx +81 -52
- package/src/OrderBookWidget/types.ts +3 -2
- package/src/gql/getOrderPositionBooks.ts +5 -1
- package/src/gql/types/fragment-masking.ts +41 -21
- package/src/gql/types/gql.ts +7 -3
- package/src/gql/types/graphql.ts +165 -44
- package/src/gql/types/index.ts +2 -2
- package/src/index.ts +1 -1
- package/src/translations/index.ts +4 -4
- package/src/translations/translations.ts +1 -3
- package/test/Main.test.tsx +12 -9
- package/test/chartOptions.test.ts +18 -12
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import { colorPalette, getGridLines, getZoomControls } from '@oanda/labs-widget-common';
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
colorPalette,
|
|
3
|
+
getGridLines,
|
|
4
|
+
getZoomControls,
|
|
5
|
+
} from '@oanda/labs-widget-common';
|
|
6
|
+
|
|
7
|
+
import {
|
|
5
8
|
CHART_HEIGHT_DESKTOP,
|
|
6
9
|
CHART_HEIGHT_MOBILE,
|
|
10
|
+
CHART_WIDTH,
|
|
11
|
+
INITIAL_BARS,
|
|
7
12
|
X_LABEL_SIZE,
|
|
8
13
|
Y_LABEL_SIZE_DESKTOP,
|
|
9
14
|
Y_LABEL_SIZE_MOBILE,
|
|
10
15
|
ZOOM_CONTROL_HEIGHT,
|
|
11
16
|
} from './constants';
|
|
12
|
-
import { GetOptionType, GetResponsiveOptionsProps } from './types';
|
|
13
17
|
import { tooltipFormatter } from './formatters';
|
|
18
|
+
import type { GetOptionType, GetResponsiveOptionsProps } from './types';
|
|
14
19
|
|
|
15
|
-
export const getResponsiveOption = (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
) => {
|
|
20
|
+
export const getResponsiveOption = ({
|
|
21
|
+
isDark,
|
|
22
|
+
isOrderBook,
|
|
23
|
+
isDesktop,
|
|
24
|
+
lang,
|
|
25
|
+
}: GetResponsiveOptionsProps) => {
|
|
21
26
|
const desktopGridLines = getGridLines({
|
|
22
27
|
isDark,
|
|
23
28
|
chartWidth: CHART_WIDTH,
|
|
@@ -136,221 +141,233 @@ export const getResponsiveOption = (
|
|
|
136
141
|
};
|
|
137
142
|
|
|
138
143
|
export const getOption: GetOptionType = ({
|
|
139
|
-
data,
|
|
144
|
+
data,
|
|
145
|
+
precision,
|
|
146
|
+
isDark,
|
|
147
|
+
isOrderBook,
|
|
148
|
+
isDesktop,
|
|
149
|
+
lang,
|
|
140
150
|
}) => {
|
|
141
151
|
const buckets = data.orderPositionBooks[0]?.buckets || [];
|
|
142
152
|
const bucketWidth = data.orderPositionBooks[0]?.bucketWidth!;
|
|
143
153
|
const price = data.orderPositionBooks[0]?.price!;
|
|
144
154
|
const bucketPrecision = bucketWidth.toString().split('.')[1].length || 0;
|
|
145
155
|
|
|
146
|
-
const dataset = buckets.map((item) =>
|
|
156
|
+
const dataset = buckets.map((item) => [
|
|
147
157
|
item!.price,
|
|
148
158
|
Number(item!.longCountPercent),
|
|
149
159
|
Number(item!.shortCountPercent) * -1,
|
|
150
|
-
])
|
|
160
|
+
]);
|
|
151
161
|
|
|
152
|
-
const zoomInitialStartValue = price -
|
|
153
|
-
const zoomInitialEndValue = price +
|
|
162
|
+
const zoomInitialStartValue = price - bucketWidth * INITIAL_BARS * 0.5;
|
|
163
|
+
const zoomInitialEndValue = price + bucketWidth * INITIAL_BARS * 0.5;
|
|
154
164
|
|
|
155
165
|
const max = Math.max(...dataset.map((item) => item[1]));
|
|
156
166
|
const min = Math.abs(Math.min(...dataset.map((item) => item[2])));
|
|
157
167
|
|
|
158
168
|
const range = max > min ? max : min;
|
|
159
169
|
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
fontSize: 14,
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
toolbox: {
|
|
175
|
-
feature: getZoomControls({
|
|
176
|
-
resetStartValue: zoomInitialStartValue,
|
|
177
|
-
resetEndValue: zoomInitialEndValue,
|
|
178
|
-
}),
|
|
170
|
+
return {
|
|
171
|
+
animation: false,
|
|
172
|
+
color: [
|
|
173
|
+
colorPalette.bottleGreenLight,
|
|
174
|
+
isDark ? colorPalette.orange : colorPalette.raspberryDark,
|
|
175
|
+
],
|
|
176
|
+
title: {
|
|
177
|
+
text: lang(isOrderBook ? 'open_orders' : 'open_positions').toUpperCase(),
|
|
178
|
+
padding: 20,
|
|
179
|
+
textStyle: {
|
|
180
|
+
fontSize: 14,
|
|
179
181
|
},
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
},
|
|
183
|
+
toolbox: {
|
|
184
|
+
feature: getZoomControls({
|
|
185
|
+
resetStartValue: zoomInitialStartValue,
|
|
186
|
+
resetEndValue: zoomInitialEndValue,
|
|
187
|
+
}),
|
|
188
|
+
},
|
|
189
|
+
dataZoom: [
|
|
190
|
+
{
|
|
191
|
+
type: 'inside',
|
|
192
|
+
realtime: true,
|
|
193
|
+
startValue: zoomInitialStartValue,
|
|
194
|
+
endValue: zoomInitialEndValue,
|
|
186
195
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
196
|
+
yAxisIndex: 0,
|
|
197
|
+
minValueSpan: 10 * bucketWidth,
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
tooltip: {
|
|
201
|
+
trigger: 'axis',
|
|
202
|
+
axisPointer: {
|
|
203
|
+
axis: 'y',
|
|
204
|
+
},
|
|
205
|
+
formatter: (val) =>
|
|
206
|
+
tooltipFormatter({
|
|
197
207
|
data: (val as { data: number[] }[])[0].data,
|
|
198
208
|
precision: bucketPrecision,
|
|
199
209
|
isOrderBook,
|
|
200
210
|
lang,
|
|
201
211
|
}),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
xAxis: {
|
|
214
|
-
type: 'value',
|
|
215
|
-
min: Math.floor(range * -1.1),
|
|
216
|
-
max: Math.ceil(range * 1.1),
|
|
217
|
-
axisTick: { show: false },
|
|
218
|
-
axisLine: { show: false },
|
|
219
|
-
axisLabel: {
|
|
220
|
-
padding: [7, 12, 0, 12],
|
|
221
|
-
formatter: (value) => (value === 0 ? '%' : `${Math.abs(value)}%`),
|
|
222
|
-
hideOverlap: true,
|
|
223
|
-
alignMaxLabel: 'right',
|
|
224
|
-
alignMinLabel: 'left',
|
|
225
|
-
},
|
|
212
|
+
extraCssText: 'z-index: 1',
|
|
213
|
+
},
|
|
214
|
+
grid: [
|
|
215
|
+
{
|
|
216
|
+
name: 'main-grid',
|
|
217
|
+
top: '48px',
|
|
218
|
+
left: '0px',
|
|
219
|
+
right: `${isDesktop ? Y_LABEL_SIZE_DESKTOP : Y_LABEL_SIZE_MOBILE}px`,
|
|
220
|
+
bottom: `${isDesktop ? X_LABEL_SIZE : X_LABEL_SIZE + ZOOM_CONTROL_HEIGHT}px`,
|
|
226
221
|
},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
},
|
|
222
|
+
],
|
|
223
|
+
xAxis: {
|
|
224
|
+
type: 'value',
|
|
225
|
+
min: Math.floor(range * -1.1),
|
|
226
|
+
max: Math.ceil(range * 1.1),
|
|
227
|
+
axisTick: { show: false },
|
|
228
|
+
axisLine: { show: false },
|
|
229
|
+
axisLabel: {
|
|
230
|
+
padding: [7, 12, 0, 12],
|
|
231
|
+
formatter: (value) => (value === 0 ? '%' : `${Math.abs(value)}%`),
|
|
232
|
+
hideOverlap: true,
|
|
233
|
+
alignMaxLabel: 'right',
|
|
234
|
+
alignMinLabel: 'left',
|
|
241
235
|
},
|
|
242
|
-
|
|
243
|
-
|
|
236
|
+
},
|
|
237
|
+
yAxis: {
|
|
238
|
+
type: 'value',
|
|
239
|
+
position: 'right',
|
|
240
|
+
axisLine: { show: false },
|
|
241
|
+
axisTick: { show: false },
|
|
242
|
+
axisLabel: {
|
|
243
|
+
overflow: 'truncate',
|
|
244
|
+
width: (isDesktop ? Y_LABEL_SIZE_DESKTOP : Y_LABEL_SIZE_MOBILE) - 10,
|
|
245
|
+
margin: isDesktop ? 10 : 0,
|
|
246
|
+
showMaxLabel: false,
|
|
247
|
+
showMinLabel: false,
|
|
248
|
+
padding: [0, 0, 0, 10],
|
|
249
|
+
formatter: (value) => value.toFixed(bucketPrecision),
|
|
244
250
|
},
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
251
|
+
},
|
|
252
|
+
dataset: {
|
|
253
|
+
source: dataset,
|
|
254
|
+
},
|
|
255
|
+
series: [
|
|
256
|
+
{
|
|
257
|
+
type: 'custom',
|
|
258
|
+
name: 'sell-short',
|
|
259
|
+
id: 'sell-short',
|
|
260
|
+
clip: true,
|
|
261
|
+
encode: {
|
|
262
|
+
x: 1,
|
|
263
|
+
y: 0,
|
|
264
|
+
tooltip: 1,
|
|
265
|
+
},
|
|
266
|
+
renderItem: (params, api) => {
|
|
267
|
+
const yValue = api.value(0);
|
|
268
|
+
const xStart = api.coord([api.value(1), yValue]);
|
|
269
|
+
const xEnd = api.coord([0, yValue]);
|
|
270
|
+
const bucketWidthHeight = api.size
|
|
271
|
+
? (api.size([0, bucketWidth]) as number[])[1]
|
|
272
|
+
: 0;
|
|
273
|
+
const height =
|
|
274
|
+
bucketWidthHeight > 4 ? bucketWidthHeight * 0.8 : bucketWidthHeight;
|
|
262
275
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
276
|
+
const rectShape = {
|
|
277
|
+
x: xStart[0] + 0.5,
|
|
278
|
+
y: xStart[1] - height / 2,
|
|
279
|
+
width: xEnd[0] - xStart[0],
|
|
280
|
+
height,
|
|
281
|
+
};
|
|
269
282
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
style: {
|
|
275
|
-
fill: colorPalette.bottleGreenLight,
|
|
276
|
-
},
|
|
277
|
-
},
|
|
283
|
+
return {
|
|
284
|
+
type: 'rect',
|
|
285
|
+
shape: rectShape,
|
|
286
|
+
emphasis: {
|
|
278
287
|
style: {
|
|
279
|
-
fill:
|
|
288
|
+
fill: colorPalette.bottleGreenLight,
|
|
280
289
|
},
|
|
281
|
-
}
|
|
282
|
-
|
|
290
|
+
},
|
|
291
|
+
style: {
|
|
292
|
+
fill: api.visual('color'),
|
|
293
|
+
},
|
|
294
|
+
};
|
|
283
295
|
},
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
type: 'custom',
|
|
299
|
+
name: 'buy-long',
|
|
300
|
+
id: 'buy-long',
|
|
301
|
+
clip: true,
|
|
302
|
+
encode: {
|
|
303
|
+
x: 1,
|
|
304
|
+
y: 0,
|
|
305
|
+
tooltip: 2,
|
|
306
|
+
},
|
|
307
|
+
renderItem: (params, api) => {
|
|
308
|
+
const yValue = api.value(0);
|
|
309
|
+
const xStart = api.coord([api.value(2), yValue]);
|
|
310
|
+
const xEnd = api.coord([0, yValue]);
|
|
311
|
+
const bucketWidthHeight = api.size
|
|
312
|
+
? (api.size([0, bucketWidth]) as number[])[1]
|
|
313
|
+
: 0;
|
|
314
|
+
const height =
|
|
315
|
+
bucketWidthHeight > 4 ? bucketWidthHeight * 0.8 : bucketWidthHeight;
|
|
300
316
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
317
|
+
const rectShape = {
|
|
318
|
+
x: xStart[0] - 0.5,
|
|
319
|
+
y: xStart[1] - height / 2,
|
|
320
|
+
width: xEnd[0] - xStart[0],
|
|
321
|
+
height,
|
|
322
|
+
};
|
|
307
323
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
style: {
|
|
313
|
-
fill: isDark ? colorPalette.orange : colorPalette.raspberryDark,
|
|
314
|
-
},
|
|
315
|
-
},
|
|
324
|
+
return {
|
|
325
|
+
type: 'rect',
|
|
326
|
+
shape: rectShape,
|
|
327
|
+
emphasis: {
|
|
316
328
|
style: {
|
|
317
|
-
fill:
|
|
329
|
+
fill: isDark ? colorPalette.orange : colorPalette.raspberryDark,
|
|
318
330
|
},
|
|
319
|
-
};
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
type: 'custom',
|
|
324
|
-
name: 'current-price',
|
|
325
|
-
id: 'current-price',
|
|
326
|
-
markLine: {
|
|
327
|
-
animation: false,
|
|
328
|
-
silent: true,
|
|
329
|
-
precision,
|
|
330
|
-
symbol: ['none', 'triangle'],
|
|
331
|
-
symbolOffset: [0, [0, isDesktop ? 0 : -10]] as unknown as number,
|
|
332
|
-
symbolRotate: 90,
|
|
333
|
-
symbolSize: [20, 10],
|
|
334
|
-
lineStyle: {
|
|
335
|
-
color: isDark ? colorPalette.orange : colorPalette.bottleGreenDark,
|
|
336
|
-
width: 1,
|
|
337
331
|
},
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
overflow: 'truncate',
|
|
341
|
-
width: isDesktop ? undefined : Y_LABEL_SIZE_MOBILE,
|
|
342
|
-
color: isDark ? colorPalette.black : colorPalette.white,
|
|
343
|
-
backgroundColor: isDark ? colorPalette.orange : colorPalette.bottleGreenDark,
|
|
332
|
+
style: {
|
|
333
|
+
fill: api.visual('color'),
|
|
344
334
|
},
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
335
|
+
};
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
type: 'custom',
|
|
340
|
+
name: 'current-price',
|
|
341
|
+
id: 'current-price',
|
|
342
|
+
markLine: {
|
|
343
|
+
animation: false,
|
|
344
|
+
silent: true,
|
|
345
|
+
precision,
|
|
346
|
+
symbol: ['none', 'triangle'],
|
|
347
|
+
symbolOffset: [0, [0, isDesktop ? 0 : -10]] as unknown as number,
|
|
348
|
+
symbolRotate: 90,
|
|
349
|
+
symbolSize: [20, 10],
|
|
350
|
+
lineStyle: {
|
|
351
|
+
color: isDark ? colorPalette.orange : colorPalette.bottleGreenDark,
|
|
352
|
+
width: 1,
|
|
353
|
+
},
|
|
354
|
+
label: {
|
|
355
|
+
distance: isDesktop ? 5 : -5,
|
|
356
|
+
overflow: 'truncate',
|
|
357
|
+
width: isDesktop ? undefined : Y_LABEL_SIZE_MOBILE,
|
|
358
|
+
color: isDark ? colorPalette.black : colorPalette.white,
|
|
359
|
+
backgroundColor: isDark
|
|
360
|
+
? colorPalette.orange
|
|
361
|
+
: colorPalette.bottleGreenDark,
|
|
350
362
|
},
|
|
351
|
-
|
|
363
|
+
data: [
|
|
364
|
+
{
|
|
365
|
+
yAxis: price,
|
|
366
|
+
},
|
|
367
|
+
],
|
|
352
368
|
},
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
369
|
+
renderItem: () => null,
|
|
370
|
+
},
|
|
371
|
+
],
|
|
372
|
+
};
|
|
356
373
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { EChartsOption } from 'echarts';
|
|
2
|
-
|
|
1
|
+
import type { EChartsOption } from 'echarts';
|
|
2
|
+
|
|
3
|
+
import type { GetOrderPositionBooksQuery } from '../../../gql/types/graphql';
|
|
3
4
|
|
|
4
5
|
export interface ChartProps {
|
|
5
6
|
data: GetOrderPositionBooksQuery;
|
|
@@ -23,15 +24,11 @@ export interface GetOptionProps {
|
|
|
23
24
|
lang: (label: string) => string;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export type GetOptionType = (
|
|
27
|
-
props: GetOptionProps,
|
|
28
|
-
) => EChartsOption;
|
|
27
|
+
export type GetOptionType = (props: GetOptionProps) => EChartsOption;
|
|
29
28
|
|
|
30
|
-
export type TooltipFormatterType = (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
) => string;
|
|
29
|
+
export type TooltipFormatterType = (props: {
|
|
30
|
+
data: number[];
|
|
31
|
+
precision: number;
|
|
32
|
+
isOrderBook: boolean;
|
|
33
|
+
lang: (label: string) => string;
|
|
34
|
+
}) => string;
|
|
@@ -1,67 +1,87 @@
|
|
|
1
1
|
import { BookType } from '../gql/types/graphql';
|
|
2
2
|
import { InstrumentId } from './types';
|
|
3
3
|
|
|
4
|
-
const navigationConfig = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const navigationConfig = [
|
|
5
|
+
{
|
|
6
|
+
id: BookType.Order,
|
|
7
|
+
label: 'order_book',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
id: BookType.Position,
|
|
11
|
+
label: 'position_book',
|
|
12
|
+
},
|
|
13
|
+
];
|
|
11
14
|
|
|
12
|
-
const instrumentSelectConfigOC = [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
15
|
+
const instrumentSelectConfigOC = [
|
|
16
|
+
{
|
|
17
|
+
id: InstrumentId.EUR_AUD,
|
|
18
|
+
label: 'EUR/AUD',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: InstrumentId.EUR_GBP,
|
|
22
|
+
label: 'EUR/GBP',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: InstrumentId.EUR_JPY,
|
|
26
|
+
label: 'EUR/JPY',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: InstrumentId.EUR_USD,
|
|
30
|
+
label: 'EUR/USD',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: InstrumentId.EUR_CHF,
|
|
34
|
+
label: 'EUR/CHF',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: InstrumentId.USD_CHF,
|
|
38
|
+
label: 'USD/CHF',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: InstrumentId.USD_JPY,
|
|
42
|
+
label: 'USD/JPY',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: InstrumentId.USD_CAD,
|
|
46
|
+
label: 'USD/CAD',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: InstrumentId.GBP_USD,
|
|
50
|
+
label: 'GBP/USD',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: InstrumentId.GBP_JPY,
|
|
54
|
+
label: 'GBP/JPY',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: InstrumentId.GBP_CHF,
|
|
58
|
+
label: 'GBP/CHF',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: InstrumentId.AUD_JPY,
|
|
62
|
+
label: 'AUD/JPY',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: InstrumentId.AUD_USD,
|
|
66
|
+
label: 'AUD/USD',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: InstrumentId.NZD_USD,
|
|
70
|
+
label: 'NZD/USD',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
55
73
|
|
|
56
74
|
const instrumentSelectConfig = [
|
|
57
75
|
...instrumentSelectConfigOC,
|
|
58
76
|
{
|
|
59
77
|
id: InstrumentId.XAU_USD,
|
|
60
78
|
label: 'XAU/USD',
|
|
61
|
-
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
62
81
|
id: InstrumentId.XAG_USD,
|
|
63
82
|
label: 'XAG/USD',
|
|
64
|
-
}
|
|
83
|
+
},
|
|
84
|
+
];
|
|
65
85
|
|
|
66
86
|
const instrumentPrecisionConfig: Record<InstrumentId, number> = {
|
|
67
87
|
[InstrumentId.EUR_AUD]: 5,
|
|
@@ -82,5 +102,8 @@ const instrumentPrecisionConfig: Record<InstrumentId, number> = {
|
|
|
82
102
|
[InstrumentId.XAG_USD]: 5,
|
|
83
103
|
};
|
|
84
104
|
export {
|
|
85
|
-
|
|
105
|
+
instrumentPrecisionConfig,
|
|
106
|
+
instrumentSelectConfig,
|
|
107
|
+
instrumentSelectConfigOC,
|
|
108
|
+
navigationConfig,
|
|
86
109
|
};
|