@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.
Files changed (99) hide show
  1. package/CHANGELOG.md +1372 -0
  2. package/dist/main/OrderBookWidget/ChartWithData.js +7 -6
  3. package/dist/main/OrderBookWidget/ChartWithData.js.map +1 -1
  4. package/dist/main/OrderBookWidget/Main.js +11 -11
  5. package/dist/main/OrderBookWidget/Main.js.map +1 -1
  6. package/dist/main/OrderBookWidget/OrderBookWidget.js +9 -9
  7. package/dist/main/OrderBookWidget/OrderBookWidget.js.map +1 -1
  8. package/dist/main/OrderBookWidget/components/Chart/Chart.js +14 -14
  9. package/dist/main/OrderBookWidget/components/Chart/Chart.js.map +1 -1
  10. package/dist/main/OrderBookWidget/components/Chart/formatters.js +3 -3
  11. package/dist/main/OrderBookWidget/components/Chart/formatters.js.map +1 -1
  12. package/dist/main/OrderBookWidget/components/Chart/getOption.js +10 -9
  13. package/dist/main/OrderBookWidget/components/Chart/getOption.js.map +1 -1
  14. package/dist/main/OrderBookWidget/components/Chart/types.js.map +1 -1
  15. package/dist/main/OrderBookWidget/config.js.map +1 -1
  16. package/dist/main/OrderBookWidget/render.js +9 -9
  17. package/dist/main/OrderBookWidget/render.js.map +1 -1
  18. package/dist/main/OrderBookWidget/types.js.map +1 -1
  19. package/dist/main/gql/getOrderPositionBooks.js +3 -18
  20. package/dist/main/gql/getOrderPositionBooks.js.map +1 -1
  21. package/dist/main/gql/types/fragment-masking.js +3 -2
  22. package/dist/main/gql/types/fragment-masking.js.map +1 -1
  23. package/dist/main/gql/types/gql.js +3 -2
  24. package/dist/main/gql/types/gql.js.map +1 -1
  25. package/dist/main/gql/types/graphql.js +114 -114
  26. package/dist/main/gql/types/graphql.js.map +1 -1
  27. package/dist/main/gql/types/index.js.map +1 -1
  28. package/dist/main/index.js +8 -8
  29. package/dist/main/index.js.map +1 -1
  30. package/dist/main/translations/index.js +1 -1
  31. package/dist/main/translations/index.js.map +1 -1
  32. package/dist/main/translations/translations.js.map +1 -1
  33. package/dist/module/OrderBookWidget/ChartWithData.js +7 -6
  34. package/dist/module/OrderBookWidget/ChartWithData.js.map +1 -1
  35. package/dist/module/OrderBookWidget/Main.js +10 -10
  36. package/dist/module/OrderBookWidget/Main.js.map +1 -1
  37. package/dist/module/OrderBookWidget/OrderBookWidget.js +9 -9
  38. package/dist/module/OrderBookWidget/OrderBookWidget.js.map +1 -1
  39. package/dist/module/OrderBookWidget/components/Chart/Chart.js +14 -14
  40. package/dist/module/OrderBookWidget/components/Chart/Chart.js.map +1 -1
  41. package/dist/module/OrderBookWidget/components/Chart/formatters.js +3 -3
  42. package/dist/module/OrderBookWidget/components/Chart/formatters.js.map +1 -1
  43. package/dist/module/OrderBookWidget/components/Chart/getOption.js +11 -10
  44. package/dist/module/OrderBookWidget/components/Chart/getOption.js.map +1 -1
  45. package/dist/module/OrderBookWidget/components/Chart/types.js.map +1 -1
  46. package/dist/module/OrderBookWidget/config.js +1 -1
  47. package/dist/module/OrderBookWidget/config.js.map +1 -1
  48. package/dist/module/OrderBookWidget/render.js +10 -10
  49. package/dist/module/OrderBookWidget/render.js.map +1 -1
  50. package/dist/module/OrderBookWidget/types.js.map +1 -1
  51. package/dist/module/gql/getOrderPositionBooks.js +3 -18
  52. package/dist/module/gql/getOrderPositionBooks.js.map +1 -1
  53. package/dist/module/gql/types/fragment-masking.js +3 -2
  54. package/dist/module/gql/types/fragment-masking.js.map +1 -1
  55. package/dist/module/gql/types/gql.js +3 -2
  56. package/dist/module/gql/types/gql.js.map +1 -1
  57. package/dist/module/gql/types/graphql.js +114 -114
  58. package/dist/module/gql/types/graphql.js.map +1 -1
  59. package/dist/module/gql/types/index.js +2 -2
  60. package/dist/module/gql/types/index.js.map +1 -1
  61. package/dist/module/index.js +1 -1
  62. package/dist/module/index.js.map +1 -1
  63. package/dist/module/translations/index.js +1 -1
  64. package/dist/module/translations/index.js.map +1 -1
  65. package/dist/module/translations/translations.js.map +1 -1
  66. package/dist/types/OrderBookWidget/ChartWithData.d.ts +2 -2
  67. package/dist/types/OrderBookWidget/Main.d.ts +1 -1
  68. package/dist/types/OrderBookWidget/OrderBookWidget.d.ts +1 -1
  69. package/dist/types/OrderBookWidget/components/Chart/Chart.d.ts +1 -1
  70. package/dist/types/OrderBookWidget/components/Chart/formatters.d.ts +1 -1
  71. package/dist/types/OrderBookWidget/components/Chart/getOption.d.ts +1 -1
  72. package/dist/types/OrderBookWidget/components/Chart/types.d.ts +2 -2
  73. package/dist/types/OrderBookWidget/config.d.ts +1 -1
  74. package/dist/types/OrderBookWidget/types.d.ts +2 -2
  75. package/dist/types/gql/types/gql.d.ts +2 -2
  76. package/dist/types/gql/types/index.d.ts +2 -2
  77. package/dist/types/index.d.ts +1 -1
  78. package/dist/types/translations/index.d.ts +2 -2
  79. package/package.json +3 -3
  80. package/src/OrderBookWidget/ChartWithData.tsx +40 -39
  81. package/src/OrderBookWidget/Main.tsx +48 -30
  82. package/src/OrderBookWidget/OrderBookWidget.tsx +8 -8
  83. package/src/OrderBookWidget/components/Chart/Chart.tsx +41 -29
  84. package/src/OrderBookWidget/components/Chart/formatters.ts +11 -4
  85. package/src/OrderBookWidget/components/Chart/getOption.ts +205 -188
  86. package/src/OrderBookWidget/components/Chart/types.ts +10 -13
  87. package/src/OrderBookWidget/config.ts +76 -53
  88. package/src/OrderBookWidget/render.tsx +81 -52
  89. package/src/OrderBookWidget/types.ts +3 -2
  90. package/src/gql/getOrderPositionBooks.ts +5 -1
  91. package/src/gql/types/fragment-masking.ts +41 -21
  92. package/src/gql/types/gql.ts +7 -3
  93. package/src/gql/types/graphql.ts +165 -44
  94. package/src/gql/types/index.ts +2 -2
  95. package/src/index.ts +1 -1
  96. package/src/translations/index.ts +4 -4
  97. package/src/translations/translations.ts +1 -3
  98. package/test/Main.test.tsx +12 -9
  99. package/test/chartOptions.test.ts +18 -12
