react-klinecharts-ui 0.6.0 → 1.1.0
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/README.md +186 -6
- package/dist/chart.cjs +70 -0
- package/dist/chart.cjs.map +1 -0
- package/dist/chart.d.cts +45 -0
- package/dist/chart.d.ts +45 -0
- package/dist/chart.js +68 -0
- package/dist/chart.js.map +1 -0
- package/dist/chunk-F24D6PWY.cjs +98 -0
- package/dist/chunk-F24D6PWY.cjs.map +1 -0
- package/dist/chunk-O7E57I66.js +92 -0
- package/dist/chunk-O7E57I66.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/{chunk-MVD3ILJT.js → chunk-RIT2LJQT.js} +35 -22
- package/dist/chunk-RIT2LJQT.js.map +1 -0
- package/dist/{chunk-FSHI2ZDB.cjs → chunk-SZDU2D3D.cjs} +46 -33
- package/dist/chunk-SZDU2D3D.cjs.map +1 -0
- package/dist/extensions.cjs +10 -9
- package/dist/extensions.d.cts +10 -7
- package/dist/extensions.d.ts +10 -7
- package/dist/extensions.js +2 -1
- package/dist/index.cjs +657 -323
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +246 -9
- package/dist/index.d.ts +246 -9
- package/dist/index.js +555 -240
- package/dist/index.js.map +1 -1
- package/package.json +31 -5
- package/dist/chunk-FSHI2ZDB.cjs.map +0 -1
- package/dist/chunk-MVD3ILJT.js.map +0 -1
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
3
|
+
var chunkQ7SFCCGT_cjs = require('./chunk-Q7SFCCGT.cjs');
|
|
4
|
+
var klinecharts = require('klinecharts');
|
|
10
5
|
|
|
11
6
|
// src/overlays/index.ts
|
|
12
7
|
var overlays_exports = {};
|
|
13
|
-
__export(overlays_exports, {
|
|
8
|
+
chunkQ7SFCCGT_cjs.__export(overlays_exports, {
|
|
14
9
|
abcd: () => abcd_default,
|
|
15
10
|
anyWaves: () => anyWaves_default,
|
|
16
11
|
arrow: () => arrow_default,
|
|
@@ -55,7 +50,7 @@ function getRayLine(coordinates, bounding) {
|
|
|
55
50
|
} else if (coordinates[0].x > coordinates[1].x) {
|
|
56
51
|
coordinate = {
|
|
57
52
|
x: 0,
|
|
58
|
-
y:
|
|
53
|
+
y: klinecharts.utils.getLinearYFromCoordinates(coordinates[0], coordinates[1], {
|
|
59
54
|
x: 0,
|
|
60
55
|
y: coordinates[0].y
|
|
61
56
|
})
|
|
@@ -63,7 +58,7 @@ function getRayLine(coordinates, bounding) {
|
|
|
63
58
|
} else {
|
|
64
59
|
coordinate = {
|
|
65
60
|
x: bounding.width,
|
|
66
|
-
y:
|
|
61
|
+
y: klinecharts.utils.getLinearYFromCoordinates(coordinates[0], coordinates[1], {
|
|
67
62
|
x: bounding.width,
|
|
68
63
|
y: coordinates[0].y
|
|
69
64
|
})
|
|
@@ -89,7 +84,7 @@ var arrow = {
|
|
|
89
84
|
createPointFigures: ({ coordinates }) => {
|
|
90
85
|
if (coordinates.length > 1) {
|
|
91
86
|
const flag = coordinates[1].x > coordinates[0].x ? 0 : 1;
|
|
92
|
-
const kb =
|
|
87
|
+
const kb = klinecharts.utils.getLinearSlopeIntercept(coordinates[0], coordinates[1]);
|
|
93
88
|
let offsetAngle;
|
|
94
89
|
if (kb) {
|
|
95
90
|
offsetAngle = Math.atan(kb[0]) + Math.PI * flag;
|
|
@@ -331,7 +326,7 @@ var fibonacciSpiral = {
|
|
|
331
326
|
if (coordinates.length > 1) {
|
|
332
327
|
const startRadius = getDistance(coordinates[0], coordinates[1]) / Math.sqrt(24);
|
|
333
328
|
const flag = coordinates[1].x > coordinates[0].x ? 0 : 1;
|
|
334
|
-
const kb =
|
|
329
|
+
const kb = klinecharts.utils.getLinearSlopeIntercept(coordinates[0], coordinates[1]);
|
|
335
330
|
let offsetAngle;
|
|
336
331
|
if (kb) {
|
|
337
332
|
offsetAngle = Math.atan(kb[0]) + Math.PI * flag;
|
|
@@ -994,7 +989,10 @@ var parallelChannel_default = parallelChannel;
|
|
|
994
989
|
// src/overlays/longPosition.ts
|
|
995
990
|
var longPosition = {
|
|
996
991
|
name: "longPosition",
|
|
997
|
-
totalStep
|
|
992
|
+
// totalStep 4 → the user places 3 points interactively (entry, target, stop).
|
|
993
|
+
// With the previous value of 3, only 2 points were captured and the stop was
|
|
994
|
+
// always a hardcoded 40px offset, so R/R was meaningless.
|
|
995
|
+
totalStep: 4,
|
|
998
996
|
needDefaultPointFigure: true,
|
|
999
997
|
needDefaultXAxisFigure: true,
|
|
1000
998
|
needDefaultYAxisFigure: true,
|
|
@@ -1103,7 +1101,10 @@ var longPosition_default = longPosition;
|
|
|
1103
1101
|
// src/overlays/shortPosition.ts
|
|
1104
1102
|
var shortPosition = {
|
|
1105
1103
|
name: "shortPosition",
|
|
1106
|
-
totalStep
|
|
1104
|
+
// totalStep 4 → the user places 3 points interactively (entry, target, stop).
|
|
1105
|
+
// With the previous value of 3, only 2 points were captured and the stop was
|
|
1106
|
+
// always a hardcoded 40px offset, so R/R was meaningless.
|
|
1107
|
+
totalStep: 4,
|
|
1107
1108
|
needDefaultPointFigure: true,
|
|
1108
1109
|
needDefaultXAxisFigure: true,
|
|
1109
1110
|
needDefaultYAxisFigure: true,
|
|
@@ -1232,8 +1233,10 @@ var measure = {
|
|
|
1232
1233
|
const endPoint = overlay.points[1];
|
|
1233
1234
|
const startCoord = coordinates[0];
|
|
1234
1235
|
const endCoord = coordinates[1];
|
|
1235
|
-
const
|
|
1236
|
-
const
|
|
1236
|
+
const startValue = startPoint.value ?? 0;
|
|
1237
|
+
const endValue = endPoint.value ?? 0;
|
|
1238
|
+
const diff = endValue - startValue;
|
|
1239
|
+
const percent = startValue !== 0 ? (diff / startValue * 100).toFixed(2) : "0.00";
|
|
1237
1240
|
const bars = Math.abs(
|
|
1238
1241
|
(endPoint.dataIndex ?? 0) - (startPoint.dataIndex ?? 0)
|
|
1239
1242
|
);
|
|
@@ -1286,7 +1289,7 @@ var measure = {
|
|
|
1286
1289
|
{
|
|
1287
1290
|
type: "line",
|
|
1288
1291
|
attrs: { coordinates: [startCoord, endCoord] },
|
|
1289
|
-
styles: { color: strokeColor, style: "
|
|
1292
|
+
styles: { color: strokeColor, style: "dashed" }
|
|
1290
1293
|
},
|
|
1291
1294
|
...textFigures
|
|
1292
1295
|
];
|
|
@@ -1342,7 +1345,7 @@ function rdp(points, epsilon) {
|
|
|
1342
1345
|
}
|
|
1343
1346
|
return result;
|
|
1344
1347
|
}
|
|
1345
|
-
|
|
1348
|
+
klinecharts.registerFigure({
|
|
1346
1349
|
name: "brush_path",
|
|
1347
1350
|
draw: (ctx, attrs, styles) => {
|
|
1348
1351
|
const { coordinates } = attrs;
|
|
@@ -1475,7 +1478,7 @@ var brush_default = brush;
|
|
|
1475
1478
|
|
|
1476
1479
|
// src/indicators/index.ts
|
|
1477
1480
|
var indicators_exports = {};
|
|
1478
|
-
__export(indicators_exports, {
|
|
1481
|
+
chunkQ7SFCCGT_cjs.__export(indicators_exports, {
|
|
1479
1482
|
bollTv: () => bollTv_default,
|
|
1480
1483
|
cci: () => cci_default,
|
|
1481
1484
|
hma: () => hma_default,
|
|
@@ -1862,8 +1865,9 @@ var ichimoku = {
|
|
|
1862
1865
|
if (index >= kijunPeriod - 1) {
|
|
1863
1866
|
item.kijun = highLowAvg(dataList, index - kijunPeriod + 1, index);
|
|
1864
1867
|
}
|
|
1865
|
-
|
|
1866
|
-
|
|
1868
|
+
const chikouIndex = index - offset;
|
|
1869
|
+
if (chikouIndex >= 0) {
|
|
1870
|
+
item.chikou = dataList[chikouIndex].close;
|
|
1867
1871
|
}
|
|
1868
1872
|
const prevIndex = index - offset;
|
|
1869
1873
|
if (prevIndex >= 0) {
|
|
@@ -2003,7 +2007,7 @@ var pivotPoints = {
|
|
|
2003
2007
|
let dayLow = Infinity;
|
|
2004
2008
|
let dayClose = 0;
|
|
2005
2009
|
return dataList.map((kLineData) => {
|
|
2006
|
-
const date = new Date(kLineData.timestamp).
|
|
2010
|
+
const date = new Date(kLineData.timestamp).toISOString().slice(0, 10);
|
|
2007
2011
|
if (date !== lastDate) {
|
|
2008
2012
|
if (lastDate !== "") {
|
|
2009
2013
|
lastP = (dayHigh + dayLow + dayClose) / 3;
|
|
@@ -2057,11 +2061,20 @@ var rsiTv = {
|
|
|
2057
2061
|
const maPeriod = indicator.calcParams[1];
|
|
2058
2062
|
const closes = dataList.map((d) => d.close);
|
|
2059
2063
|
const rsiValues = TA_default.rsi(closes, rsiPeriod);
|
|
2060
|
-
const
|
|
2061
|
-
|
|
2064
|
+
const rsiMa = new Array(rsiValues.length).fill(null);
|
|
2065
|
+
for (let i = 0; i < rsiValues.length; i++) {
|
|
2066
|
+
if (rsiValues[i] === null) continue;
|
|
2067
|
+
const valid = [];
|
|
2068
|
+
for (let j = i; j >= 0 && valid.length < maPeriod; j--) {
|
|
2069
|
+
if (rsiValues[j] !== null) valid.push(rsiValues[j]);
|
|
2070
|
+
}
|
|
2071
|
+
if (valid.length === maPeriod) {
|
|
2072
|
+
rsiMa[i] = valid.reduce((a, b) => a + b, 0) / maPeriod;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2062
2075
|
return dataList.map((_, i) => {
|
|
2063
2076
|
const rsi = rsiValues[i];
|
|
2064
|
-
const rsi_ma = rsi !== null
|
|
2077
|
+
const rsi_ma = rsi !== null ? rsiMa[i] : null;
|
|
2065
2078
|
return { rsi, rsi_ma };
|
|
2066
2079
|
});
|
|
2067
2080
|
},
|
|
@@ -2283,7 +2296,7 @@ var vwap = {
|
|
|
2283
2296
|
let cumulativePriceVolume = 0;
|
|
2284
2297
|
let lastDate = "";
|
|
2285
2298
|
return dataList.map((kLineData) => {
|
|
2286
|
-
const date = new Date(kLineData.timestamp).
|
|
2299
|
+
const date = new Date(kLineData.timestamp).toISOString().slice(0, 10);
|
|
2287
2300
|
if (date !== lastDate) {
|
|
2288
2301
|
cumulativeVolume = 0;
|
|
2289
2302
|
cumulativePriceVolume = 0;
|
|
@@ -2416,7 +2429,7 @@ var depthOverlay = {
|
|
|
2416
2429
|
const maxBarPx = bounding.width * maxBarFraction;
|
|
2417
2430
|
const askColor = d.askColor ?? "rgba(239,83,80,0.25)";
|
|
2418
2431
|
const bidColor = d.bidColor ?? "rgba(38,166,154,0.25)";
|
|
2419
|
-
const maxQty = d.maxQty
|
|
2432
|
+
const maxQty = d.maxQty ?? 1;
|
|
2420
2433
|
const figures = [];
|
|
2421
2434
|
for (const row of d.rows) {
|
|
2422
2435
|
const y = yAxis.convertToPixel(row.price);
|
|
@@ -2556,15 +2569,15 @@ var indicators = Object.values(indicators_exports);
|
|
|
2556
2569
|
var registered = false;
|
|
2557
2570
|
function registerExtensions() {
|
|
2558
2571
|
if (registered) return;
|
|
2559
|
-
overlays.forEach((overlay) =>
|
|
2560
|
-
featureOverlays.forEach((overlay) =>
|
|
2561
|
-
indicators.forEach((indicator) =>
|
|
2572
|
+
overlays.forEach((overlay) => klinecharts.registerOverlay(overlay));
|
|
2573
|
+
featureOverlays.forEach((overlay) => klinecharts.registerOverlay(overlay));
|
|
2574
|
+
indicators.forEach((indicator) => klinecharts.registerIndicator(indicator));
|
|
2562
2575
|
registered = true;
|
|
2563
2576
|
}
|
|
2564
2577
|
var alertLineRegistered = false;
|
|
2565
2578
|
function ensureAlertLineRegistered() {
|
|
2566
2579
|
if (alertLineRegistered) return;
|
|
2567
|
-
|
|
2580
|
+
klinecharts.registerOverlay(alertLine_default);
|
|
2568
2581
|
alertLineRegistered = true;
|
|
2569
2582
|
}
|
|
2570
2583
|
|
|
@@ -2614,5 +2627,5 @@ exports.threeWaves_default = threeWaves_default;
|
|
|
2614
2627
|
exports.triangle_default = triangle_default;
|
|
2615
2628
|
exports.vwap_default = vwap_default;
|
|
2616
2629
|
exports.xabcd_default = xabcd_default;
|
|
2617
|
-
//# sourceMappingURL=chunk-
|
|
2618
|
-
//# sourceMappingURL=chunk-
|
|
2630
|
+
//# sourceMappingURL=chunk-SZDU2D3D.cjs.map
|
|
2631
|
+
//# sourceMappingURL=chunk-SZDU2D3D.cjs.map
|