hyperprop-charting-library 0.1.123 → 0.1.124
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/dist/hyperprop-charting-library.cjs +56 -2
- package/dist/hyperprop-charting-library.js +56 -2
- package/dist/index.cjs +56 -2
- package/dist/index.js +56 -2
- package/package.json +1 -1
|
@@ -1364,7 +1364,7 @@ function createChart(element, options = {}) {
|
|
|
1364
1364
|
return;
|
|
1365
1365
|
}
|
|
1366
1366
|
const tickerOpts = mergedOptions.tickerLine ?? DEFAULT_OPTIONS.tickerLine;
|
|
1367
|
-
const speed = clamp(tickerOpts.smoothingSpeed ??
|
|
1367
|
+
const speed = clamp(tickerOpts.smoothingSpeed ?? 4, 1, 60);
|
|
1368
1368
|
const dt = 1 / 60;
|
|
1369
1369
|
const lerp = 1 - Math.exp(-speed * dt);
|
|
1370
1370
|
smoothedTickerPrice += priceDiff * lerp;
|
|
@@ -1801,6 +1801,56 @@ function createChart(element, options = {}) {
|
|
|
1801
1801
|
const upperDelta = Math.abs(upperPoint.time.getTime() - timeMs);
|
|
1802
1802
|
return lowerDelta <= upperDelta ? lower : upper;
|
|
1803
1803
|
};
|
|
1804
|
+
const indexForTimeMs = (timeMs) => {
|
|
1805
|
+
if (!Number.isFinite(timeMs) || data.length === 0) {
|
|
1806
|
+
return null;
|
|
1807
|
+
}
|
|
1808
|
+
const firstMs = data[0].time.getTime();
|
|
1809
|
+
const lastMs = data[data.length - 1].time.getTime();
|
|
1810
|
+
if (timeMs < firstMs) {
|
|
1811
|
+
const stepMs = getTimeStepMs();
|
|
1812
|
+
return stepMs > 0 ? (timeMs - firstMs) / stepMs : 0;
|
|
1813
|
+
}
|
|
1814
|
+
if (timeMs > lastMs) {
|
|
1815
|
+
const stepMs = getTimeStepMs();
|
|
1816
|
+
return data.length - 1 + (stepMs > 0 ? (timeMs - lastMs) / stepMs : 0);
|
|
1817
|
+
}
|
|
1818
|
+
return findNearestIndexForTimeMs(timeMs);
|
|
1819
|
+
};
|
|
1820
|
+
const reanchorDrawingPoint = (point) => {
|
|
1821
|
+
if (!point.time) {
|
|
1822
|
+
return point;
|
|
1823
|
+
}
|
|
1824
|
+
const timeMs = Date.parse(point.time);
|
|
1825
|
+
if (!Number.isFinite(timeMs)) {
|
|
1826
|
+
return point;
|
|
1827
|
+
}
|
|
1828
|
+
const rounded = Math.round(point.index);
|
|
1829
|
+
if (data[rounded]?.time.getTime() === timeMs) {
|
|
1830
|
+
return point;
|
|
1831
|
+
}
|
|
1832
|
+
const mapped = indexForTimeMs(timeMs);
|
|
1833
|
+
if (mapped === null) {
|
|
1834
|
+
return point;
|
|
1835
|
+
}
|
|
1836
|
+
const fraction = point.index - rounded;
|
|
1837
|
+
return { ...point, index: mapped + fraction };
|
|
1838
|
+
};
|
|
1839
|
+
const reanchorDrawingsToData = () => {
|
|
1840
|
+
if (data.length === 0) {
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
drawings = drawings.map((drawing) => ({
|
|
1844
|
+
...drawing,
|
|
1845
|
+
points: drawing.points.map((point) => reanchorDrawingPoint(point))
|
|
1846
|
+
}));
|
|
1847
|
+
if (draftDrawing) {
|
|
1848
|
+
draftDrawing = {
|
|
1849
|
+
...draftDrawing,
|
|
1850
|
+
points: draftDrawing.points.map((point) => reanchorDrawingPoint(point))
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1853
|
+
};
|
|
1804
1854
|
const getCandleDirectionByIndex = (index) => {
|
|
1805
1855
|
const point = data[index];
|
|
1806
1856
|
if (!point) {
|
|
@@ -5785,6 +5835,7 @@ function createChart(element, options = {}) {
|
|
|
5785
5835
|
fitXViewport();
|
|
5786
5836
|
}
|
|
5787
5837
|
}
|
|
5838
|
+
reanchorDrawingsToData();
|
|
5788
5839
|
const lastPoint = data[data.length - 1];
|
|
5789
5840
|
if (lastPoint) {
|
|
5790
5841
|
pushSmoothedTicker(lastPoint.c, lastPoint.v);
|
|
@@ -5831,6 +5882,7 @@ function createChart(element, options = {}) {
|
|
|
5831
5882
|
}
|
|
5832
5883
|
merged.set(timeMs, parsed);
|
|
5833
5884
|
data = Array.from(merged.values()).sort((a, b) => a.time.getTime() - b.time.getTime());
|
|
5885
|
+
reanchorDrawingsToData();
|
|
5834
5886
|
}
|
|
5835
5887
|
pushSmoothedTicker(parsed.c, parsed.v);
|
|
5836
5888
|
scheduleDraw();
|
|
@@ -6013,11 +6065,13 @@ function createChart(element, options = {}) {
|
|
|
6013
6065
|
const setDrawings = (nextDrawings) => {
|
|
6014
6066
|
drawings = dedupeDrawingIds(nextDrawings.map((drawing) => normalizeDrawingState(drawing)));
|
|
6015
6067
|
draftDrawing = null;
|
|
6068
|
+
reanchorDrawingsToData();
|
|
6016
6069
|
emitDrawingsChange();
|
|
6017
6070
|
scheduleDraw();
|
|
6018
6071
|
};
|
|
6019
6072
|
const addDrawing = (drawing) => {
|
|
6020
6073
|
const next = normalizeDrawingState(drawing);
|
|
6074
|
+
next.points = next.points.map((point) => reanchorDrawingPoint(point));
|
|
6021
6075
|
drawings.push(next);
|
|
6022
6076
|
emitDrawingsChange();
|
|
6023
6077
|
scheduleDraw();
|
|
@@ -6029,7 +6083,7 @@ function createChart(element, options = {}) {
|
|
|
6029
6083
|
...serializeDrawing(drawing),
|
|
6030
6084
|
...patch,
|
|
6031
6085
|
id,
|
|
6032
|
-
points: patch.points ?? drawing.points
|
|
6086
|
+
points: (patch.points ?? drawing.points).map((point) => reanchorDrawingPoint(point))
|
|
6033
6087
|
}) : drawing
|
|
6034
6088
|
);
|
|
6035
6089
|
emitDrawingsChange();
|
|
@@ -1338,7 +1338,7 @@ function createChart(element, options = {}) {
|
|
|
1338
1338
|
return;
|
|
1339
1339
|
}
|
|
1340
1340
|
const tickerOpts = mergedOptions.tickerLine ?? DEFAULT_OPTIONS.tickerLine;
|
|
1341
|
-
const speed = clamp(tickerOpts.smoothingSpeed ??
|
|
1341
|
+
const speed = clamp(tickerOpts.smoothingSpeed ?? 4, 1, 60);
|
|
1342
1342
|
const dt = 1 / 60;
|
|
1343
1343
|
const lerp = 1 - Math.exp(-speed * dt);
|
|
1344
1344
|
smoothedTickerPrice += priceDiff * lerp;
|
|
@@ -1775,6 +1775,56 @@ function createChart(element, options = {}) {
|
|
|
1775
1775
|
const upperDelta = Math.abs(upperPoint.time.getTime() - timeMs);
|
|
1776
1776
|
return lowerDelta <= upperDelta ? lower : upper;
|
|
1777
1777
|
};
|
|
1778
|
+
const indexForTimeMs = (timeMs) => {
|
|
1779
|
+
if (!Number.isFinite(timeMs) || data.length === 0) {
|
|
1780
|
+
return null;
|
|
1781
|
+
}
|
|
1782
|
+
const firstMs = data[0].time.getTime();
|
|
1783
|
+
const lastMs = data[data.length - 1].time.getTime();
|
|
1784
|
+
if (timeMs < firstMs) {
|
|
1785
|
+
const stepMs = getTimeStepMs();
|
|
1786
|
+
return stepMs > 0 ? (timeMs - firstMs) / stepMs : 0;
|
|
1787
|
+
}
|
|
1788
|
+
if (timeMs > lastMs) {
|
|
1789
|
+
const stepMs = getTimeStepMs();
|
|
1790
|
+
return data.length - 1 + (stepMs > 0 ? (timeMs - lastMs) / stepMs : 0);
|
|
1791
|
+
}
|
|
1792
|
+
return findNearestIndexForTimeMs(timeMs);
|
|
1793
|
+
};
|
|
1794
|
+
const reanchorDrawingPoint = (point) => {
|
|
1795
|
+
if (!point.time) {
|
|
1796
|
+
return point;
|
|
1797
|
+
}
|
|
1798
|
+
const timeMs = Date.parse(point.time);
|
|
1799
|
+
if (!Number.isFinite(timeMs)) {
|
|
1800
|
+
return point;
|
|
1801
|
+
}
|
|
1802
|
+
const rounded = Math.round(point.index);
|
|
1803
|
+
if (data[rounded]?.time.getTime() === timeMs) {
|
|
1804
|
+
return point;
|
|
1805
|
+
}
|
|
1806
|
+
const mapped = indexForTimeMs(timeMs);
|
|
1807
|
+
if (mapped === null) {
|
|
1808
|
+
return point;
|
|
1809
|
+
}
|
|
1810
|
+
const fraction = point.index - rounded;
|
|
1811
|
+
return { ...point, index: mapped + fraction };
|
|
1812
|
+
};
|
|
1813
|
+
const reanchorDrawingsToData = () => {
|
|
1814
|
+
if (data.length === 0) {
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
drawings = drawings.map((drawing) => ({
|
|
1818
|
+
...drawing,
|
|
1819
|
+
points: drawing.points.map((point) => reanchorDrawingPoint(point))
|
|
1820
|
+
}));
|
|
1821
|
+
if (draftDrawing) {
|
|
1822
|
+
draftDrawing = {
|
|
1823
|
+
...draftDrawing,
|
|
1824
|
+
points: draftDrawing.points.map((point) => reanchorDrawingPoint(point))
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
};
|
|
1778
1828
|
const getCandleDirectionByIndex = (index) => {
|
|
1779
1829
|
const point = data[index];
|
|
1780
1830
|
if (!point) {
|
|
@@ -5759,6 +5809,7 @@ function createChart(element, options = {}) {
|
|
|
5759
5809
|
fitXViewport();
|
|
5760
5810
|
}
|
|
5761
5811
|
}
|
|
5812
|
+
reanchorDrawingsToData();
|
|
5762
5813
|
const lastPoint = data[data.length - 1];
|
|
5763
5814
|
if (lastPoint) {
|
|
5764
5815
|
pushSmoothedTicker(lastPoint.c, lastPoint.v);
|
|
@@ -5805,6 +5856,7 @@ function createChart(element, options = {}) {
|
|
|
5805
5856
|
}
|
|
5806
5857
|
merged.set(timeMs, parsed);
|
|
5807
5858
|
data = Array.from(merged.values()).sort((a, b) => a.time.getTime() - b.time.getTime());
|
|
5859
|
+
reanchorDrawingsToData();
|
|
5808
5860
|
}
|
|
5809
5861
|
pushSmoothedTicker(parsed.c, parsed.v);
|
|
5810
5862
|
scheduleDraw();
|
|
@@ -5987,11 +6039,13 @@ function createChart(element, options = {}) {
|
|
|
5987
6039
|
const setDrawings = (nextDrawings) => {
|
|
5988
6040
|
drawings = dedupeDrawingIds(nextDrawings.map((drawing) => normalizeDrawingState(drawing)));
|
|
5989
6041
|
draftDrawing = null;
|
|
6042
|
+
reanchorDrawingsToData();
|
|
5990
6043
|
emitDrawingsChange();
|
|
5991
6044
|
scheduleDraw();
|
|
5992
6045
|
};
|
|
5993
6046
|
const addDrawing = (drawing) => {
|
|
5994
6047
|
const next = normalizeDrawingState(drawing);
|
|
6048
|
+
next.points = next.points.map((point) => reanchorDrawingPoint(point));
|
|
5995
6049
|
drawings.push(next);
|
|
5996
6050
|
emitDrawingsChange();
|
|
5997
6051
|
scheduleDraw();
|
|
@@ -6003,7 +6057,7 @@ function createChart(element, options = {}) {
|
|
|
6003
6057
|
...serializeDrawing(drawing),
|
|
6004
6058
|
...patch,
|
|
6005
6059
|
id,
|
|
6006
|
-
points: patch.points ?? drawing.points
|
|
6060
|
+
points: (patch.points ?? drawing.points).map((point) => reanchorDrawingPoint(point))
|
|
6007
6061
|
}) : drawing
|
|
6008
6062
|
);
|
|
6009
6063
|
emitDrawingsChange();
|
package/dist/index.cjs
CHANGED
|
@@ -1364,7 +1364,7 @@ function createChart(element, options = {}) {
|
|
|
1364
1364
|
return;
|
|
1365
1365
|
}
|
|
1366
1366
|
const tickerOpts = mergedOptions.tickerLine ?? DEFAULT_OPTIONS.tickerLine;
|
|
1367
|
-
const speed = clamp(tickerOpts.smoothingSpeed ??
|
|
1367
|
+
const speed = clamp(tickerOpts.smoothingSpeed ?? 4, 1, 60);
|
|
1368
1368
|
const dt = 1 / 60;
|
|
1369
1369
|
const lerp = 1 - Math.exp(-speed * dt);
|
|
1370
1370
|
smoothedTickerPrice += priceDiff * lerp;
|
|
@@ -1801,6 +1801,56 @@ function createChart(element, options = {}) {
|
|
|
1801
1801
|
const upperDelta = Math.abs(upperPoint.time.getTime() - timeMs);
|
|
1802
1802
|
return lowerDelta <= upperDelta ? lower : upper;
|
|
1803
1803
|
};
|
|
1804
|
+
const indexForTimeMs = (timeMs) => {
|
|
1805
|
+
if (!Number.isFinite(timeMs) || data.length === 0) {
|
|
1806
|
+
return null;
|
|
1807
|
+
}
|
|
1808
|
+
const firstMs = data[0].time.getTime();
|
|
1809
|
+
const lastMs = data[data.length - 1].time.getTime();
|
|
1810
|
+
if (timeMs < firstMs) {
|
|
1811
|
+
const stepMs = getTimeStepMs();
|
|
1812
|
+
return stepMs > 0 ? (timeMs - firstMs) / stepMs : 0;
|
|
1813
|
+
}
|
|
1814
|
+
if (timeMs > lastMs) {
|
|
1815
|
+
const stepMs = getTimeStepMs();
|
|
1816
|
+
return data.length - 1 + (stepMs > 0 ? (timeMs - lastMs) / stepMs : 0);
|
|
1817
|
+
}
|
|
1818
|
+
return findNearestIndexForTimeMs(timeMs);
|
|
1819
|
+
};
|
|
1820
|
+
const reanchorDrawingPoint = (point) => {
|
|
1821
|
+
if (!point.time) {
|
|
1822
|
+
return point;
|
|
1823
|
+
}
|
|
1824
|
+
const timeMs = Date.parse(point.time);
|
|
1825
|
+
if (!Number.isFinite(timeMs)) {
|
|
1826
|
+
return point;
|
|
1827
|
+
}
|
|
1828
|
+
const rounded = Math.round(point.index);
|
|
1829
|
+
if (data[rounded]?.time.getTime() === timeMs) {
|
|
1830
|
+
return point;
|
|
1831
|
+
}
|
|
1832
|
+
const mapped = indexForTimeMs(timeMs);
|
|
1833
|
+
if (mapped === null) {
|
|
1834
|
+
return point;
|
|
1835
|
+
}
|
|
1836
|
+
const fraction = point.index - rounded;
|
|
1837
|
+
return { ...point, index: mapped + fraction };
|
|
1838
|
+
};
|
|
1839
|
+
const reanchorDrawingsToData = () => {
|
|
1840
|
+
if (data.length === 0) {
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
drawings = drawings.map((drawing) => ({
|
|
1844
|
+
...drawing,
|
|
1845
|
+
points: drawing.points.map((point) => reanchorDrawingPoint(point))
|
|
1846
|
+
}));
|
|
1847
|
+
if (draftDrawing) {
|
|
1848
|
+
draftDrawing = {
|
|
1849
|
+
...draftDrawing,
|
|
1850
|
+
points: draftDrawing.points.map((point) => reanchorDrawingPoint(point))
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1853
|
+
};
|
|
1804
1854
|
const getCandleDirectionByIndex = (index) => {
|
|
1805
1855
|
const point = data[index];
|
|
1806
1856
|
if (!point) {
|
|
@@ -5785,6 +5835,7 @@ function createChart(element, options = {}) {
|
|
|
5785
5835
|
fitXViewport();
|
|
5786
5836
|
}
|
|
5787
5837
|
}
|
|
5838
|
+
reanchorDrawingsToData();
|
|
5788
5839
|
const lastPoint = data[data.length - 1];
|
|
5789
5840
|
if (lastPoint) {
|
|
5790
5841
|
pushSmoothedTicker(lastPoint.c, lastPoint.v);
|
|
@@ -5831,6 +5882,7 @@ function createChart(element, options = {}) {
|
|
|
5831
5882
|
}
|
|
5832
5883
|
merged.set(timeMs, parsed);
|
|
5833
5884
|
data = Array.from(merged.values()).sort((a, b) => a.time.getTime() - b.time.getTime());
|
|
5885
|
+
reanchorDrawingsToData();
|
|
5834
5886
|
}
|
|
5835
5887
|
pushSmoothedTicker(parsed.c, parsed.v);
|
|
5836
5888
|
scheduleDraw();
|
|
@@ -6013,11 +6065,13 @@ function createChart(element, options = {}) {
|
|
|
6013
6065
|
const setDrawings = (nextDrawings) => {
|
|
6014
6066
|
drawings = dedupeDrawingIds(nextDrawings.map((drawing) => normalizeDrawingState(drawing)));
|
|
6015
6067
|
draftDrawing = null;
|
|
6068
|
+
reanchorDrawingsToData();
|
|
6016
6069
|
emitDrawingsChange();
|
|
6017
6070
|
scheduleDraw();
|
|
6018
6071
|
};
|
|
6019
6072
|
const addDrawing = (drawing) => {
|
|
6020
6073
|
const next = normalizeDrawingState(drawing);
|
|
6074
|
+
next.points = next.points.map((point) => reanchorDrawingPoint(point));
|
|
6021
6075
|
drawings.push(next);
|
|
6022
6076
|
emitDrawingsChange();
|
|
6023
6077
|
scheduleDraw();
|
|
@@ -6029,7 +6083,7 @@ function createChart(element, options = {}) {
|
|
|
6029
6083
|
...serializeDrawing(drawing),
|
|
6030
6084
|
...patch,
|
|
6031
6085
|
id,
|
|
6032
|
-
points: patch.points ?? drawing.points
|
|
6086
|
+
points: (patch.points ?? drawing.points).map((point) => reanchorDrawingPoint(point))
|
|
6033
6087
|
}) : drawing
|
|
6034
6088
|
);
|
|
6035
6089
|
emitDrawingsChange();
|
package/dist/index.js
CHANGED
|
@@ -1338,7 +1338,7 @@ function createChart(element, options = {}) {
|
|
|
1338
1338
|
return;
|
|
1339
1339
|
}
|
|
1340
1340
|
const tickerOpts = mergedOptions.tickerLine ?? DEFAULT_OPTIONS.tickerLine;
|
|
1341
|
-
const speed = clamp(tickerOpts.smoothingSpeed ??
|
|
1341
|
+
const speed = clamp(tickerOpts.smoothingSpeed ?? 4, 1, 60);
|
|
1342
1342
|
const dt = 1 / 60;
|
|
1343
1343
|
const lerp = 1 - Math.exp(-speed * dt);
|
|
1344
1344
|
smoothedTickerPrice += priceDiff * lerp;
|
|
@@ -1775,6 +1775,56 @@ function createChart(element, options = {}) {
|
|
|
1775
1775
|
const upperDelta = Math.abs(upperPoint.time.getTime() - timeMs);
|
|
1776
1776
|
return lowerDelta <= upperDelta ? lower : upper;
|
|
1777
1777
|
};
|
|
1778
|
+
const indexForTimeMs = (timeMs) => {
|
|
1779
|
+
if (!Number.isFinite(timeMs) || data.length === 0) {
|
|
1780
|
+
return null;
|
|
1781
|
+
}
|
|
1782
|
+
const firstMs = data[0].time.getTime();
|
|
1783
|
+
const lastMs = data[data.length - 1].time.getTime();
|
|
1784
|
+
if (timeMs < firstMs) {
|
|
1785
|
+
const stepMs = getTimeStepMs();
|
|
1786
|
+
return stepMs > 0 ? (timeMs - firstMs) / stepMs : 0;
|
|
1787
|
+
}
|
|
1788
|
+
if (timeMs > lastMs) {
|
|
1789
|
+
const stepMs = getTimeStepMs();
|
|
1790
|
+
return data.length - 1 + (stepMs > 0 ? (timeMs - lastMs) / stepMs : 0);
|
|
1791
|
+
}
|
|
1792
|
+
return findNearestIndexForTimeMs(timeMs);
|
|
1793
|
+
};
|
|
1794
|
+
const reanchorDrawingPoint = (point) => {
|
|
1795
|
+
if (!point.time) {
|
|
1796
|
+
return point;
|
|
1797
|
+
}
|
|
1798
|
+
const timeMs = Date.parse(point.time);
|
|
1799
|
+
if (!Number.isFinite(timeMs)) {
|
|
1800
|
+
return point;
|
|
1801
|
+
}
|
|
1802
|
+
const rounded = Math.round(point.index);
|
|
1803
|
+
if (data[rounded]?.time.getTime() === timeMs) {
|
|
1804
|
+
return point;
|
|
1805
|
+
}
|
|
1806
|
+
const mapped = indexForTimeMs(timeMs);
|
|
1807
|
+
if (mapped === null) {
|
|
1808
|
+
return point;
|
|
1809
|
+
}
|
|
1810
|
+
const fraction = point.index - rounded;
|
|
1811
|
+
return { ...point, index: mapped + fraction };
|
|
1812
|
+
};
|
|
1813
|
+
const reanchorDrawingsToData = () => {
|
|
1814
|
+
if (data.length === 0) {
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
drawings = drawings.map((drawing) => ({
|
|
1818
|
+
...drawing,
|
|
1819
|
+
points: drawing.points.map((point) => reanchorDrawingPoint(point))
|
|
1820
|
+
}));
|
|
1821
|
+
if (draftDrawing) {
|
|
1822
|
+
draftDrawing = {
|
|
1823
|
+
...draftDrawing,
|
|
1824
|
+
points: draftDrawing.points.map((point) => reanchorDrawingPoint(point))
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
};
|
|
1778
1828
|
const getCandleDirectionByIndex = (index) => {
|
|
1779
1829
|
const point = data[index];
|
|
1780
1830
|
if (!point) {
|
|
@@ -5759,6 +5809,7 @@ function createChart(element, options = {}) {
|
|
|
5759
5809
|
fitXViewport();
|
|
5760
5810
|
}
|
|
5761
5811
|
}
|
|
5812
|
+
reanchorDrawingsToData();
|
|
5762
5813
|
const lastPoint = data[data.length - 1];
|
|
5763
5814
|
if (lastPoint) {
|
|
5764
5815
|
pushSmoothedTicker(lastPoint.c, lastPoint.v);
|
|
@@ -5805,6 +5856,7 @@ function createChart(element, options = {}) {
|
|
|
5805
5856
|
}
|
|
5806
5857
|
merged.set(timeMs, parsed);
|
|
5807
5858
|
data = Array.from(merged.values()).sort((a, b) => a.time.getTime() - b.time.getTime());
|
|
5859
|
+
reanchorDrawingsToData();
|
|
5808
5860
|
}
|
|
5809
5861
|
pushSmoothedTicker(parsed.c, parsed.v);
|
|
5810
5862
|
scheduleDraw();
|
|
@@ -5987,11 +6039,13 @@ function createChart(element, options = {}) {
|
|
|
5987
6039
|
const setDrawings = (nextDrawings) => {
|
|
5988
6040
|
drawings = dedupeDrawingIds(nextDrawings.map((drawing) => normalizeDrawingState(drawing)));
|
|
5989
6041
|
draftDrawing = null;
|
|
6042
|
+
reanchorDrawingsToData();
|
|
5990
6043
|
emitDrawingsChange();
|
|
5991
6044
|
scheduleDraw();
|
|
5992
6045
|
};
|
|
5993
6046
|
const addDrawing = (drawing) => {
|
|
5994
6047
|
const next = normalizeDrawingState(drawing);
|
|
6048
|
+
next.points = next.points.map((point) => reanchorDrawingPoint(point));
|
|
5995
6049
|
drawings.push(next);
|
|
5996
6050
|
emitDrawingsChange();
|
|
5997
6051
|
scheduleDraw();
|
|
@@ -6003,7 +6057,7 @@ function createChart(element, options = {}) {
|
|
|
6003
6057
|
...serializeDrawing(drawing),
|
|
6004
6058
|
...patch,
|
|
6005
6059
|
id,
|
|
6006
|
-
points: patch.points ?? drawing.points
|
|
6060
|
+
points: (patch.points ?? drawing.points).map((point) => reanchorDrawingPoint(point))
|
|
6007
6061
|
}) : drawing
|
|
6008
6062
|
);
|
|
6009
6063
|
emitDrawingsChange();
|