@oanda/labs-order-book-widget 1.0.173 → 1.0.175
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 +1372 -0
- package/dist/main/OrderBookWidget/ChartWithData.js +7 -6
- 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 +3 -3
- package/dist/main/OrderBookWidget/components/Chart/formatters.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/getOption.js +10 -9
- 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 +3 -18
- package/dist/main/gql/getOrderPositionBooks.js.map +1 -1
- package/dist/main/gql/types/fragment-masking.js +3 -2
- package/dist/main/gql/types/fragment-masking.js.map +1 -1
- package/dist/main/gql/types/gql.js +3 -2
- 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 +7 -6
- 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 +3 -3
- package/dist/module/OrderBookWidget/components/Chart/formatters.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/getOption.js +11 -10
- 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 +3 -18
- package/dist/module/gql/getOrderPositionBooks.js.map +1 -1
- package/dist/module/gql/types/fragment-masking.js +3 -2
- package/dist/module/gql/types/fragment-masking.js.map +1 -1
- package/dist/module/gql/types/gql.js +3 -2
- 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,24 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
colorPalette,
|
|
3
|
+
getChartTheme,
|
|
4
|
+
Size,
|
|
5
|
+
Theme,
|
|
6
|
+
useLayoutProvider,
|
|
7
|
+
} from '@oanda/labs-widget-common';
|
|
8
|
+
import { useLocale } from '@oanda/mono-i18n';
|
|
4
9
|
import { CustomChart } from 'echarts/charts';
|
|
5
|
-
import { CanvasRenderer } from 'echarts/renderers';
|
|
6
10
|
import {
|
|
7
|
-
|
|
11
|
+
DatasetComponent,
|
|
12
|
+
DataZoomInsideComponent,
|
|
8
13
|
GraphicComponent,
|
|
9
|
-
|
|
10
|
-
TitleComponent,
|
|
14
|
+
GridSimpleComponent,
|
|
11
15
|
MarkLineComponent,
|
|
16
|
+
TitleComponent,
|
|
12
17
|
ToolboxComponent,
|
|
13
|
-
|
|
14
|
-
DatasetComponent,
|
|
18
|
+
TooltipComponent,
|
|
15
19
|
} from 'echarts/components';
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
import {
|
|
20
|
+
import * as echarts from 'echarts/core';
|
|
21
|
+
import { CanvasRenderer } from 'echarts/renderers';
|
|
22
|
+
import ReactEChartsCore from 'echarts-for-react/lib/core';
|
|
23
|
+
import React, { useEffect, useRef } from 'react';
|
|
24
|
+
|
|
25
|
+
import { getOption, getResponsiveOption } from './getOption';
|
|
26
|
+
import type { ChartProps } from './types';
|
|
22
27
|
|
|
23
28
|
echarts.use([
|
|
24
29
|
GridSimpleComponent,
|
|
@@ -41,16 +46,16 @@ export const Chart = ({ data, isOrderBook, precision }: ChartProps) => {
|
|
|
41
46
|
const { isDark, size } = useLayoutProvider();
|
|
42
47
|
const isDesktop = size === Size.DESKTOP;
|
|
43
48
|
|
|
44
|
-
const echartRef = useRef(null);
|
|
49
|
+
const echartRef = useRef<ReactEChartsCore | null>(null);
|
|
45
50
|
|
|
46
51
|
useEffect(() => {
|
|
47
52
|
if (echartRef.current) {
|
|
48
|
-
|
|
49
|
-
const echartInstance = echartRef.current.getEchartsInstance() as echarts.EChartsType;
|
|
53
|
+
const echartInstance = echartRef.current.getEchartsInstance();
|
|
50
54
|
|
|
51
55
|
echartInstance.on('highlight', () => {
|
|
52
|
-
if (
|
|
53
|
-
echartInstance.getOption().color as echarts.Color[])[0] ===
|
|
56
|
+
if (
|
|
57
|
+
(echartInstance.getOption().color as echarts.Color[])[0] ===
|
|
58
|
+
colorPalette.bottleGreenLight
|
|
54
59
|
) {
|
|
55
60
|
echartInstance.setOption({
|
|
56
61
|
color: [
|
|
@@ -74,13 +79,15 @@ export const Chart = ({ data, isOrderBook, precision }: ChartProps) => {
|
|
|
74
79
|
|
|
75
80
|
useEffect(() => {
|
|
76
81
|
if (echartRef.current) {
|
|
77
|
-
|
|
78
|
-
const echartInstance = echartRef.current.getEchartsInstance() as echarts.EChartsType;
|
|
82
|
+
const echartInstance = echartRef.current.getEchartsInstance();
|
|
79
83
|
|
|
80
84
|
echartInstance.setOption(
|
|
81
85
|
getResponsiveOption({
|
|
82
|
-
isDark,
|
|
83
|
-
|
|
86
|
+
isDark,
|
|
87
|
+
isOrderBook,
|
|
88
|
+
isDesktop,
|
|
89
|
+
lang,
|
|
90
|
+
})
|
|
84
91
|
);
|
|
85
92
|
}
|
|
86
93
|
}, [echartRef, isDesktop, isDark, isOrderBook, lang]);
|
|
@@ -90,16 +97,21 @@ export const Chart = ({ data, isOrderBook, precision }: ChartProps) => {
|
|
|
90
97
|
<div>
|
|
91
98
|
{data && (
|
|
92
99
|
<ReactEChartsCore
|
|
93
|
-
echarts={echarts}
|
|
94
100
|
ref={echartRef}
|
|
95
|
-
|
|
101
|
+
echarts={echarts}
|
|
102
|
+
option={getOption({
|
|
103
|
+
data,
|
|
104
|
+
precision,
|
|
105
|
+
isDark,
|
|
106
|
+
isOrderBook,
|
|
107
|
+
isDesktop,
|
|
108
|
+
lang,
|
|
109
|
+
})}
|
|
96
110
|
style={{
|
|
97
111
|
height: isDesktop ? '450px' : '390px',
|
|
98
112
|
width: '100%',
|
|
99
113
|
}}
|
|
100
|
-
|
|
101
|
-
data, precision, isDark, isOrderBook, isDesktop, lang,
|
|
102
|
-
})}
|
|
114
|
+
theme={isDark ? 'dark_theme' : 'light_theme'}
|
|
103
115
|
/>
|
|
104
116
|
)}
|
|
105
117
|
</div>
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { TooltipFormatterType } from './types';
|
|
1
|
+
import type { TooltipFormatterType } from './types';
|
|
2
2
|
|
|
3
3
|
const tooltipFormatter: TooltipFormatterType = ({
|
|
4
|
-
data,
|
|
4
|
+
data,
|
|
5
|
+
precision,
|
|
6
|
+
isOrderBook,
|
|
7
|
+
lang,
|
|
5
8
|
}) => {
|
|
6
9
|
const priceText = `${lang('price')}: ${data[0].toFixed(precision)}`;
|
|
7
|
-
const buyText = data[1]
|
|
8
|
-
|
|
10
|
+
const buyText = data[1]
|
|
11
|
+
? `<br />${lang(isOrderBook ? 'buy' : 'long_positions')}: ${data[1]}%`
|
|
12
|
+
: '';
|
|
13
|
+
const sellText = data[2]
|
|
14
|
+
? `<br />${lang(isOrderBook ? 'sell' : 'short_positions')}: ${data[2] * -1}%`
|
|
15
|
+
: '';
|
|
9
16
|
|
|
10
17
|
return priceText + buyText + sellText;
|
|
11
18
|
};
|
|
@@ -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;
|