@oanda/labs-order-book-widget 1.0.62 → 1.0.64
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 +484 -0
- package/dist/main/OrderBookWidget/OrderBookWidget.js +6 -3
- package/dist/main/OrderBookWidget/OrderBookWidget.js.map +1 -1
- package/dist/main/OrderBookWidget/Widget.js +12 -14
- package/dist/main/OrderBookWidget/Widget.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/Chart.js +49 -14
- package/dist/main/OrderBookWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/constants.js +7 -3
- package/dist/main/OrderBookWidget/components/Chart/constants.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/formatters.js +14 -0
- package/dist/main/OrderBookWidget/components/Chart/formatters.js.map +1 -0
- package/dist/main/OrderBookWidget/components/Chart/getOption.js +274 -0
- package/dist/main/OrderBookWidget/components/Chart/getOption.js.map +1 -0
- package/dist/main/OrderBookWidget/components/Chart/types.js +6 -0
- package/dist/main/OrderBookWidget/components/Chart/types.js.map +1 -0
- package/dist/main/OrderBookWidget/config.js +15 -0
- package/dist/main/OrderBookWidget/config.js.map +1 -0
- package/dist/main/OrderBookWidget/render.js +31 -10
- package/dist/main/OrderBookWidget/render.js.map +1 -1
- package/dist/main/OrderBookWidget/types.js.map +1 -1
- package/dist/module/OrderBookWidget/OrderBookWidget.js +7 -4
- package/dist/module/OrderBookWidget/OrderBookWidget.js.map +1 -1
- package/dist/module/OrderBookWidget/Widget.js +13 -15
- package/dist/module/OrderBookWidget/Widget.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/Chart.js +47 -14
- package/dist/module/OrderBookWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/constants.js +6 -2
- package/dist/module/OrderBookWidget/components/Chart/constants.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/formatters.js +8 -0
- package/dist/module/OrderBookWidget/components/Chart/formatters.js.map +1 -0
- package/dist/module/OrderBookWidget/components/Chart/getOption.js +266 -0
- package/dist/module/OrderBookWidget/components/Chart/getOption.js.map +1 -0
- package/dist/module/OrderBookWidget/components/Chart/types.js +2 -0
- package/dist/module/OrderBookWidget/components/Chart/types.js.map +1 -0
- package/dist/module/OrderBookWidget/config.js +10 -0
- package/dist/module/OrderBookWidget/config.js.map +1 -0
- package/dist/module/OrderBookWidget/render.js +31 -10
- package/dist/module/OrderBookWidget/render.js.map +1 -1
- package/dist/module/OrderBookWidget/types.js.map +1 -1
- package/dist/types/OrderBookWidget/OrderBookWidget.d.ts +1 -1
- package/dist/types/OrderBookWidget/components/Chart/Chart.d.ts +2 -6
- package/dist/types/OrderBookWidget/components/Chart/constants.d.ts +6 -2
- package/dist/types/OrderBookWidget/components/Chart/formatters.d.ts +3 -0
- package/dist/types/OrderBookWidget/components/Chart/getOption.d.ts +174 -0
- package/dist/types/OrderBookWidget/components/Chart/types.d.ts +18 -0
- package/dist/types/OrderBookWidget/config.d.ts +6 -0
- package/dist/types/OrderBookWidget/render.d.ts +1 -6
- package/dist/types/OrderBookWidget/types.d.ts +2 -0
- package/package.json +3 -3
- package/src/OrderBookWidget/OrderBookWidget.tsx +9 -6
- package/src/OrderBookWidget/Widget.tsx +12 -21
- package/src/OrderBookWidget/components/Chart/Chart.tsx +56 -18
- package/src/OrderBookWidget/components/Chart/constants.ts +7 -2
- package/src/OrderBookWidget/components/Chart/formatters.ts +11 -0
- package/src/OrderBookWidget/components/Chart/getOption.ts +296 -0
- package/src/OrderBookWidget/components/Chart/types.ts +29 -0
- package/src/OrderBookWidget/config.ts +11 -0
- package/src/OrderBookWidget/render.tsx +36 -18
- package/src/OrderBookWidget/types.ts +2 -0
- package/dist/main/OrderBookWidget/components/Chart/getOptions.js +0 -322
- package/dist/main/OrderBookWidget/components/Chart/getOptions.js.map +0 -1
- package/dist/module/OrderBookWidget/components/Chart/getOptions.js +0 -315
- package/dist/module/OrderBookWidget/components/Chart/getOptions.js.map +0 -1
- package/dist/types/OrderBookWidget/components/Chart/getOptions.d.ts +0 -6
- package/src/OrderBookWidget/components/Chart/getOptions.ts +0 -361
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getOptions.js","names":["chartSharedOptions","ZOOM_BARS","INITIAL_BARS","getOptions","_ref","data","price","bucketWidth","toolbox","itemSize","itemGap","bottom","right","showTitle","iconStyle","borderColor","emphasis","tooltip","show","backgroundColor","formatter","val","title","position","confine","textStyle","color","feature","myZoomIn","icon","icons","zoomInIcon","onclick","model","instance","startValue","endValue","option","dataZoom","halfZoomValue","dispatchAction","type","myZoomOut","zoomOutIcon","myResetZoom","resetZoomIcon","realtime","yAxisIndex","dataset","source","trigger","borderRadius","shadowBlur","shadowOffsetX","shadowOffsetY","shadowColor","params","values","concat","Math","abs","axisPointer","axis","grid","top","left","width","height","graphic","silent","children","z","shape","style","fill","text","yAxis","axisLine","axisTick","splitLine","lineStyle","axisLabel","padding","rich","a","value","index","xAxis","min","max","showMinLabel","showMaxLabel","series","encode","x","y","itemStyle","renderItem","api","yValue","xStart","coord","xEnd","bucketWidthHeight","size","rectShape","markLine","animation","precision","symbol","symbolRotate","symbolSize","label"],"sources":["../../../../../src/OrderBookWidget/components/Chart/getOptions.ts"],"sourcesContent":["import { EChartsOption, Model, EChartsType } from 'echarts';\nimport { chartSharedOptions } from '@oanda/labs-widget-common';\nimport { ZOOM_BARS, INITIAL_BARS } from './constants';\n\nexport const getOptions = (\n {\n data,\n price,\n bucketWidth,\n } :\n {\n data: number[][],\n price: number,\n bucketWidth: number\n },\n): EChartsOption => (\n {\n toolbox: {\n itemSize: 18,\n itemGap: 14,\n bottom: 6,\n right: 6,\n showTitle: false,\n iconStyle: {\n borderColor: '#00214A',\n },\n emphasis: {\n iconStyle: {\n borderColor: '#008573',\n },\n },\n tooltip: {\n show: true,\n backgroundColor: '#00214A',\n formatter: (val) => val.title,\n position: 'top',\n confine: true,\n textStyle: {\n color: '#fff',\n },\n },\n feature: {\n myZoomIn: {\n show: true,\n title: 'Zoom in',\n icon: chartSharedOptions.icons.zoomInIcon,\n onclick: (model: Model, instance: EChartsType) => {\n const { startValue, endValue } = model.option.dataZoom[0];\n // @todo handle zoom with minimal step\n const halfZoomValue = 0.5 * ZOOM_BARS * bucketWidth;\n\n instance.dispatchAction({\n type: 'dataZoom',\n startValue: startValue + halfZoomValue,\n endValue: endValue - halfZoomValue,\n });\n },\n },\n myZoomOut: {\n show: true,\n title: 'Zoom out',\n icon: chartSharedOptions.icons.zoomOutIcon,\n onclick: (model: Model, instance: EChartsType) => {\n const { startValue, endValue } = model.option.dataZoom[0];\n // @todo handle zoom with full chart range\n const halfZoomValue = 0.5 * ZOOM_BARS * bucketWidth;\n\n instance.dispatchAction({\n type: 'dataZoom',\n startValue: startValue - halfZoomValue,\n endValue: endValue + halfZoomValue,\n });\n },\n },\n myResetZoom: {\n show: true,\n title: 'ResetZoom',\n icon: chartSharedOptions.icons.resetZoomIcon,\n onclick: (model: Model, instance: EChartsType) => {\n instance.dispatchAction({\n type: 'dataZoom',\n startValue: price - (bucketWidth * INITIAL_BARS * 0.5),\n endValue: price + (bucketWidth * INITIAL_BARS * 0.5),\n });\n },\n },\n },\n },\n dataZoom: [\n {\n type: 'inside',\n realtime: true,\n startValue: price - (bucketWidth * INITIAL_BARS * 0.5),\n endValue: price + (bucketWidth * INITIAL_BARS * 0.5),\n yAxisIndex: 0,\n // @todo\n // minSpan: 2,\n },\n ],\n dataset: {\n source: data,\n },\n textStyle: {\n // @todo, broken due dark mode\n // ...chartSharedOptions.textStyle,\n },\n tooltip: {\n trigger: 'axis',\n borderRadius: 0,\n shadowBlur: 24,\n shadowOffsetX: 0,\n shadowOffsetY: 6,\n shadowColor: 'rgba(0,0,0,0.1)',\n textStyle: {\n // @todo, broken due dark mode\n // ...chartSharedOptions.textStyle,\n },\n formatter: (params) => {\n const values = (params as { data: number[] }[])[0].data;\n return `Price: ${values[0]}<br />Buy: ${values[1]}%<br/>Sell: ${Math.abs(values[2])}%`;\n },\n axisPointer: {\n axis: 'y',\n },\n },\n grid: [\n {\n top: '1px',\n left: '1px',\n right: '121px',\n bottom: '41px',\n // @todo, broken due dark mode\n // borderColor: chartSharedOptions.colors.axis,\n show: true,\n },\n {\n bottom: '1px',\n right: '1px',\n width: '120px',\n height: '40px',\n // @todo, broken due dark mode\n // borderColor: chartSharedOptions.colors.axis,\n show: true,\n },\n {\n top: '1px',\n left: '1px',\n right: '1px',\n bottom: '1px',\n // @todo, broken due dark mode\n // borderColor: chartSharedOptions.colors.axis,\n show: true,\n },\n ],\n graphic: [\n {\n type: 'group',\n left: '8px',\n top: '8px',\n silent: true,\n children: [\n {\n type: 'rect',\n z: 100,\n left: 'center',\n top: 'middle',\n shape: {\n width: 60,\n height: 30,\n },\n style: {\n fill: '#fff',\n shadowBlur: 8,\n shadowOffsetX: 0,\n shadowOffsetY: 1,\n shadowColor: 'rgba(0,0,0,0.1)',\n },\n },\n {\n type: 'text',\n z: 100,\n left: 'center',\n top: 'middle',\n style: {\n width: 60,\n height: 30,\n // @todo\n text: 'Sell',\n },\n },\n ],\n },\n {\n type: 'group',\n right: '128px',\n top: '8px',\n silent: true,\n children: [\n {\n type: 'rect',\n z: 100,\n right: 'center',\n top: 'middle',\n shape: {\n width: 60,\n height: 30,\n },\n style: {\n fill: '#fff',\n shadowBlur: 8,\n shadowOffsetX: 0,\n shadowOffsetY: 1,\n shadowColor: 'rgba(0,0,0,0.1)',\n },\n },\n {\n type: 'text',\n z: 100,\n right: 'center',\n top: 'middle',\n style: {\n width: 60,\n height: 30,\n // @todo\n text: 'Buy',\n },\n },\n ],\n },\n ],\n yAxis: {\n type: 'value',\n position: 'right',\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n lineStyle: {\n // @todo, broken due dark mode\n // color: chartSharedOptions.colors.axis,\n },\n },\n axisLabel: {\n padding: [0, 0, 0, 10],\n rich: {\n a: {\n padding: [0, 0, 16, 0],\n },\n },\n // @todo add decimal places\n formatter: (value, index) => (index ? `${value}` : `{a|${value}}`),\n },\n },\n xAxis: {\n type: 'value',\n // @todo\n min: -1.1,\n max: 1.1,\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n lineStyle: {\n // @todo, broken due dark mode\n // color: chartSharedOptions.colors.axis,\n },\n },\n axisLabel: {\n padding: [7, 0, 0, 0],\n showMinLabel: false,\n showMaxLabel: false,\n formatter: (value) => (value === 0 ? '%' : `${Math.abs(value)}%`),\n },\n },\n series: [\n {\n type: 'custom',\n encode: {\n x: 1,\n y: 0,\n tooltip: 1,\n },\n itemStyle: {\n color: '#00B89E',\n },\n renderItem: (params, api) => {\n const yValue = api.value(0);\n const xStart = api.coord([api.value(1), yValue]);\n const xEnd = api.coord([0, yValue]);\n const bucketWidthHeight = api.size ? (api.size([0, bucketWidth]) as number[])[1] : 0;\n const height = bucketWidthHeight > 4 ? bucketWidthHeight * 0.8 : bucketWidthHeight;\n\n const rectShape = {\n x: xStart[0] + 0.5,\n y: xStart[1] - height / 2,\n width: xEnd[0] - xStart[0],\n height,\n };\n\n return {\n type: 'rect',\n shape: rectShape,\n style: api.style(),\n };\n },\n },\n {\n type: 'custom',\n encode: {\n x: 1,\n y: 0,\n tooltip: 2,\n },\n markLine: {\n animation: false,\n silent: true,\n // @todo confirm precision\n precision: 4,\n symbol: ['none', 'triangle'],\n symbolRotate: 90,\n symbolSize: [20, 10],\n lineStyle: {\n color: '#008573',\n width: 1,\n },\n label: {\n padding: [5, 15, 5, 15],\n color: '#fff',\n backgroundColor: '#008573',\n },\n data: [\n {\n yAxis: price,\n },\n ],\n },\n itemStyle: {\n color: '#E5226E',\n },\n renderItem: (params, api) => {\n const yValue = api.value(0);\n const xStart = api.coord([api.value(2), yValue]);\n const xEnd = api.coord([0, yValue]);\n const bucketWidthHeight = api.size ? (api.size([0, bucketWidth]) as number[])[1] : 0;\n const height = bucketWidthHeight > 4 ? bucketWidthHeight * 0.8 : bucketWidthHeight;\n\n const rectShape = {\n x: xStart[0] - 0.5,\n y: xStart[1] - height / 2,\n width: xEnd[0] - xStart[0],\n height,\n };\n\n return {\n type: 'rect',\n shape: rectShape,\n style: api.style(),\n };\n },\n },\n ],\n }\n);\n"],"mappings":"AACA,SAASA,kBAAkB,QAAQ,2BAA2B;AAC9D,SAASC,SAAS,EAAEC,YAAY,QAAQ,aAAa;AAErD,OAAO,MAAMC,UAAU,GAAGC,IAAA;EAAA,IACxB;IACEC,IAAI;IACJC,KAAK;IACLC;EAMF,CAAC,GAAAH,IAAA;EAAA,OAED;IACEI,OAAO,EAAE;MACPC,QAAQ,EAAE,EAAE;MACZC,OAAO,EAAE,EAAE;MACXC,MAAM,EAAE,CAAC;MACTC,KAAK,EAAE,CAAC;MACRC,SAAS,EAAE,KAAK;MAChBC,SAAS,EAAE;QACTC,WAAW,EAAE;MACf,CAAC;MACDC,QAAQ,EAAE;QACRF,SAAS,EAAE;UACTC,WAAW,EAAE;QACf;MACF,CAAC;MACDE,OAAO,EAAE;QACPC,IAAI,EAAE,IAAI;QACVC,eAAe,EAAE,SAAS;QAC1BC,SAAS,EAAGC,GAAG,IAAKA,GAAG,CAACC,KAAK;QAC7BC,QAAQ,EAAE,KAAK;QACfC,OAAO,EAAE,IAAI;QACbC,SAAS,EAAE;UACTC,KAAK,EAAE;QACT;MACF,CAAC;MACDC,OAAO,EAAE;QACPC,QAAQ,EAAE;UACRV,IAAI,EAAE,IAAI;UACVI,KAAK,EAAE,SAAS;UAChBO,IAAI,EAAE7B,kBAAkB,CAAC8B,KAAK,CAACC,UAAU;UACzCC,OAAO,EAAEA,CAACC,KAAY,EAAEC,QAAqB,KAAK;YAChD,MAAM;cAAEC,UAAU;cAAEC;YAAS,CAAC,GAAGH,KAAK,CAACI,MAAM,CAACC,QAAQ,CAAC,CAAC,CAAC;YAEzD,MAAMC,aAAa,GAAG,GAAG,GAAGtC,SAAS,GAAGM,WAAW;YAEnD2B,QAAQ,CAACM,cAAc,CAAC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C,MAAM,GAAG,CAAC;UACzBD,KAAK,EAAEoC,IAAI,CAAC,CAAC,CAAC,GAAGF,MAAM,CAAC,CAAC,CAAC;UAC1BjC;QACF,CAAC;QAED,OAAO;UACL1B,IAAI,EAAE,MAAM;UACZ+B,KAAK,EAAEiC,SAAS;UAChBhC,KAAK,EAAEyB,GAAG,CAACzB,KAAK,CAAC;QACnB,CAAC;MACH;IACF,CAAC;EAEL,CAAC;AAAA,CACF"}
|
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import { EChartsOption, Model, EChartsType } from 'echarts';
|
|
2
|
-
import { chartSharedOptions } from '@oanda/labs-widget-common';
|
|
3
|
-
import { ZOOM_BARS, INITIAL_BARS } from './constants';
|
|
4
|
-
|
|
5
|
-
export const getOptions = (
|
|
6
|
-
{
|
|
7
|
-
data,
|
|
8
|
-
price,
|
|
9
|
-
bucketWidth,
|
|
10
|
-
} :
|
|
11
|
-
{
|
|
12
|
-
data: number[][],
|
|
13
|
-
price: number,
|
|
14
|
-
bucketWidth: number
|
|
15
|
-
},
|
|
16
|
-
): EChartsOption => (
|
|
17
|
-
{
|
|
18
|
-
toolbox: {
|
|
19
|
-
itemSize: 18,
|
|
20
|
-
itemGap: 14,
|
|
21
|
-
bottom: 6,
|
|
22
|
-
right: 6,
|
|
23
|
-
showTitle: false,
|
|
24
|
-
iconStyle: {
|
|
25
|
-
borderColor: '#00214A',
|
|
26
|
-
},
|
|
27
|
-
emphasis: {
|
|
28
|
-
iconStyle: {
|
|
29
|
-
borderColor: '#008573',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
tooltip: {
|
|
33
|
-
show: true,
|
|
34
|
-
backgroundColor: '#00214A',
|
|
35
|
-
formatter: (val) => val.title,
|
|
36
|
-
position: 'top',
|
|
37
|
-
confine: true,
|
|
38
|
-
textStyle: {
|
|
39
|
-
color: '#fff',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
feature: {
|
|
43
|
-
myZoomIn: {
|
|
44
|
-
show: true,
|
|
45
|
-
title: 'Zoom in',
|
|
46
|
-
icon: chartSharedOptions.icons.zoomInIcon,
|
|
47
|
-
onclick: (model: Model, instance: EChartsType) => {
|
|
48
|
-
const { startValue, endValue } = model.option.dataZoom[0];
|
|
49
|
-
// @todo handle zoom with minimal step
|
|
50
|
-
const halfZoomValue = 0.5 * ZOOM_BARS * bucketWidth;
|
|
51
|
-
|
|
52
|
-
instance.dispatchAction({
|
|
53
|
-
type: 'dataZoom',
|
|
54
|
-
startValue: startValue + halfZoomValue,
|
|
55
|
-
endValue: endValue - halfZoomValue,
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
myZoomOut: {
|
|
60
|
-
show: true,
|
|
61
|
-
title: 'Zoom out',
|
|
62
|
-
icon: chartSharedOptions.icons.zoomOutIcon,
|
|
63
|
-
onclick: (model: Model, instance: EChartsType) => {
|
|
64
|
-
const { startValue, endValue } = model.option.dataZoom[0];
|
|
65
|
-
// @todo handle zoom with full chart range
|
|
66
|
-
const halfZoomValue = 0.5 * ZOOM_BARS * bucketWidth;
|
|
67
|
-
|
|
68
|
-
instance.dispatchAction({
|
|
69
|
-
type: 'dataZoom',
|
|
70
|
-
startValue: startValue - halfZoomValue,
|
|
71
|
-
endValue: endValue + halfZoomValue,
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
myResetZoom: {
|
|
76
|
-
show: true,
|
|
77
|
-
title: 'ResetZoom',
|
|
78
|
-
icon: chartSharedOptions.icons.resetZoomIcon,
|
|
79
|
-
onclick: (model: Model, instance: EChartsType) => {
|
|
80
|
-
instance.dispatchAction({
|
|
81
|
-
type: 'dataZoom',
|
|
82
|
-
startValue: price - (bucketWidth * INITIAL_BARS * 0.5),
|
|
83
|
-
endValue: price + (bucketWidth * INITIAL_BARS * 0.5),
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
dataZoom: [
|
|
90
|
-
{
|
|
91
|
-
type: 'inside',
|
|
92
|
-
realtime: true,
|
|
93
|
-
startValue: price - (bucketWidth * INITIAL_BARS * 0.5),
|
|
94
|
-
endValue: price + (bucketWidth * INITIAL_BARS * 0.5),
|
|
95
|
-
yAxisIndex: 0,
|
|
96
|
-
// @todo
|
|
97
|
-
// minSpan: 2,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
dataset: {
|
|
101
|
-
source: data,
|
|
102
|
-
},
|
|
103
|
-
textStyle: {
|
|
104
|
-
// @todo, broken due dark mode
|
|
105
|
-
// ...chartSharedOptions.textStyle,
|
|
106
|
-
},
|
|
107
|
-
tooltip: {
|
|
108
|
-
trigger: 'axis',
|
|
109
|
-
borderRadius: 0,
|
|
110
|
-
shadowBlur: 24,
|
|
111
|
-
shadowOffsetX: 0,
|
|
112
|
-
shadowOffsetY: 6,
|
|
113
|
-
shadowColor: 'rgba(0,0,0,0.1)',
|
|
114
|
-
textStyle: {
|
|
115
|
-
// @todo, broken due dark mode
|
|
116
|
-
// ...chartSharedOptions.textStyle,
|
|
117
|
-
},
|
|
118
|
-
formatter: (params) => {
|
|
119
|
-
const values = (params as { data: number[] }[])[0].data;
|
|
120
|
-
return `Price: ${values[0]}<br />Buy: ${values[1]}%<br/>Sell: ${Math.abs(values[2])}%`;
|
|
121
|
-
},
|
|
122
|
-
axisPointer: {
|
|
123
|
-
axis: 'y',
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
grid: [
|
|
127
|
-
{
|
|
128
|
-
top: '1px',
|
|
129
|
-
left: '1px',
|
|
130
|
-
right: '121px',
|
|
131
|
-
bottom: '41px',
|
|
132
|
-
// @todo, broken due dark mode
|
|
133
|
-
// borderColor: chartSharedOptions.colors.axis,
|
|
134
|
-
show: true,
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
bottom: '1px',
|
|
138
|
-
right: '1px',
|
|
139
|
-
width: '120px',
|
|
140
|
-
height: '40px',
|
|
141
|
-
// @todo, broken due dark mode
|
|
142
|
-
// borderColor: chartSharedOptions.colors.axis,
|
|
143
|
-
show: true,
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
top: '1px',
|
|
147
|
-
left: '1px',
|
|
148
|
-
right: '1px',
|
|
149
|
-
bottom: '1px',
|
|
150
|
-
// @todo, broken due dark mode
|
|
151
|
-
// borderColor: chartSharedOptions.colors.axis,
|
|
152
|
-
show: true,
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
graphic: [
|
|
156
|
-
{
|
|
157
|
-
type: 'group',
|
|
158
|
-
left: '8px',
|
|
159
|
-
top: '8px',
|
|
160
|
-
silent: true,
|
|
161
|
-
children: [
|
|
162
|
-
{
|
|
163
|
-
type: 'rect',
|
|
164
|
-
z: 100,
|
|
165
|
-
left: 'center',
|
|
166
|
-
top: 'middle',
|
|
167
|
-
shape: {
|
|
168
|
-
width: 60,
|
|
169
|
-
height: 30,
|
|
170
|
-
},
|
|
171
|
-
style: {
|
|
172
|
-
fill: '#fff',
|
|
173
|
-
shadowBlur: 8,
|
|
174
|
-
shadowOffsetX: 0,
|
|
175
|
-
shadowOffsetY: 1,
|
|
176
|
-
shadowColor: 'rgba(0,0,0,0.1)',
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
type: 'text',
|
|
181
|
-
z: 100,
|
|
182
|
-
left: 'center',
|
|
183
|
-
top: 'middle',
|
|
184
|
-
style: {
|
|
185
|
-
width: 60,
|
|
186
|
-
height: 30,
|
|
187
|
-
// @todo
|
|
188
|
-
text: 'Sell',
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
type: 'group',
|
|
195
|
-
right: '128px',
|
|
196
|
-
top: '8px',
|
|
197
|
-
silent: true,
|
|
198
|
-
children: [
|
|
199
|
-
{
|
|
200
|
-
type: 'rect',
|
|
201
|
-
z: 100,
|
|
202
|
-
right: 'center',
|
|
203
|
-
top: 'middle',
|
|
204
|
-
shape: {
|
|
205
|
-
width: 60,
|
|
206
|
-
height: 30,
|
|
207
|
-
},
|
|
208
|
-
style: {
|
|
209
|
-
fill: '#fff',
|
|
210
|
-
shadowBlur: 8,
|
|
211
|
-
shadowOffsetX: 0,
|
|
212
|
-
shadowOffsetY: 1,
|
|
213
|
-
shadowColor: 'rgba(0,0,0,0.1)',
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
type: 'text',
|
|
218
|
-
z: 100,
|
|
219
|
-
right: 'center',
|
|
220
|
-
top: 'middle',
|
|
221
|
-
style: {
|
|
222
|
-
width: 60,
|
|
223
|
-
height: 30,
|
|
224
|
-
// @todo
|
|
225
|
-
text: 'Buy',
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
],
|
|
229
|
-
},
|
|
230
|
-
],
|
|
231
|
-
yAxis: {
|
|
232
|
-
type: 'value',
|
|
233
|
-
position: 'right',
|
|
234
|
-
axisLine: { show: false },
|
|
235
|
-
axisTick: { show: false },
|
|
236
|
-
splitLine: {
|
|
237
|
-
lineStyle: {
|
|
238
|
-
// @todo, broken due dark mode
|
|
239
|
-
// color: chartSharedOptions.colors.axis,
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
axisLabel: {
|
|
243
|
-
padding: [0, 0, 0, 10],
|
|
244
|
-
rich: {
|
|
245
|
-
a: {
|
|
246
|
-
padding: [0, 0, 16, 0],
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
// @todo add decimal places
|
|
250
|
-
formatter: (value, index) => (index ? `${value}` : `{a|${value}}`),
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
xAxis: {
|
|
254
|
-
type: 'value',
|
|
255
|
-
// @todo
|
|
256
|
-
min: -1.1,
|
|
257
|
-
max: 1.1,
|
|
258
|
-
axisLine: { show: false },
|
|
259
|
-
axisTick: { show: false },
|
|
260
|
-
splitLine: {
|
|
261
|
-
lineStyle: {
|
|
262
|
-
// @todo, broken due dark mode
|
|
263
|
-
// color: chartSharedOptions.colors.axis,
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
axisLabel: {
|
|
267
|
-
padding: [7, 0, 0, 0],
|
|
268
|
-
showMinLabel: false,
|
|
269
|
-
showMaxLabel: false,
|
|
270
|
-
formatter: (value) => (value === 0 ? '%' : `${Math.abs(value)}%`),
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
series: [
|
|
274
|
-
{
|
|
275
|
-
type: 'custom',
|
|
276
|
-
encode: {
|
|
277
|
-
x: 1,
|
|
278
|
-
y: 0,
|
|
279
|
-
tooltip: 1,
|
|
280
|
-
},
|
|
281
|
-
itemStyle: {
|
|
282
|
-
color: '#00B89E',
|
|
283
|
-
},
|
|
284
|
-
renderItem: (params, api) => {
|
|
285
|
-
const yValue = api.value(0);
|
|
286
|
-
const xStart = api.coord([api.value(1), yValue]);
|
|
287
|
-
const xEnd = api.coord([0, yValue]);
|
|
288
|
-
const bucketWidthHeight = api.size ? (api.size([0, bucketWidth]) as number[])[1] : 0;
|
|
289
|
-
const height = bucketWidthHeight > 4 ? bucketWidthHeight * 0.8 : bucketWidthHeight;
|
|
290
|
-
|
|
291
|
-
const rectShape = {
|
|
292
|
-
x: xStart[0] + 0.5,
|
|
293
|
-
y: xStart[1] - height / 2,
|
|
294
|
-
width: xEnd[0] - xStart[0],
|
|
295
|
-
height,
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
return {
|
|
299
|
-
type: 'rect',
|
|
300
|
-
shape: rectShape,
|
|
301
|
-
style: api.style(),
|
|
302
|
-
};
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
type: 'custom',
|
|
307
|
-
encode: {
|
|
308
|
-
x: 1,
|
|
309
|
-
y: 0,
|
|
310
|
-
tooltip: 2,
|
|
311
|
-
},
|
|
312
|
-
markLine: {
|
|
313
|
-
animation: false,
|
|
314
|
-
silent: true,
|
|
315
|
-
// @todo confirm precision
|
|
316
|
-
precision: 4,
|
|
317
|
-
symbol: ['none', 'triangle'],
|
|
318
|
-
symbolRotate: 90,
|
|
319
|
-
symbolSize: [20, 10],
|
|
320
|
-
lineStyle: {
|
|
321
|
-
color: '#008573',
|
|
322
|
-
width: 1,
|
|
323
|
-
},
|
|
324
|
-
label: {
|
|
325
|
-
padding: [5, 15, 5, 15],
|
|
326
|
-
color: '#fff',
|
|
327
|
-
backgroundColor: '#008573',
|
|
328
|
-
},
|
|
329
|
-
data: [
|
|
330
|
-
{
|
|
331
|
-
yAxis: price,
|
|
332
|
-
},
|
|
333
|
-
],
|
|
334
|
-
},
|
|
335
|
-
itemStyle: {
|
|
336
|
-
color: '#E5226E',
|
|
337
|
-
},
|
|
338
|
-
renderItem: (params, api) => {
|
|
339
|
-
const yValue = api.value(0);
|
|
340
|
-
const xStart = api.coord([api.value(2), yValue]);
|
|
341
|
-
const xEnd = api.coord([0, yValue]);
|
|
342
|
-
const bucketWidthHeight = api.size ? (api.size([0, bucketWidth]) as number[])[1] : 0;
|
|
343
|
-
const height = bucketWidthHeight > 4 ? bucketWidthHeight * 0.8 : bucketWidthHeight;
|
|
344
|
-
|
|
345
|
-
const rectShape = {
|
|
346
|
-
x: xStart[0] - 0.5,
|
|
347
|
-
y: xStart[1] - height / 2,
|
|
348
|
-
width: xEnd[0] - xStart[0],
|
|
349
|
-
height,
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
return {
|
|
353
|
-
type: 'rect',
|
|
354
|
-
shape: rectShape,
|
|
355
|
-
style: api.style(),
|
|
356
|
-
};
|
|
357
|
-
},
|
|
358
|
-
},
|
|
359
|
-
],
|
|
360
|
-
}
|
|
361
|
-
);
|