hyperprop-charting-library 0.1.31 → 0.1.32
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.
|
@@ -819,6 +819,13 @@ function createChart(element, options = {}) {
|
|
|
819
819
|
const orderPriceTagWidthById = /* @__PURE__ */ new Map();
|
|
820
820
|
let xCenter = 0;
|
|
821
821
|
let xSpan = 60;
|
|
822
|
+
let followLatest = true;
|
|
823
|
+
let followingLatestChangeHandler = null;
|
|
824
|
+
const updateFollowLatest = (next) => {
|
|
825
|
+
if (followLatest === next) return;
|
|
826
|
+
followLatest = next;
|
|
827
|
+
followingLatestChangeHandler?.(next);
|
|
828
|
+
};
|
|
822
829
|
let yMinOverride = null;
|
|
823
830
|
let yMaxOverride = null;
|
|
824
831
|
let autoYMin = null;
|
|
@@ -2150,6 +2157,7 @@ function createChart(element, options = {}) {
|
|
|
2150
2157
|
xSpan = nextSpan;
|
|
2151
2158
|
xCenter = nextStart + nextSpan / 2;
|
|
2152
2159
|
clampXViewport();
|
|
2160
|
+
updateFollowLatest(false);
|
|
2153
2161
|
draw();
|
|
2154
2162
|
};
|
|
2155
2163
|
const zoomXToLatest = (factor) => {
|
|
@@ -2194,6 +2202,9 @@ function createChart(element, options = {}) {
|
|
|
2194
2202
|
const indexShift = deltaX / drawState.chartWidth * xSpan;
|
|
2195
2203
|
xCenter -= indexShift;
|
|
2196
2204
|
clampXViewport();
|
|
2205
|
+
if (deltaX !== 0) {
|
|
2206
|
+
updateFollowLatest(false);
|
|
2207
|
+
}
|
|
2197
2208
|
}
|
|
2198
2209
|
if (allowY) {
|
|
2199
2210
|
const currentMin = yMinOverride ?? drawState.yMin;
|
|
@@ -2242,6 +2253,7 @@ function createChart(element, options = {}) {
|
|
|
2242
2253
|
}
|
|
2243
2254
|
xCenter += bars;
|
|
2244
2255
|
clampXViewport();
|
|
2256
|
+
updateFollowLatest(false);
|
|
2245
2257
|
draw();
|
|
2246
2258
|
};
|
|
2247
2259
|
const panY = (priceDelta) => {
|
|
@@ -2257,13 +2269,29 @@ function createChart(element, options = {}) {
|
|
|
2257
2269
|
};
|
|
2258
2270
|
const fitContent = () => {
|
|
2259
2271
|
fitXViewport();
|
|
2272
|
+
updateFollowLatest(true);
|
|
2260
2273
|
draw();
|
|
2261
2274
|
};
|
|
2262
2275
|
const resetViewport = () => {
|
|
2263
2276
|
fitXViewport();
|
|
2264
2277
|
resetYViewport();
|
|
2278
|
+
updateFollowLatest(true);
|
|
2265
2279
|
draw();
|
|
2266
2280
|
};
|
|
2281
|
+
const isFollowingLatest = () => followLatest;
|
|
2282
|
+
const setFollowingLatest = (follow) => {
|
|
2283
|
+
if (follow && data.length > 0) {
|
|
2284
|
+
xCenter = data.length - xSpan / 2 + rightEdgePaddingBars;
|
|
2285
|
+
clampXViewport();
|
|
2286
|
+
updateFollowLatest(true);
|
|
2287
|
+
draw();
|
|
2288
|
+
} else {
|
|
2289
|
+
updateFollowLatest(follow);
|
|
2290
|
+
}
|
|
2291
|
+
};
|
|
2292
|
+
const onFollowingLatestChange = (handler) => {
|
|
2293
|
+
followingLatestChangeHandler = handler;
|
|
2294
|
+
};
|
|
2267
2295
|
const getCanvasPoint = (event) => {
|
|
2268
2296
|
const rect = canvas.getBoundingClientRect();
|
|
2269
2297
|
return {
|
|
@@ -2682,9 +2710,7 @@ function createChart(element, options = {}) {
|
|
|
2682
2710
|
resetYViewport();
|
|
2683
2711
|
} else {
|
|
2684
2712
|
if (mergedOptions.preserveViewportOnDataUpdate) {
|
|
2685
|
-
|
|
2686
|
-
const wasAtRightEdge = hasNewBars && xCenter + xSpan / 2 >= previousCount - 1;
|
|
2687
|
-
if (wasAtRightEdge) {
|
|
2713
|
+
if (followLatest) {
|
|
2688
2714
|
xCenter = data.length - xSpan / 2 + rightEdgePaddingBars;
|
|
2689
2715
|
} else if (previousCenterTimeMs !== null) {
|
|
2690
2716
|
const nextCenter = findNearestIndexForTimeMs(previousCenterTimeMs);
|
|
@@ -2878,6 +2904,9 @@ function createChart(element, options = {}) {
|
|
|
2878
2904
|
panY,
|
|
2879
2905
|
resetViewport,
|
|
2880
2906
|
fitContent,
|
|
2907
|
+
isFollowingLatest,
|
|
2908
|
+
setFollowingLatest,
|
|
2909
|
+
onFollowingLatestChange,
|
|
2881
2910
|
setDoubleClickEnabled,
|
|
2882
2911
|
setDoubleClickAction,
|
|
2883
2912
|
registerIndicator,
|
|
@@ -281,6 +281,9 @@ interface ChartInstance {
|
|
|
281
281
|
panY: (priceDelta: number) => void;
|
|
282
282
|
resetViewport: () => void;
|
|
283
283
|
fitContent: () => void;
|
|
284
|
+
isFollowingLatest: () => boolean;
|
|
285
|
+
setFollowingLatest: (follow: boolean) => void;
|
|
286
|
+
onFollowingLatestChange: (handler: ((following: boolean) => void) | null) => void;
|
|
284
287
|
setDoubleClickEnabled: (enabled: boolean) => void;
|
|
285
288
|
setDoubleClickAction: (action: "reset" | "placeLimitOrder") => void;
|
|
286
289
|
registerIndicator: (plugin: IndicatorPlugin<any>) => void;
|
|
@@ -795,6 +795,13 @@ function createChart(element, options = {}) {
|
|
|
795
795
|
const orderPriceTagWidthById = /* @__PURE__ */ new Map();
|
|
796
796
|
let xCenter = 0;
|
|
797
797
|
let xSpan = 60;
|
|
798
|
+
let followLatest = true;
|
|
799
|
+
let followingLatestChangeHandler = null;
|
|
800
|
+
const updateFollowLatest = (next) => {
|
|
801
|
+
if (followLatest === next) return;
|
|
802
|
+
followLatest = next;
|
|
803
|
+
followingLatestChangeHandler?.(next);
|
|
804
|
+
};
|
|
798
805
|
let yMinOverride = null;
|
|
799
806
|
let yMaxOverride = null;
|
|
800
807
|
let autoYMin = null;
|
|
@@ -2126,6 +2133,7 @@ function createChart(element, options = {}) {
|
|
|
2126
2133
|
xSpan = nextSpan;
|
|
2127
2134
|
xCenter = nextStart + nextSpan / 2;
|
|
2128
2135
|
clampXViewport();
|
|
2136
|
+
updateFollowLatest(false);
|
|
2129
2137
|
draw();
|
|
2130
2138
|
};
|
|
2131
2139
|
const zoomXToLatest = (factor) => {
|
|
@@ -2170,6 +2178,9 @@ function createChart(element, options = {}) {
|
|
|
2170
2178
|
const indexShift = deltaX / drawState.chartWidth * xSpan;
|
|
2171
2179
|
xCenter -= indexShift;
|
|
2172
2180
|
clampXViewport();
|
|
2181
|
+
if (deltaX !== 0) {
|
|
2182
|
+
updateFollowLatest(false);
|
|
2183
|
+
}
|
|
2173
2184
|
}
|
|
2174
2185
|
if (allowY) {
|
|
2175
2186
|
const currentMin = yMinOverride ?? drawState.yMin;
|
|
@@ -2218,6 +2229,7 @@ function createChart(element, options = {}) {
|
|
|
2218
2229
|
}
|
|
2219
2230
|
xCenter += bars;
|
|
2220
2231
|
clampXViewport();
|
|
2232
|
+
updateFollowLatest(false);
|
|
2221
2233
|
draw();
|
|
2222
2234
|
};
|
|
2223
2235
|
const panY = (priceDelta) => {
|
|
@@ -2233,13 +2245,29 @@ function createChart(element, options = {}) {
|
|
|
2233
2245
|
};
|
|
2234
2246
|
const fitContent = () => {
|
|
2235
2247
|
fitXViewport();
|
|
2248
|
+
updateFollowLatest(true);
|
|
2236
2249
|
draw();
|
|
2237
2250
|
};
|
|
2238
2251
|
const resetViewport = () => {
|
|
2239
2252
|
fitXViewport();
|
|
2240
2253
|
resetYViewport();
|
|
2254
|
+
updateFollowLatest(true);
|
|
2241
2255
|
draw();
|
|
2242
2256
|
};
|
|
2257
|
+
const isFollowingLatest = () => followLatest;
|
|
2258
|
+
const setFollowingLatest = (follow) => {
|
|
2259
|
+
if (follow && data.length > 0) {
|
|
2260
|
+
xCenter = data.length - xSpan / 2 + rightEdgePaddingBars;
|
|
2261
|
+
clampXViewport();
|
|
2262
|
+
updateFollowLatest(true);
|
|
2263
|
+
draw();
|
|
2264
|
+
} else {
|
|
2265
|
+
updateFollowLatest(follow);
|
|
2266
|
+
}
|
|
2267
|
+
};
|
|
2268
|
+
const onFollowingLatestChange = (handler) => {
|
|
2269
|
+
followingLatestChangeHandler = handler;
|
|
2270
|
+
};
|
|
2243
2271
|
const getCanvasPoint = (event) => {
|
|
2244
2272
|
const rect = canvas.getBoundingClientRect();
|
|
2245
2273
|
return {
|
|
@@ -2658,9 +2686,7 @@ function createChart(element, options = {}) {
|
|
|
2658
2686
|
resetYViewport();
|
|
2659
2687
|
} else {
|
|
2660
2688
|
if (mergedOptions.preserveViewportOnDataUpdate) {
|
|
2661
|
-
|
|
2662
|
-
const wasAtRightEdge = hasNewBars && xCenter + xSpan / 2 >= previousCount - 1;
|
|
2663
|
-
if (wasAtRightEdge) {
|
|
2689
|
+
if (followLatest) {
|
|
2664
2690
|
xCenter = data.length - xSpan / 2 + rightEdgePaddingBars;
|
|
2665
2691
|
} else if (previousCenterTimeMs !== null) {
|
|
2666
2692
|
const nextCenter = findNearestIndexForTimeMs(previousCenterTimeMs);
|
|
@@ -2854,6 +2880,9 @@ function createChart(element, options = {}) {
|
|
|
2854
2880
|
panY,
|
|
2855
2881
|
resetViewport,
|
|
2856
2882
|
fitContent,
|
|
2883
|
+
isFollowingLatest,
|
|
2884
|
+
setFollowingLatest,
|
|
2885
|
+
onFollowingLatestChange,
|
|
2857
2886
|
setDoubleClickEnabled,
|
|
2858
2887
|
setDoubleClickAction,
|
|
2859
2888
|
registerIndicator,
|
package/dist/index.cjs
CHANGED
|
@@ -819,6 +819,13 @@ function createChart(element, options = {}) {
|
|
|
819
819
|
const orderPriceTagWidthById = /* @__PURE__ */ new Map();
|
|
820
820
|
let xCenter = 0;
|
|
821
821
|
let xSpan = 60;
|
|
822
|
+
let followLatest = true;
|
|
823
|
+
let followingLatestChangeHandler = null;
|
|
824
|
+
const updateFollowLatest = (next) => {
|
|
825
|
+
if (followLatest === next) return;
|
|
826
|
+
followLatest = next;
|
|
827
|
+
followingLatestChangeHandler?.(next);
|
|
828
|
+
};
|
|
822
829
|
let yMinOverride = null;
|
|
823
830
|
let yMaxOverride = null;
|
|
824
831
|
let autoYMin = null;
|
|
@@ -2150,6 +2157,7 @@ function createChart(element, options = {}) {
|
|
|
2150
2157
|
xSpan = nextSpan;
|
|
2151
2158
|
xCenter = nextStart + nextSpan / 2;
|
|
2152
2159
|
clampXViewport();
|
|
2160
|
+
updateFollowLatest(false);
|
|
2153
2161
|
draw();
|
|
2154
2162
|
};
|
|
2155
2163
|
const zoomXToLatest = (factor) => {
|
|
@@ -2194,6 +2202,9 @@ function createChart(element, options = {}) {
|
|
|
2194
2202
|
const indexShift = deltaX / drawState.chartWidth * xSpan;
|
|
2195
2203
|
xCenter -= indexShift;
|
|
2196
2204
|
clampXViewport();
|
|
2205
|
+
if (deltaX !== 0) {
|
|
2206
|
+
updateFollowLatest(false);
|
|
2207
|
+
}
|
|
2197
2208
|
}
|
|
2198
2209
|
if (allowY) {
|
|
2199
2210
|
const currentMin = yMinOverride ?? drawState.yMin;
|
|
@@ -2242,6 +2253,7 @@ function createChart(element, options = {}) {
|
|
|
2242
2253
|
}
|
|
2243
2254
|
xCenter += bars;
|
|
2244
2255
|
clampXViewport();
|
|
2256
|
+
updateFollowLatest(false);
|
|
2245
2257
|
draw();
|
|
2246
2258
|
};
|
|
2247
2259
|
const panY = (priceDelta) => {
|
|
@@ -2257,13 +2269,29 @@ function createChart(element, options = {}) {
|
|
|
2257
2269
|
};
|
|
2258
2270
|
const fitContent = () => {
|
|
2259
2271
|
fitXViewport();
|
|
2272
|
+
updateFollowLatest(true);
|
|
2260
2273
|
draw();
|
|
2261
2274
|
};
|
|
2262
2275
|
const resetViewport = () => {
|
|
2263
2276
|
fitXViewport();
|
|
2264
2277
|
resetYViewport();
|
|
2278
|
+
updateFollowLatest(true);
|
|
2265
2279
|
draw();
|
|
2266
2280
|
};
|
|
2281
|
+
const isFollowingLatest = () => followLatest;
|
|
2282
|
+
const setFollowingLatest = (follow) => {
|
|
2283
|
+
if (follow && data.length > 0) {
|
|
2284
|
+
xCenter = data.length - xSpan / 2 + rightEdgePaddingBars;
|
|
2285
|
+
clampXViewport();
|
|
2286
|
+
updateFollowLatest(true);
|
|
2287
|
+
draw();
|
|
2288
|
+
} else {
|
|
2289
|
+
updateFollowLatest(follow);
|
|
2290
|
+
}
|
|
2291
|
+
};
|
|
2292
|
+
const onFollowingLatestChange = (handler) => {
|
|
2293
|
+
followingLatestChangeHandler = handler;
|
|
2294
|
+
};
|
|
2267
2295
|
const getCanvasPoint = (event) => {
|
|
2268
2296
|
const rect = canvas.getBoundingClientRect();
|
|
2269
2297
|
return {
|
|
@@ -2682,9 +2710,7 @@ function createChart(element, options = {}) {
|
|
|
2682
2710
|
resetYViewport();
|
|
2683
2711
|
} else {
|
|
2684
2712
|
if (mergedOptions.preserveViewportOnDataUpdate) {
|
|
2685
|
-
|
|
2686
|
-
const wasAtRightEdge = hasNewBars && xCenter + xSpan / 2 >= previousCount - 1;
|
|
2687
|
-
if (wasAtRightEdge) {
|
|
2713
|
+
if (followLatest) {
|
|
2688
2714
|
xCenter = data.length - xSpan / 2 + rightEdgePaddingBars;
|
|
2689
2715
|
} else if (previousCenterTimeMs !== null) {
|
|
2690
2716
|
const nextCenter = findNearestIndexForTimeMs(previousCenterTimeMs);
|
|
@@ -2878,6 +2904,9 @@ function createChart(element, options = {}) {
|
|
|
2878
2904
|
panY,
|
|
2879
2905
|
resetViewport,
|
|
2880
2906
|
fitContent,
|
|
2907
|
+
isFollowingLatest,
|
|
2908
|
+
setFollowingLatest,
|
|
2909
|
+
onFollowingLatestChange,
|
|
2881
2910
|
setDoubleClickEnabled,
|
|
2882
2911
|
setDoubleClickAction,
|
|
2883
2912
|
registerIndicator,
|
package/dist/index.d.cts
CHANGED
|
@@ -281,6 +281,9 @@ interface ChartInstance {
|
|
|
281
281
|
panY: (priceDelta: number) => void;
|
|
282
282
|
resetViewport: () => void;
|
|
283
283
|
fitContent: () => void;
|
|
284
|
+
isFollowingLatest: () => boolean;
|
|
285
|
+
setFollowingLatest: (follow: boolean) => void;
|
|
286
|
+
onFollowingLatestChange: (handler: ((following: boolean) => void) | null) => void;
|
|
284
287
|
setDoubleClickEnabled: (enabled: boolean) => void;
|
|
285
288
|
setDoubleClickAction: (action: "reset" | "placeLimitOrder") => void;
|
|
286
289
|
registerIndicator: (plugin: IndicatorPlugin<any>) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -281,6 +281,9 @@ interface ChartInstance {
|
|
|
281
281
|
panY: (priceDelta: number) => void;
|
|
282
282
|
resetViewport: () => void;
|
|
283
283
|
fitContent: () => void;
|
|
284
|
+
isFollowingLatest: () => boolean;
|
|
285
|
+
setFollowingLatest: (follow: boolean) => void;
|
|
286
|
+
onFollowingLatestChange: (handler: ((following: boolean) => void) | null) => void;
|
|
284
287
|
setDoubleClickEnabled: (enabled: boolean) => void;
|
|
285
288
|
setDoubleClickAction: (action: "reset" | "placeLimitOrder") => void;
|
|
286
289
|
registerIndicator: (plugin: IndicatorPlugin<any>) => void;
|
package/dist/index.js
CHANGED
|
@@ -795,6 +795,13 @@ function createChart(element, options = {}) {
|
|
|
795
795
|
const orderPriceTagWidthById = /* @__PURE__ */ new Map();
|
|
796
796
|
let xCenter = 0;
|
|
797
797
|
let xSpan = 60;
|
|
798
|
+
let followLatest = true;
|
|
799
|
+
let followingLatestChangeHandler = null;
|
|
800
|
+
const updateFollowLatest = (next) => {
|
|
801
|
+
if (followLatest === next) return;
|
|
802
|
+
followLatest = next;
|
|
803
|
+
followingLatestChangeHandler?.(next);
|
|
804
|
+
};
|
|
798
805
|
let yMinOverride = null;
|
|
799
806
|
let yMaxOverride = null;
|
|
800
807
|
let autoYMin = null;
|
|
@@ -2126,6 +2133,7 @@ function createChart(element, options = {}) {
|
|
|
2126
2133
|
xSpan = nextSpan;
|
|
2127
2134
|
xCenter = nextStart + nextSpan / 2;
|
|
2128
2135
|
clampXViewport();
|
|
2136
|
+
updateFollowLatest(false);
|
|
2129
2137
|
draw();
|
|
2130
2138
|
};
|
|
2131
2139
|
const zoomXToLatest = (factor) => {
|
|
@@ -2170,6 +2178,9 @@ function createChart(element, options = {}) {
|
|
|
2170
2178
|
const indexShift = deltaX / drawState.chartWidth * xSpan;
|
|
2171
2179
|
xCenter -= indexShift;
|
|
2172
2180
|
clampXViewport();
|
|
2181
|
+
if (deltaX !== 0) {
|
|
2182
|
+
updateFollowLatest(false);
|
|
2183
|
+
}
|
|
2173
2184
|
}
|
|
2174
2185
|
if (allowY) {
|
|
2175
2186
|
const currentMin = yMinOverride ?? drawState.yMin;
|
|
@@ -2218,6 +2229,7 @@ function createChart(element, options = {}) {
|
|
|
2218
2229
|
}
|
|
2219
2230
|
xCenter += bars;
|
|
2220
2231
|
clampXViewport();
|
|
2232
|
+
updateFollowLatest(false);
|
|
2221
2233
|
draw();
|
|
2222
2234
|
};
|
|
2223
2235
|
const panY = (priceDelta) => {
|
|
@@ -2233,13 +2245,29 @@ function createChart(element, options = {}) {
|
|
|
2233
2245
|
};
|
|
2234
2246
|
const fitContent = () => {
|
|
2235
2247
|
fitXViewport();
|
|
2248
|
+
updateFollowLatest(true);
|
|
2236
2249
|
draw();
|
|
2237
2250
|
};
|
|
2238
2251
|
const resetViewport = () => {
|
|
2239
2252
|
fitXViewport();
|
|
2240
2253
|
resetYViewport();
|
|
2254
|
+
updateFollowLatest(true);
|
|
2241
2255
|
draw();
|
|
2242
2256
|
};
|
|
2257
|
+
const isFollowingLatest = () => followLatest;
|
|
2258
|
+
const setFollowingLatest = (follow) => {
|
|
2259
|
+
if (follow && data.length > 0) {
|
|
2260
|
+
xCenter = data.length - xSpan / 2 + rightEdgePaddingBars;
|
|
2261
|
+
clampXViewport();
|
|
2262
|
+
updateFollowLatest(true);
|
|
2263
|
+
draw();
|
|
2264
|
+
} else {
|
|
2265
|
+
updateFollowLatest(follow);
|
|
2266
|
+
}
|
|
2267
|
+
};
|
|
2268
|
+
const onFollowingLatestChange = (handler) => {
|
|
2269
|
+
followingLatestChangeHandler = handler;
|
|
2270
|
+
};
|
|
2243
2271
|
const getCanvasPoint = (event) => {
|
|
2244
2272
|
const rect = canvas.getBoundingClientRect();
|
|
2245
2273
|
return {
|
|
@@ -2658,9 +2686,7 @@ function createChart(element, options = {}) {
|
|
|
2658
2686
|
resetYViewport();
|
|
2659
2687
|
} else {
|
|
2660
2688
|
if (mergedOptions.preserveViewportOnDataUpdate) {
|
|
2661
|
-
|
|
2662
|
-
const wasAtRightEdge = hasNewBars && xCenter + xSpan / 2 >= previousCount - 1;
|
|
2663
|
-
if (wasAtRightEdge) {
|
|
2689
|
+
if (followLatest) {
|
|
2664
2690
|
xCenter = data.length - xSpan / 2 + rightEdgePaddingBars;
|
|
2665
2691
|
} else if (previousCenterTimeMs !== null) {
|
|
2666
2692
|
const nextCenter = findNearestIndexForTimeMs(previousCenterTimeMs);
|
|
@@ -2854,6 +2880,9 @@ function createChart(element, options = {}) {
|
|
|
2854
2880
|
panY,
|
|
2855
2881
|
resetViewport,
|
|
2856
2882
|
fitContent,
|
|
2883
|
+
isFollowingLatest,
|
|
2884
|
+
setFollowingLatest,
|
|
2885
|
+
onFollowingLatestChange,
|
|
2857
2886
|
setDoubleClickEnabled,
|
|
2858
2887
|
setDoubleClickAction,
|
|
2859
2888
|
registerIndicator,
|