@adrienhobbs/candlekit 0.2.2 → 0.2.3
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/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -346,6 +346,12 @@ function ChartComponent({
|
|
|
346
346
|
vertLines: { color: "#1e293b" },
|
|
347
347
|
horzLines: { color: "#1e293b" }
|
|
348
348
|
},
|
|
349
|
+
// Render axis ticks + crosshair in the viewer's LOCAL timezone (lightweight-
|
|
350
|
+
// charts otherwise renders numeric times as UTC, which mismatches any
|
|
351
|
+
// local-time table/labels alongside the chart).
|
|
352
|
+
localization: {
|
|
353
|
+
timeFormatter: localCrosshairTimeFormatter
|
|
354
|
+
},
|
|
349
355
|
width: chartContainerRef.current.clientWidth,
|
|
350
356
|
// Auto-fill the container's height unless an explicit `height` is given.
|
|
351
357
|
// Fall back to 600 only when the container hasn't been laid out yet (a
|
|
@@ -354,7 +360,8 @@ function ChartComponent({
|
|
|
354
360
|
timeScale: {
|
|
355
361
|
timeVisible: true,
|
|
356
362
|
secondsVisible: true,
|
|
357
|
-
borderColor: "#334155"
|
|
363
|
+
borderColor: "#334155",
|
|
364
|
+
tickMarkFormatter: localTickMarkFormatter
|
|
358
365
|
},
|
|
359
366
|
rightPriceScale: {
|
|
360
367
|
borderColor: "#334155"
|
|
@@ -1007,6 +1014,31 @@ function getLineStyle(style) {
|
|
|
1007
1014
|
return LineStyle.Solid;
|
|
1008
1015
|
}
|
|
1009
1016
|
}
|
|
1017
|
+
var pad2 = (n) => String(n).padStart(2, "0");
|
|
1018
|
+
function localTickMarkFormatter(time, tickMarkType) {
|
|
1019
|
+
const d = new Date(time * 1e3);
|
|
1020
|
+
switch (tickMarkType) {
|
|
1021
|
+
case 0:
|
|
1022
|
+
return String(d.getFullYear());
|
|
1023
|
+
case 1:
|
|
1024
|
+
return d.toLocaleString(void 0, { month: "short" });
|
|
1025
|
+
case 2:
|
|
1026
|
+
return d.toLocaleString(void 0, { month: "short", day: "numeric" });
|
|
1027
|
+
case 4:
|
|
1028
|
+
return `${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`;
|
|
1029
|
+
default:
|
|
1030
|
+
return `${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
function localCrosshairTimeFormatter(time) {
|
|
1034
|
+
return new Date(time * 1e3).toLocaleString(void 0, {
|
|
1035
|
+
month: "short",
|
|
1036
|
+
day: "2-digit",
|
|
1037
|
+
hour: "2-digit",
|
|
1038
|
+
minute: "2-digit",
|
|
1039
|
+
hour12: false
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1010
1042
|
var IndicatorCategory = /* @__PURE__ */ ((IndicatorCategory2) => {
|
|
1011
1043
|
IndicatorCategory2["TREND"] = "Trend";
|
|
1012
1044
|
IndicatorCategory2["MOMENTUM"] = "Momentum";
|