hyperprop-charting-library 0.1.103 → 0.1.104
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 +17 -6
- package/dist/hyperprop-charting-library.js +17 -6
- package/dist/index.cjs +17 -6
- package/dist/index.js +17 -6
- package/package.json +1 -1
|
@@ -1292,10 +1292,19 @@ function createChart(element, options = {}) {
|
|
|
1292
1292
|
}
|
|
1293
1293
|
return Math.round(price / tickSize) * tickSize;
|
|
1294
1294
|
};
|
|
1295
|
+
const groupThousands = (value, decimals) => {
|
|
1296
|
+
const negative = value < 0;
|
|
1297
|
+
const fixed = Math.abs(value).toFixed(decimals);
|
|
1298
|
+
const dot = fixed.indexOf(".");
|
|
1299
|
+
const intPart = dot === -1 ? fixed : fixed.slice(0, dot);
|
|
1300
|
+
const decPart = dot === -1 ? "" : fixed.slice(dot);
|
|
1301
|
+
const grouped = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1302
|
+
return `${negative ? "-" : ""}${grouped}${decPart}`;
|
|
1303
|
+
};
|
|
1295
1304
|
const formatPrice = (price) => {
|
|
1296
1305
|
const rounded = quantizeToTickSize(price);
|
|
1297
1306
|
const decimals = getDisplayPriceDecimals();
|
|
1298
|
-
return rounded
|
|
1307
|
+
return groupThousands(rounded, decimals);
|
|
1299
1308
|
};
|
|
1300
1309
|
const roundToPricePrecision = (price) => {
|
|
1301
1310
|
const rounded = quantizeToTickSize(price);
|
|
@@ -1333,7 +1342,7 @@ function createChart(element, options = {}) {
|
|
|
1333
1342
|
}
|
|
1334
1343
|
const observedDigits = maxAbsPrice >= 1 ? Math.floor(Math.log10(maxAbsPrice)) + 1 : 1;
|
|
1335
1344
|
const integerDigits = Math.max(configuredDigits, observedDigits);
|
|
1336
|
-
const integerPart = "8".repeat(integerDigits);
|
|
1345
|
+
const integerPart = "8".repeat(integerDigits).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1337
1346
|
const decimalPart = decimals > 0 ? `.${"8".repeat(decimals)}` : "";
|
|
1338
1347
|
return `${integerPart}${decimalPart}`;
|
|
1339
1348
|
};
|
|
@@ -3432,16 +3441,18 @@ function createChart(element, options = {}) {
|
|
|
3432
3441
|
ctx.font = prevFont;
|
|
3433
3442
|
}
|
|
3434
3443
|
}
|
|
3444
|
+
const axisStepMs = getTimeStepMs();
|
|
3445
|
+
const axisIntraday = axisStepMs > 0 && axisStepMs < 24 * 60 * 60 * 1e3;
|
|
3446
|
+
let prevAxisTickTime = null;
|
|
3435
3447
|
for (let index = tickStartIndex; index <= visibleTickEnd; index += xStep) {
|
|
3436
3448
|
const tickTime = getTimeForIndex(index);
|
|
3437
3449
|
if (!tickTime) {
|
|
3438
3450
|
continue;
|
|
3439
3451
|
}
|
|
3440
3452
|
const x = chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth;
|
|
3441
|
-
const
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
});
|
|
3453
|
+
const isNewDay = !prevAxisTickTime || prevAxisTickTime.getDate() !== tickTime.getDate() || prevAxisTickTime.getMonth() !== tickTime.getMonth() || prevAxisTickTime.getFullYear() !== tickTime.getFullYear();
|
|
3454
|
+
const timeLabel = axisIntraday && !isNewDay ? tickTime.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit", hour12: false }) : tickTime.toLocaleDateString(void 0, { month: "short", day: "numeric" });
|
|
3455
|
+
prevAxisTickTime = tickTime;
|
|
3445
3456
|
const prevFont = ctx.font;
|
|
3446
3457
|
ctx.font = `${xAxisFontSize}px ${mergedOptions.fontFamily}`;
|
|
3447
3458
|
drawText(timeLabel, x, fullChartBottom + 8, "center", "top", xAxis.textColor);
|
|
@@ -1266,10 +1266,19 @@ function createChart(element, options = {}) {
|
|
|
1266
1266
|
}
|
|
1267
1267
|
return Math.round(price / tickSize) * tickSize;
|
|
1268
1268
|
};
|
|
1269
|
+
const groupThousands = (value, decimals) => {
|
|
1270
|
+
const negative = value < 0;
|
|
1271
|
+
const fixed = Math.abs(value).toFixed(decimals);
|
|
1272
|
+
const dot = fixed.indexOf(".");
|
|
1273
|
+
const intPart = dot === -1 ? fixed : fixed.slice(0, dot);
|
|
1274
|
+
const decPart = dot === -1 ? "" : fixed.slice(dot);
|
|
1275
|
+
const grouped = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1276
|
+
return `${negative ? "-" : ""}${grouped}${decPart}`;
|
|
1277
|
+
};
|
|
1269
1278
|
const formatPrice = (price) => {
|
|
1270
1279
|
const rounded = quantizeToTickSize(price);
|
|
1271
1280
|
const decimals = getDisplayPriceDecimals();
|
|
1272
|
-
return rounded
|
|
1281
|
+
return groupThousands(rounded, decimals);
|
|
1273
1282
|
};
|
|
1274
1283
|
const roundToPricePrecision = (price) => {
|
|
1275
1284
|
const rounded = quantizeToTickSize(price);
|
|
@@ -1307,7 +1316,7 @@ function createChart(element, options = {}) {
|
|
|
1307
1316
|
}
|
|
1308
1317
|
const observedDigits = maxAbsPrice >= 1 ? Math.floor(Math.log10(maxAbsPrice)) + 1 : 1;
|
|
1309
1318
|
const integerDigits = Math.max(configuredDigits, observedDigits);
|
|
1310
|
-
const integerPart = "8".repeat(integerDigits);
|
|
1319
|
+
const integerPart = "8".repeat(integerDigits).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1311
1320
|
const decimalPart = decimals > 0 ? `.${"8".repeat(decimals)}` : "";
|
|
1312
1321
|
return `${integerPart}${decimalPart}`;
|
|
1313
1322
|
};
|
|
@@ -3406,16 +3415,18 @@ function createChart(element, options = {}) {
|
|
|
3406
3415
|
ctx.font = prevFont;
|
|
3407
3416
|
}
|
|
3408
3417
|
}
|
|
3418
|
+
const axisStepMs = getTimeStepMs();
|
|
3419
|
+
const axisIntraday = axisStepMs > 0 && axisStepMs < 24 * 60 * 60 * 1e3;
|
|
3420
|
+
let prevAxisTickTime = null;
|
|
3409
3421
|
for (let index = tickStartIndex; index <= visibleTickEnd; index += xStep) {
|
|
3410
3422
|
const tickTime = getTimeForIndex(index);
|
|
3411
3423
|
if (!tickTime) {
|
|
3412
3424
|
continue;
|
|
3413
3425
|
}
|
|
3414
3426
|
const x = chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth;
|
|
3415
|
-
const
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
});
|
|
3427
|
+
const isNewDay = !prevAxisTickTime || prevAxisTickTime.getDate() !== tickTime.getDate() || prevAxisTickTime.getMonth() !== tickTime.getMonth() || prevAxisTickTime.getFullYear() !== tickTime.getFullYear();
|
|
3428
|
+
const timeLabel = axisIntraday && !isNewDay ? tickTime.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit", hour12: false }) : tickTime.toLocaleDateString(void 0, { month: "short", day: "numeric" });
|
|
3429
|
+
prevAxisTickTime = tickTime;
|
|
3419
3430
|
const prevFont = ctx.font;
|
|
3420
3431
|
ctx.font = `${xAxisFontSize}px ${mergedOptions.fontFamily}`;
|
|
3421
3432
|
drawText(timeLabel, x, fullChartBottom + 8, "center", "top", xAxis.textColor);
|
package/dist/index.cjs
CHANGED
|
@@ -1292,10 +1292,19 @@ function createChart(element, options = {}) {
|
|
|
1292
1292
|
}
|
|
1293
1293
|
return Math.round(price / tickSize) * tickSize;
|
|
1294
1294
|
};
|
|
1295
|
+
const groupThousands = (value, decimals) => {
|
|
1296
|
+
const negative = value < 0;
|
|
1297
|
+
const fixed = Math.abs(value).toFixed(decimals);
|
|
1298
|
+
const dot = fixed.indexOf(".");
|
|
1299
|
+
const intPart = dot === -1 ? fixed : fixed.slice(0, dot);
|
|
1300
|
+
const decPart = dot === -1 ? "" : fixed.slice(dot);
|
|
1301
|
+
const grouped = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1302
|
+
return `${negative ? "-" : ""}${grouped}${decPart}`;
|
|
1303
|
+
};
|
|
1295
1304
|
const formatPrice = (price) => {
|
|
1296
1305
|
const rounded = quantizeToTickSize(price);
|
|
1297
1306
|
const decimals = getDisplayPriceDecimals();
|
|
1298
|
-
return rounded
|
|
1307
|
+
return groupThousands(rounded, decimals);
|
|
1299
1308
|
};
|
|
1300
1309
|
const roundToPricePrecision = (price) => {
|
|
1301
1310
|
const rounded = quantizeToTickSize(price);
|
|
@@ -1333,7 +1342,7 @@ function createChart(element, options = {}) {
|
|
|
1333
1342
|
}
|
|
1334
1343
|
const observedDigits = maxAbsPrice >= 1 ? Math.floor(Math.log10(maxAbsPrice)) + 1 : 1;
|
|
1335
1344
|
const integerDigits = Math.max(configuredDigits, observedDigits);
|
|
1336
|
-
const integerPart = "8".repeat(integerDigits);
|
|
1345
|
+
const integerPart = "8".repeat(integerDigits).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1337
1346
|
const decimalPart = decimals > 0 ? `.${"8".repeat(decimals)}` : "";
|
|
1338
1347
|
return `${integerPart}${decimalPart}`;
|
|
1339
1348
|
};
|
|
@@ -3432,16 +3441,18 @@ function createChart(element, options = {}) {
|
|
|
3432
3441
|
ctx.font = prevFont;
|
|
3433
3442
|
}
|
|
3434
3443
|
}
|
|
3444
|
+
const axisStepMs = getTimeStepMs();
|
|
3445
|
+
const axisIntraday = axisStepMs > 0 && axisStepMs < 24 * 60 * 60 * 1e3;
|
|
3446
|
+
let prevAxisTickTime = null;
|
|
3435
3447
|
for (let index = tickStartIndex; index <= visibleTickEnd; index += xStep) {
|
|
3436
3448
|
const tickTime = getTimeForIndex(index);
|
|
3437
3449
|
if (!tickTime) {
|
|
3438
3450
|
continue;
|
|
3439
3451
|
}
|
|
3440
3452
|
const x = chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth;
|
|
3441
|
-
const
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
});
|
|
3453
|
+
const isNewDay = !prevAxisTickTime || prevAxisTickTime.getDate() !== tickTime.getDate() || prevAxisTickTime.getMonth() !== tickTime.getMonth() || prevAxisTickTime.getFullYear() !== tickTime.getFullYear();
|
|
3454
|
+
const timeLabel = axisIntraday && !isNewDay ? tickTime.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit", hour12: false }) : tickTime.toLocaleDateString(void 0, { month: "short", day: "numeric" });
|
|
3455
|
+
prevAxisTickTime = tickTime;
|
|
3445
3456
|
const prevFont = ctx.font;
|
|
3446
3457
|
ctx.font = `${xAxisFontSize}px ${mergedOptions.fontFamily}`;
|
|
3447
3458
|
drawText(timeLabel, x, fullChartBottom + 8, "center", "top", xAxis.textColor);
|
package/dist/index.js
CHANGED
|
@@ -1266,10 +1266,19 @@ function createChart(element, options = {}) {
|
|
|
1266
1266
|
}
|
|
1267
1267
|
return Math.round(price / tickSize) * tickSize;
|
|
1268
1268
|
};
|
|
1269
|
+
const groupThousands = (value, decimals) => {
|
|
1270
|
+
const negative = value < 0;
|
|
1271
|
+
const fixed = Math.abs(value).toFixed(decimals);
|
|
1272
|
+
const dot = fixed.indexOf(".");
|
|
1273
|
+
const intPart = dot === -1 ? fixed : fixed.slice(0, dot);
|
|
1274
|
+
const decPart = dot === -1 ? "" : fixed.slice(dot);
|
|
1275
|
+
const grouped = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1276
|
+
return `${negative ? "-" : ""}${grouped}${decPart}`;
|
|
1277
|
+
};
|
|
1269
1278
|
const formatPrice = (price) => {
|
|
1270
1279
|
const rounded = quantizeToTickSize(price);
|
|
1271
1280
|
const decimals = getDisplayPriceDecimals();
|
|
1272
|
-
return rounded
|
|
1281
|
+
return groupThousands(rounded, decimals);
|
|
1273
1282
|
};
|
|
1274
1283
|
const roundToPricePrecision = (price) => {
|
|
1275
1284
|
const rounded = quantizeToTickSize(price);
|
|
@@ -1307,7 +1316,7 @@ function createChart(element, options = {}) {
|
|
|
1307
1316
|
}
|
|
1308
1317
|
const observedDigits = maxAbsPrice >= 1 ? Math.floor(Math.log10(maxAbsPrice)) + 1 : 1;
|
|
1309
1318
|
const integerDigits = Math.max(configuredDigits, observedDigits);
|
|
1310
|
-
const integerPart = "8".repeat(integerDigits);
|
|
1319
|
+
const integerPart = "8".repeat(integerDigits).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1311
1320
|
const decimalPart = decimals > 0 ? `.${"8".repeat(decimals)}` : "";
|
|
1312
1321
|
return `${integerPart}${decimalPart}`;
|
|
1313
1322
|
};
|
|
@@ -3406,16 +3415,18 @@ function createChart(element, options = {}) {
|
|
|
3406
3415
|
ctx.font = prevFont;
|
|
3407
3416
|
}
|
|
3408
3417
|
}
|
|
3418
|
+
const axisStepMs = getTimeStepMs();
|
|
3419
|
+
const axisIntraday = axisStepMs > 0 && axisStepMs < 24 * 60 * 60 * 1e3;
|
|
3420
|
+
let prevAxisTickTime = null;
|
|
3409
3421
|
for (let index = tickStartIndex; index <= visibleTickEnd; index += xStep) {
|
|
3410
3422
|
const tickTime = getTimeForIndex(index);
|
|
3411
3423
|
if (!tickTime) {
|
|
3412
3424
|
continue;
|
|
3413
3425
|
}
|
|
3414
3426
|
const x = chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth;
|
|
3415
|
-
const
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
});
|
|
3427
|
+
const isNewDay = !prevAxisTickTime || prevAxisTickTime.getDate() !== tickTime.getDate() || prevAxisTickTime.getMonth() !== tickTime.getMonth() || prevAxisTickTime.getFullYear() !== tickTime.getFullYear();
|
|
3428
|
+
const timeLabel = axisIntraday && !isNewDay ? tickTime.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit", hour12: false }) : tickTime.toLocaleDateString(void 0, { month: "short", day: "numeric" });
|
|
3429
|
+
prevAxisTickTime = tickTime;
|
|
3419
3430
|
const prevFont = ctx.font;
|
|
3420
3431
|
ctx.font = `${xAxisFontSize}px ${mergedOptions.fontFamily}`;
|
|
3421
3432
|
drawText(timeLabel, x, fullChartBottom + 8, "center", "top", xAxis.textColor);
|