@@ -1,24 +1,29 @@
1
- import React, { useRef, useEffect } from 'react';
2
- import ReactEChartsCore from 'echarts-for-react/lib/core';
3
- import * as echarts from 'echarts/core';
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
- GridSimpleComponent,
11
+ DatasetComponent,
12
+ DataZoomInsideComponent,
8
13
  GraphicComponent,
9
- TooltipComponent,
10
- TitleComponent,
14
+ GridSimpleComponent,
11
15
  MarkLineComponent,
16
+ TitleComponent,
12
17
  ToolboxComponent,
13
- DataZoomInsideComponent,
14
- DatasetComponent,
18
+ TooltipComponent,
15
19
  } from 'echarts/components';
16
- import {
17
- Theme, useLayoutProvider, colorPalette, getChartTheme, Size,
18
- } from '@oanda/labs-widget-common';
19
- import { useLocale } from '@oanda/mono-i18n';
20
- import { getResponsiveOption, getOption } from './getOption';
21
- import { ChartProps } from './types';
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
- // @ts-ignore
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] === colorPalette.bottleGreenLight
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
- // @ts-ignore
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, isOrderBook, isDesktop, lang,
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
- theme={isDark ? 'dark_theme' : 'light_theme'}
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
- option={getOption({
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, precision, isOrderBook, lang,
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] ? `<br />${lang(isOrderBook ? 'buy' : 'long_positions')}: ${data[1]}%` : '';
8
- const sellText = data[2] ? `<br />${lang(isOrderBook ? 'sell' : 'short_positions')}: ${data[2] * -1}%` : '';
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
- INITIAL_BARS,
4
- CHART_WIDTH,
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
- isDark, isOrderBook, isDesktop, lang,
18
- }
19
- : GetResponsiveOptionsProps,
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, precision, isDark, isOrderBook, isDesktop, lang,
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 - (bucketWidth * INITIAL_BARS * 0.5);
153
- const zoomInitialEndValue = price + (bucketWidth * INITIAL_BARS * 0.5);
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
- animation: false,
163
- color: [
164
- colorPalette.bottleGreenLight,
165
- isDark ? colorPalette.orange : colorPalette.raspberryDark,
166
- ],
167
- title: {
168
- text: lang(isOrderBook ? 'open_orders' : 'open_positions').toUpperCase(),
169
- padding: 20,
170
- textStyle: {
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
- dataZoom: [
181
- {
182
- type: 'inside',
183
- realtime: true,
184
- startValue: zoomInitialStartValue,
185
- endValue: zoomInitialEndValue,
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
- yAxisIndex: 0,
188
- minValueSpan: 10 * bucketWidth,
189
- },
190
- ],
191
- tooltip: {
192
- trigger: 'axis',
193
- axisPointer: {
194
- axis: 'y',
195
- },
196
- formatter: (val) => tooltipFormatter({
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
- extraCssText: 'z-index: 1',
203
- },
204
- grid: [
205
- {
206
- name: 'main-grid',
207
- top: '48px',
208
- left: '0px',
209
- right: `${isDesktop ? Y_LABEL_SIZE_DESKTOP : Y_LABEL_SIZE_MOBILE}px`,
210
- bottom: `${isDesktop ? X_LABEL_SIZE : X_LABEL_SIZE + ZOOM_CONTROL_HEIGHT}px`,
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
- yAxis: {
228
- type: 'value',
229
- position: 'right',
230
- axisLine: { show: false },
231
- axisTick: { show: false },
232
- axisLabel: {
233
- overflow: 'truncate',
234
- width: (isDesktop ? Y_LABEL_SIZE_DESKTOP : Y_LABEL_SIZE_MOBILE) - 10,
235
- margin: isDesktop ? 10 : 0,
236
- showMaxLabel: false,
237
- showMinLabel: false,
238
- padding: [0, 0, 0, 10],
239
- formatter: (value) => value.toFixed(bucketPrecision),
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
- dataset: {
243
- source: dataset,
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
- series: [
246
- {
247
- type: 'custom',
248
- name: 'sell-short',
249
- id: 'sell-short',
250
- clip: true,
251
- encode: {
252
- x: 1,
253
- y: 0,
254
- tooltip: 1,
255
- },
256
- renderItem: (params, api) => {
257
- const yValue = api.value(0);
258
- const xStart = api.coord([api.value(1), yValue]);
259
- const xEnd = api.coord([0, yValue]);
260
- const bucketWidthHeight = api.size ? (api.size([0, bucketWidth]) as number[])[1] : 0;
261
- const height = bucketWidthHeight > 4 ? bucketWidthHeight * 0.8 : bucketWidthHeight;
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
- const rectShape = {
264
- x: xStart[0] + 0.5,
265
- y: xStart[1] - height / 2,
266
- width: xEnd[0] - xStart[0],
267
- height,
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
- return {
271
- type: 'rect',
272
- shape: rectShape,
273
- emphasis: {
274
- style: {
275
- fill: colorPalette.bottleGreenLight,
276
- },
277
- },
283
+ return {
284
+ type: 'rect',
285
+ shape: rectShape,
286
+ emphasis: {
278
287
  style: {
279
- fill: api.visual('color'),
288
+ fill: colorPalette.bottleGreenLight,
280
289
  },
281
- };
282
- },
290
+ },
291
+ style: {
292
+ fill: api.visual('color'),
293
+ },
294
+ };
283
295
  },
284
- {
285
- type: 'custom',
286
- name: 'buy-long',
287
- id: 'buy-long',
288
- clip: true,
289
- encode: {
290
- x: 1,
291
- y: 0,
292
- tooltip: 2,
293
- },
294
- renderItem: (params, api) => {
295
- const yValue = api.value(0);
296
- const xStart = api.coord([api.value(2), yValue]);
297
- const xEnd = api.coord([0, yValue]);
298
- const bucketWidthHeight = api.size ? (api.size([0, bucketWidth]) as number[])[1] : 0;
299
- const height = bucketWidthHeight > 4 ? bucketWidthHeight * 0.8 : bucketWidthHeight;
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
- const rectShape = {
302
- x: xStart[0] - 0.5,
303
- y: xStart[1] - height / 2,
304
- width: xEnd[0] - xStart[0],
305
- height,
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
- return {
309
- type: 'rect',
310
- shape: rectShape,
311
- emphasis: {
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: api.visual('color'),
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
- label: {
339
- distance: isDesktop ? 5 : -5,
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
- data: [
346
- {
347
- yAxis: price,
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
- renderItem: () => null,
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
- import { GetOrderPositionBooksQuery } from '../../../gql/types/graphql';
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
- props : {
32
- data: number[],
33
- precision: number,
34
- isOrderBook: boolean,
35
- lang: (label: string) => string;
36
- }
37
- ) => string;
29
+ export type TooltipFormatterType = (props: {
30
+ data: number[];
31
+ precision: number;
32
+ isOrderBook: boolean;
33
+ lang: (label: string) => string;
34
+ }) => string;