hyperprop-charting-library 0.1.156 → 0.1.157
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 +33 -14
- package/dist/hyperprop-charting-library.d.ts +18 -1
- package/dist/hyperprop-charting-library.js +33 -14
- package/dist/index.cjs +33 -14
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +33 -14
- package/package.json +1 -1
|
@@ -8480,30 +8480,42 @@ function createChart(element, options = {}) {
|
|
|
8480
8480
|
ctx.fill();
|
|
8481
8481
|
cursorX += dotRadius * 2 + 6;
|
|
8482
8482
|
}
|
|
8483
|
-
const headline = [
|
|
8483
|
+
const headline = [
|
|
8484
|
+
dataLine.symbol,
|
|
8485
|
+
dataLine.description,
|
|
8486
|
+
dataLine.interval,
|
|
8487
|
+
dataLine.exchange,
|
|
8488
|
+
dataLine.chartTypeLabel
|
|
8489
|
+
].filter((part) => part && part.length > 0).join(" \xB7 ");
|
|
8484
8490
|
if (headline) {
|
|
8485
8491
|
ctx.fillStyle = symbolColor;
|
|
8486
8492
|
ctx.fillText(headline, cursorX, rowY);
|
|
8487
|
-
cursorX += measureTextWidth(headline) +
|
|
8493
|
+
cursorX += measureTextWidth(headline) + 12;
|
|
8488
8494
|
}
|
|
8489
8495
|
if (dataLine.showOhlc !== false) {
|
|
8490
|
-
const
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8496
|
+
const ohlcLabelColor = dataLine.ohlcLabelColor || textColor;
|
|
8497
|
+
const pairs = [
|
|
8498
|
+
["O", formatPrice(bar.o)],
|
|
8499
|
+
["H", formatPrice(bar.h)],
|
|
8500
|
+
["L", formatPrice(bar.l)],
|
|
8501
|
+
["C", formatPrice(bar.c)]
|
|
8502
|
+
];
|
|
8503
|
+
for (const [label, value] of pairs) {
|
|
8504
|
+
ctx.fillStyle = ohlcLabelColor;
|
|
8505
|
+
ctx.fillText(label, cursorX, rowY);
|
|
8506
|
+
cursorX += measureTextWidth(label) + 2;
|
|
8507
|
+
ctx.fillStyle = changeColor;
|
|
8508
|
+
ctx.fillText(value, cursorX, rowY);
|
|
8509
|
+
cursorX += measureTextWidth(value) + 9;
|
|
8510
|
+
}
|
|
8511
|
+
cursorX += 3;
|
|
8494
8512
|
}
|
|
8495
8513
|
if (dataLine.showChange !== false) {
|
|
8496
8514
|
const pct = bar.o !== 0 ? changeAbs / bar.o * 100 : 0;
|
|
8497
8515
|
const changeText = `${changeAbs >= 0 ? "+" : ""}${formatPrice(changeAbs)} (${changeAbs >= 0 ? "+" : ""}${pct.toFixed(2)}%)`;
|
|
8498
8516
|
ctx.fillStyle = changeColor;
|
|
8499
8517
|
ctx.fillText(changeText, cursorX, rowY);
|
|
8500
|
-
cursorX += measureTextWidth(changeText) +
|
|
8501
|
-
}
|
|
8502
|
-
if (dataLine.showVolume && bar.v !== void 0) {
|
|
8503
|
-
const volumeText = `Vol ${bar.v >= 1e6 ? `${(bar.v / 1e6).toFixed(2)}M` : bar.v >= 1e3 ? `${(bar.v / 1e3).toFixed(1)}K` : String(Math.round(bar.v))}`;
|
|
8504
|
-
ctx.fillStyle = textColor;
|
|
8505
|
-
ctx.fillText(volumeText, cursorX, rowY);
|
|
8506
|
-
cursorX += measureTextWidth(volumeText) + 10;
|
|
8518
|
+
cursorX += measureTextWidth(changeText) + 12;
|
|
8507
8519
|
}
|
|
8508
8520
|
for (const detail of dataLine.details ?? []) {
|
|
8509
8521
|
const text = detail.label ? `${detail.label} ${detail.value}` : detail.value;
|
|
@@ -8517,7 +8529,14 @@ function createChart(element, options = {}) {
|
|
|
8517
8529
|
ctx.fillText(text, cursorX, rowY);
|
|
8518
8530
|
cursorX += width2 + 12;
|
|
8519
8531
|
}
|
|
8520
|
-
|
|
8532
|
+
let lastRowY = rowY;
|
|
8533
|
+
if (dataLine.showVolume && bar.v !== void 0) {
|
|
8534
|
+
const volumeText = `Vol ${bar.v >= 1e6 ? `${(bar.v / 1e6).toFixed(2)}M` : bar.v >= 1e3 ? `${(bar.v / 1e3).toFixed(1)}K` : String(Math.round(bar.v))}`;
|
|
8535
|
+
lastRowY = rowY + fontSize + 4;
|
|
8536
|
+
ctx.fillStyle = textColor;
|
|
8537
|
+
ctx.fillText(volumeText, chartLeft + legendInsetX, lastRowY);
|
|
8538
|
+
}
|
|
8539
|
+
dataLineBottom = lastRowY + fontSize + 6;
|
|
8521
8540
|
ctx.font = prevFont;
|
|
8522
8541
|
}
|
|
8523
8542
|
}
|
|
@@ -697,15 +697,26 @@ interface DataLineOptions {
|
|
|
697
697
|
visible?: boolean;
|
|
698
698
|
/** e.g. "NQU6" — drawn first, in the emphasis color. */
|
|
699
699
|
symbol?: string;
|
|
700
|
+
/**
|
|
701
|
+
* Long instrument name, e.g. "NASDAQ 100 E-mini Futures". Drawn after the
|
|
702
|
+
* symbol in the emphasis color, the way other charting platforms label a
|
|
703
|
+
* pane. Omit to keep the headline to the code alone.
|
|
704
|
+
*/
|
|
705
|
+
description?: string;
|
|
700
706
|
/** e.g. "1h". */
|
|
701
707
|
interval?: string;
|
|
702
708
|
/** e.g. "CME". */
|
|
703
709
|
exchange?: string;
|
|
710
|
+
/**
|
|
711
|
+
* Chart style, e.g. "Candles" or "Renko [ATR(14), 1000]" — the last part of
|
|
712
|
+
* the headline, so a non-default style is never a surprise.
|
|
713
|
+
*/
|
|
714
|
+
chartTypeLabel?: string;
|
|
704
715
|
/** O/H/L/C values for the hovered (or latest) bar. Default true. */
|
|
705
716
|
showOhlc?: boolean;
|
|
706
717
|
/** Absolute and percent change of that bar, colored by direction. Default true. */
|
|
707
718
|
showChange?: boolean;
|
|
708
|
-
/** Bar volume. Default false. */
|
|
719
|
+
/** Bar volume. Drawn on its own row beneath the values. Default false. */
|
|
709
720
|
showVolume?: boolean;
|
|
710
721
|
/**
|
|
711
722
|
* Extra chips after the values — session, currency, a "Closed" badge. Each
|
|
@@ -724,6 +735,12 @@ interface DataLineOptions {
|
|
|
724
735
|
symbolColor?: string;
|
|
725
736
|
/** Everything after the symbol. Defaults to the indicator legend color. */
|
|
726
737
|
textColor?: string;
|
|
738
|
+
/**
|
|
739
|
+
* Color of the O/H/L/C letters. Values stay colored by direction, so dimming
|
|
740
|
+
* the letters is what makes the numbers readable at a glance rather than one
|
|
741
|
+
* run of same-colored text. Defaults to `textColor`.
|
|
742
|
+
*/
|
|
743
|
+
ohlcLabelColor?: string;
|
|
727
744
|
}
|
|
728
745
|
interface IndicatorUpdateOptions {
|
|
729
746
|
/**
|
|
@@ -8441,30 +8441,42 @@ function createChart(element, options = {}) {
|
|
|
8441
8441
|
ctx.fill();
|
|
8442
8442
|
cursorX += dotRadius * 2 + 6;
|
|
8443
8443
|
}
|
|
8444
|
-
const headline = [
|
|
8444
|
+
const headline = [
|
|
8445
|
+
dataLine.symbol,
|
|
8446
|
+
dataLine.description,
|
|
8447
|
+
dataLine.interval,
|
|
8448
|
+
dataLine.exchange,
|
|
8449
|
+
dataLine.chartTypeLabel
|
|
8450
|
+
].filter((part) => part && part.length > 0).join(" \xB7 ");
|
|
8445
8451
|
if (headline) {
|
|
8446
8452
|
ctx.fillStyle = symbolColor;
|
|
8447
8453
|
ctx.fillText(headline, cursorX, rowY);
|
|
8448
|
-
cursorX += measureTextWidth(headline) +
|
|
8454
|
+
cursorX += measureTextWidth(headline) + 12;
|
|
8449
8455
|
}
|
|
8450
8456
|
if (dataLine.showOhlc !== false) {
|
|
8451
|
-
const
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8457
|
+
const ohlcLabelColor = dataLine.ohlcLabelColor || textColor;
|
|
8458
|
+
const pairs = [
|
|
8459
|
+
["O", formatPrice(bar.o)],
|
|
8460
|
+
["H", formatPrice(bar.h)],
|
|
8461
|
+
["L", formatPrice(bar.l)],
|
|
8462
|
+
["C", formatPrice(bar.c)]
|
|
8463
|
+
];
|
|
8464
|
+
for (const [label, value] of pairs) {
|
|
8465
|
+
ctx.fillStyle = ohlcLabelColor;
|
|
8466
|
+
ctx.fillText(label, cursorX, rowY);
|
|
8467
|
+
cursorX += measureTextWidth(label) + 2;
|
|
8468
|
+
ctx.fillStyle = changeColor;
|
|
8469
|
+
ctx.fillText(value, cursorX, rowY);
|
|
8470
|
+
cursorX += measureTextWidth(value) + 9;
|
|
8471
|
+
}
|
|
8472
|
+
cursorX += 3;
|
|
8455
8473
|
}
|
|
8456
8474
|
if (dataLine.showChange !== false) {
|
|
8457
8475
|
const pct = bar.o !== 0 ? changeAbs / bar.o * 100 : 0;
|
|
8458
8476
|
const changeText = `${changeAbs >= 0 ? "+" : ""}${formatPrice(changeAbs)} (${changeAbs >= 0 ? "+" : ""}${pct.toFixed(2)}%)`;
|
|
8459
8477
|
ctx.fillStyle = changeColor;
|
|
8460
8478
|
ctx.fillText(changeText, cursorX, rowY);
|
|
8461
|
-
cursorX += measureTextWidth(changeText) +
|
|
8462
|
-
}
|
|
8463
|
-
if (dataLine.showVolume && bar.v !== void 0) {
|
|
8464
|
-
const volumeText = `Vol ${bar.v >= 1e6 ? `${(bar.v / 1e6).toFixed(2)}M` : bar.v >= 1e3 ? `${(bar.v / 1e3).toFixed(1)}K` : String(Math.round(bar.v))}`;
|
|
8465
|
-
ctx.fillStyle = textColor;
|
|
8466
|
-
ctx.fillText(volumeText, cursorX, rowY);
|
|
8467
|
-
cursorX += measureTextWidth(volumeText) + 10;
|
|
8479
|
+
cursorX += measureTextWidth(changeText) + 12;
|
|
8468
8480
|
}
|
|
8469
8481
|
for (const detail of dataLine.details ?? []) {
|
|
8470
8482
|
const text = detail.label ? `${detail.label} ${detail.value}` : detail.value;
|
|
@@ -8478,7 +8490,14 @@ function createChart(element, options = {}) {
|
|
|
8478
8490
|
ctx.fillText(text, cursorX, rowY);
|
|
8479
8491
|
cursorX += width2 + 12;
|
|
8480
8492
|
}
|
|
8481
|
-
|
|
8493
|
+
let lastRowY = rowY;
|
|
8494
|
+
if (dataLine.showVolume && bar.v !== void 0) {
|
|
8495
|
+
const volumeText = `Vol ${bar.v >= 1e6 ? `${(bar.v / 1e6).toFixed(2)}M` : bar.v >= 1e3 ? `${(bar.v / 1e3).toFixed(1)}K` : String(Math.round(bar.v))}`;
|
|
8496
|
+
lastRowY = rowY + fontSize + 4;
|
|
8497
|
+
ctx.fillStyle = textColor;
|
|
8498
|
+
ctx.fillText(volumeText, chartLeft + legendInsetX, lastRowY);
|
|
8499
|
+
}
|
|
8500
|
+
dataLineBottom = lastRowY + fontSize + 6;
|
|
8482
8501
|
ctx.font = prevFont;
|
|
8483
8502
|
}
|
|
8484
8503
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -8480,30 +8480,42 @@ function createChart(element, options = {}) {
|
|
|
8480
8480
|
ctx.fill();
|
|
8481
8481
|
cursorX += dotRadius * 2 + 6;
|
|
8482
8482
|
}
|
|
8483
|
-
const headline = [
|
|
8483
|
+
const headline = [
|
|
8484
|
+
dataLine.symbol,
|
|
8485
|
+
dataLine.description,
|
|
8486
|
+
dataLine.interval,
|
|
8487
|
+
dataLine.exchange,
|
|
8488
|
+
dataLine.chartTypeLabel
|
|
8489
|
+
].filter((part) => part && part.length > 0).join(" \xB7 ");
|
|
8484
8490
|
if (headline) {
|
|
8485
8491
|
ctx.fillStyle = symbolColor;
|
|
8486
8492
|
ctx.fillText(headline, cursorX, rowY);
|
|
8487
|
-
cursorX += measureTextWidth(headline) +
|
|
8493
|
+
cursorX += measureTextWidth(headline) + 12;
|
|
8488
8494
|
}
|
|
8489
8495
|
if (dataLine.showOhlc !== false) {
|
|
8490
|
-
const
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8496
|
+
const ohlcLabelColor = dataLine.ohlcLabelColor || textColor;
|
|
8497
|
+
const pairs = [
|
|
8498
|
+
["O", formatPrice(bar.o)],
|
|
8499
|
+
["H", formatPrice(bar.h)],
|
|
8500
|
+
["L", formatPrice(bar.l)],
|
|
8501
|
+
["C", formatPrice(bar.c)]
|
|
8502
|
+
];
|
|
8503
|
+
for (const [label, value] of pairs) {
|
|
8504
|
+
ctx.fillStyle = ohlcLabelColor;
|
|
8505
|
+
ctx.fillText(label, cursorX, rowY);
|
|
8506
|
+
cursorX += measureTextWidth(label) + 2;
|
|
8507
|
+
ctx.fillStyle = changeColor;
|
|
8508
|
+
ctx.fillText(value, cursorX, rowY);
|
|
8509
|
+
cursorX += measureTextWidth(value) + 9;
|
|
8510
|
+
}
|
|
8511
|
+
cursorX += 3;
|
|
8494
8512
|
}
|
|
8495
8513
|
if (dataLine.showChange !== false) {
|
|
8496
8514
|
const pct = bar.o !== 0 ? changeAbs / bar.o * 100 : 0;
|
|
8497
8515
|
const changeText = `${changeAbs >= 0 ? "+" : ""}${formatPrice(changeAbs)} (${changeAbs >= 0 ? "+" : ""}${pct.toFixed(2)}%)`;
|
|
8498
8516
|
ctx.fillStyle = changeColor;
|
|
8499
8517
|
ctx.fillText(changeText, cursorX, rowY);
|
|
8500
|
-
cursorX += measureTextWidth(changeText) +
|
|
8501
|
-
}
|
|
8502
|
-
if (dataLine.showVolume && bar.v !== void 0) {
|
|
8503
|
-
const volumeText = `Vol ${bar.v >= 1e6 ? `${(bar.v / 1e6).toFixed(2)}M` : bar.v >= 1e3 ? `${(bar.v / 1e3).toFixed(1)}K` : String(Math.round(bar.v))}`;
|
|
8504
|
-
ctx.fillStyle = textColor;
|
|
8505
|
-
ctx.fillText(volumeText, cursorX, rowY);
|
|
8506
|
-
cursorX += measureTextWidth(volumeText) + 10;
|
|
8518
|
+
cursorX += measureTextWidth(changeText) + 12;
|
|
8507
8519
|
}
|
|
8508
8520
|
for (const detail of dataLine.details ?? []) {
|
|
8509
8521
|
const text = detail.label ? `${detail.label} ${detail.value}` : detail.value;
|
|
@@ -8517,7 +8529,14 @@ function createChart(element, options = {}) {
|
|
|
8517
8529
|
ctx.fillText(text, cursorX, rowY);
|
|
8518
8530
|
cursorX += width2 + 12;
|
|
8519
8531
|
}
|
|
8520
|
-
|
|
8532
|
+
let lastRowY = rowY;
|
|
8533
|
+
if (dataLine.showVolume && bar.v !== void 0) {
|
|
8534
|
+
const volumeText = `Vol ${bar.v >= 1e6 ? `${(bar.v / 1e6).toFixed(2)}M` : bar.v >= 1e3 ? `${(bar.v / 1e3).toFixed(1)}K` : String(Math.round(bar.v))}`;
|
|
8535
|
+
lastRowY = rowY + fontSize + 4;
|
|
8536
|
+
ctx.fillStyle = textColor;
|
|
8537
|
+
ctx.fillText(volumeText, chartLeft + legendInsetX, lastRowY);
|
|
8538
|
+
}
|
|
8539
|
+
dataLineBottom = lastRowY + fontSize + 6;
|
|
8521
8540
|
ctx.font = prevFont;
|
|
8522
8541
|
}
|
|
8523
8542
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -697,15 +697,26 @@ interface DataLineOptions {
|
|
|
697
697
|
visible?: boolean;
|
|
698
698
|
/** e.g. "NQU6" — drawn first, in the emphasis color. */
|
|
699
699
|
symbol?: string;
|
|
700
|
+
/**
|
|
701
|
+
* Long instrument name, e.g. "NASDAQ 100 E-mini Futures". Drawn after the
|
|
702
|
+
* symbol in the emphasis color, the way other charting platforms label a
|
|
703
|
+
* pane. Omit to keep the headline to the code alone.
|
|
704
|
+
*/
|
|
705
|
+
description?: string;
|
|
700
706
|
/** e.g. "1h". */
|
|
701
707
|
interval?: string;
|
|
702
708
|
/** e.g. "CME". */
|
|
703
709
|
exchange?: string;
|
|
710
|
+
/**
|
|
711
|
+
* Chart style, e.g. "Candles" or "Renko [ATR(14), 1000]" — the last part of
|
|
712
|
+
* the headline, so a non-default style is never a surprise.
|
|
713
|
+
*/
|
|
714
|
+
chartTypeLabel?: string;
|
|
704
715
|
/** O/H/L/C values for the hovered (or latest) bar. Default true. */
|
|
705
716
|
showOhlc?: boolean;
|
|
706
717
|
/** Absolute and percent change of that bar, colored by direction. Default true. */
|
|
707
718
|
showChange?: boolean;
|
|
708
|
-
/** Bar volume. Default false. */
|
|
719
|
+
/** Bar volume. Drawn on its own row beneath the values. Default false. */
|
|
709
720
|
showVolume?: boolean;
|
|
710
721
|
/**
|
|
711
722
|
* Extra chips after the values — session, currency, a "Closed" badge. Each
|
|
@@ -724,6 +735,12 @@ interface DataLineOptions {
|
|
|
724
735
|
symbolColor?: string;
|
|
725
736
|
/** Everything after the symbol. Defaults to the indicator legend color. */
|
|
726
737
|
textColor?: string;
|
|
738
|
+
/**
|
|
739
|
+
* Color of the O/H/L/C letters. Values stay colored by direction, so dimming
|
|
740
|
+
* the letters is what makes the numbers readable at a glance rather than one
|
|
741
|
+
* run of same-colored text. Defaults to `textColor`.
|
|
742
|
+
*/
|
|
743
|
+
ohlcLabelColor?: string;
|
|
727
744
|
}
|
|
728
745
|
interface IndicatorUpdateOptions {
|
|
729
746
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -697,15 +697,26 @@ interface DataLineOptions {
|
|
|
697
697
|
visible?: boolean;
|
|
698
698
|
/** e.g. "NQU6" — drawn first, in the emphasis color. */
|
|
699
699
|
symbol?: string;
|
|
700
|
+
/**
|
|
701
|
+
* Long instrument name, e.g. "NASDAQ 100 E-mini Futures". Drawn after the
|
|
702
|
+
* symbol in the emphasis color, the way other charting platforms label a
|
|
703
|
+
* pane. Omit to keep the headline to the code alone.
|
|
704
|
+
*/
|
|
705
|
+
description?: string;
|
|
700
706
|
/** e.g. "1h". */
|
|
701
707
|
interval?: string;
|
|
702
708
|
/** e.g. "CME". */
|
|
703
709
|
exchange?: string;
|
|
710
|
+
/**
|
|
711
|
+
* Chart style, e.g. "Candles" or "Renko [ATR(14), 1000]" — the last part of
|
|
712
|
+
* the headline, so a non-default style is never a surprise.
|
|
713
|
+
*/
|
|
714
|
+
chartTypeLabel?: string;
|
|
704
715
|
/** O/H/L/C values for the hovered (or latest) bar. Default true. */
|
|
705
716
|
showOhlc?: boolean;
|
|
706
717
|
/** Absolute and percent change of that bar, colored by direction. Default true. */
|
|
707
718
|
showChange?: boolean;
|
|
708
|
-
/** Bar volume. Default false. */
|
|
719
|
+
/** Bar volume. Drawn on its own row beneath the values. Default false. */
|
|
709
720
|
showVolume?: boolean;
|
|
710
721
|
/**
|
|
711
722
|
* Extra chips after the values — session, currency, a "Closed" badge. Each
|
|
@@ -724,6 +735,12 @@ interface DataLineOptions {
|
|
|
724
735
|
symbolColor?: string;
|
|
725
736
|
/** Everything after the symbol. Defaults to the indicator legend color. */
|
|
726
737
|
textColor?: string;
|
|
738
|
+
/**
|
|
739
|
+
* Color of the O/H/L/C letters. Values stay colored by direction, so dimming
|
|
740
|
+
* the letters is what makes the numbers readable at a glance rather than one
|
|
741
|
+
* run of same-colored text. Defaults to `textColor`.
|
|
742
|
+
*/
|
|
743
|
+
ohlcLabelColor?: string;
|
|
727
744
|
}
|
|
728
745
|
interface IndicatorUpdateOptions {
|
|
729
746
|
/**
|
package/dist/index.js
CHANGED
|
@@ -8441,30 +8441,42 @@ function createChart(element, options = {}) {
|
|
|
8441
8441
|
ctx.fill();
|
|
8442
8442
|
cursorX += dotRadius * 2 + 6;
|
|
8443
8443
|
}
|
|
8444
|
-
const headline = [
|
|
8444
|
+
const headline = [
|
|
8445
|
+
dataLine.symbol,
|
|
8446
|
+
dataLine.description,
|
|
8447
|
+
dataLine.interval,
|
|
8448
|
+
dataLine.exchange,
|
|
8449
|
+
dataLine.chartTypeLabel
|
|
8450
|
+
].filter((part) => part && part.length > 0).join(" \xB7 ");
|
|
8445
8451
|
if (headline) {
|
|
8446
8452
|
ctx.fillStyle = symbolColor;
|
|
8447
8453
|
ctx.fillText(headline, cursorX, rowY);
|
|
8448
|
-
cursorX += measureTextWidth(headline) +
|
|
8454
|
+
cursorX += measureTextWidth(headline) + 12;
|
|
8449
8455
|
}
|
|
8450
8456
|
if (dataLine.showOhlc !== false) {
|
|
8451
|
-
const
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8457
|
+
const ohlcLabelColor = dataLine.ohlcLabelColor || textColor;
|
|
8458
|
+
const pairs = [
|
|
8459
|
+
["O", formatPrice(bar.o)],
|
|
8460
|
+
["H", formatPrice(bar.h)],
|
|
8461
|
+
["L", formatPrice(bar.l)],
|
|
8462
|
+
["C", formatPrice(bar.c)]
|
|
8463
|
+
];
|
|
8464
|
+
for (const [label, value] of pairs) {
|
|
8465
|
+
ctx.fillStyle = ohlcLabelColor;
|
|
8466
|
+
ctx.fillText(label, cursorX, rowY);
|
|
8467
|
+
cursorX += measureTextWidth(label) + 2;
|
|
8468
|
+
ctx.fillStyle = changeColor;
|
|
8469
|
+
ctx.fillText(value, cursorX, rowY);
|
|
8470
|
+
cursorX += measureTextWidth(value) + 9;
|
|
8471
|
+
}
|
|
8472
|
+
cursorX += 3;
|
|
8455
8473
|
}
|
|
8456
8474
|
if (dataLine.showChange !== false) {
|
|
8457
8475
|
const pct = bar.o !== 0 ? changeAbs / bar.o * 100 : 0;
|
|
8458
8476
|
const changeText = `${changeAbs >= 0 ? "+" : ""}${formatPrice(changeAbs)} (${changeAbs >= 0 ? "+" : ""}${pct.toFixed(2)}%)`;
|
|
8459
8477
|
ctx.fillStyle = changeColor;
|
|
8460
8478
|
ctx.fillText(changeText, cursorX, rowY);
|
|
8461
|
-
cursorX += measureTextWidth(changeText) +
|
|
8462
|
-
}
|
|
8463
|
-
if (dataLine.showVolume && bar.v !== void 0) {
|
|
8464
|
-
const volumeText = `Vol ${bar.v >= 1e6 ? `${(bar.v / 1e6).toFixed(2)}M` : bar.v >= 1e3 ? `${(bar.v / 1e3).toFixed(1)}K` : String(Math.round(bar.v))}`;
|
|
8465
|
-
ctx.fillStyle = textColor;
|
|
8466
|
-
ctx.fillText(volumeText, cursorX, rowY);
|
|
8467
|
-
cursorX += measureTextWidth(volumeText) + 10;
|
|
8479
|
+
cursorX += measureTextWidth(changeText) + 12;
|
|
8468
8480
|
}
|
|
8469
8481
|
for (const detail of dataLine.details ?? []) {
|
|
8470
8482
|
const text = detail.label ? `${detail.label} ${detail.value}` : detail.value;
|
|
@@ -8478,7 +8490,14 @@ function createChart(element, options = {}) {
|
|
|
8478
8490
|
ctx.fillText(text, cursorX, rowY);
|
|
8479
8491
|
cursorX += width2 + 12;
|
|
8480
8492
|
}
|
|
8481
|
-
|
|
8493
|
+
let lastRowY = rowY;
|
|
8494
|
+
if (dataLine.showVolume && bar.v !== void 0) {
|
|
8495
|
+
const volumeText = `Vol ${bar.v >= 1e6 ? `${(bar.v / 1e6).toFixed(2)}M` : bar.v >= 1e3 ? `${(bar.v / 1e3).toFixed(1)}K` : String(Math.round(bar.v))}`;
|
|
8496
|
+
lastRowY = rowY + fontSize + 4;
|
|
8497
|
+
ctx.fillStyle = textColor;
|
|
8498
|
+
ctx.fillText(volumeText, chartLeft + legendInsetX, lastRowY);
|
|
8499
|
+
}
|
|
8500
|
+
dataLineBottom = lastRowY + fontSize + 6;
|
|
8482
8501
|
ctx.font = prevFont;
|
|
8483
8502
|
}
|
|
8484
8503
|
}
|