binbot-charts 0.2.6 → 0.2.7
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.
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = TVChartContainer;
|
|
9
7
|
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
+
|
|
10
10
|
require("core-js/modules/es.promise.js");
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -17,6 +17,8 @@ var _datafeed = _interopRequireDefault(require("./datafeed"));
|
|
|
17
17
|
|
|
18
18
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
19
|
|
|
20
|
+
var _useImmer = require("use-immer");
|
|
21
|
+
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
23
|
|
|
22
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -35,7 +37,8 @@ function TVChartContainer(_ref) {
|
|
|
35
37
|
getLatestBar
|
|
36
38
|
} = _ref;
|
|
37
39
|
const containerRef = (0, _react.useRef)(null);
|
|
38
|
-
(0,
|
|
40
|
+
const [chartOrderLines, setChartOrderLines] = (0, _useImmer.useImmer)([]);
|
|
41
|
+
(0, _react.useEffect)(() => {
|
|
39
42
|
const widgetOptions = {
|
|
40
43
|
symbol: symbol,
|
|
41
44
|
datafeed: new _datafeed.default(timescaleMarks),
|
|
@@ -56,8 +59,11 @@ function TVChartContainer(_ref) {
|
|
|
56
59
|
tvWidget.onChartReady(() => {
|
|
57
60
|
if (orderLines.length > 0) {
|
|
58
61
|
orderLines.forEach(order => {
|
|
59
|
-
const
|
|
60
|
-
|
|
62
|
+
const orderLine = updateOrderLines(tvWidget, order);
|
|
63
|
+
setChartOrderLines(draft => {
|
|
64
|
+
draft.push(orderLine);
|
|
65
|
+
return draft;
|
|
66
|
+
});
|
|
61
67
|
});
|
|
62
68
|
}
|
|
63
69
|
|
|
@@ -76,18 +82,30 @@ function TVChartContainer(_ref) {
|
|
|
76
82
|
}); // returned function will be called on component unmount
|
|
77
83
|
|
|
78
84
|
return () => {
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
this.tvWidget = null;
|
|
85
|
+
if (!tvWidget) {
|
|
86
|
+
tvWidget.remove();
|
|
82
87
|
}
|
|
83
88
|
};
|
|
84
|
-
}, []);
|
|
85
|
-
|
|
89
|
+
}, [orderLines, timescaleMarks]);
|
|
90
|
+
|
|
91
|
+
const updateOrderLines = (tvWidget, order) => {
|
|
92
|
+
if (chartOrderLines && chartOrderLines.length > 0) {
|
|
93
|
+
chartOrderLines.forEach(item => {
|
|
94
|
+
item.remove();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const lineStyle = order.lineStyle || 0;
|
|
99
|
+
const chartOrderLine = tvWidget.chart().createOrderLine().setText(order.text).setTooltip(order.tooltip).setQuantity(order.quantity).setQuantityFont("inherit 14px Arial").setQuantityBackgroundColor(order.color).setQuantityBorderColor(order.color).setLineStyle(lineStyle).setLineLength(25).setLineColor(order.color).setBodyFont("inherit 14px Arial").setBodyBorderColor(order.color).setBodyTextColor(order.color).setPrice(order.price);
|
|
100
|
+
return chartOrderLine;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, console.log(chartOrderLines), /*#__PURE__*/_react.default.createElement("div", {
|
|
86
104
|
ref: containerRef,
|
|
87
105
|
style: {
|
|
88
106
|
height: height
|
|
89
107
|
}
|
|
90
|
-
});
|
|
108
|
+
}));
|
|
91
109
|
}
|
|
92
110
|
|
|
93
111
|
TVChartContainer.propTypes = {
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.2.
|
|
2
|
+
"version": "0.2.7",
|
|
3
3
|
"name": "binbot-charts",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"react": "^17.0.1",
|
|
6
6
|
"react-dom": "^17.0.1",
|
|
7
|
-
"react-scripts": "^5.0.1"
|
|
7
|
+
"react-scripts": "^5.0.1",
|
|
8
|
+
"use-immer": "^0.7.0"
|
|
8
9
|
},
|
|
9
10
|
"devDependencies": {
|
|
10
11
|
"@babel/cli": "^7.18.10",
|