lit-litelements 2.2.5 → 2.2.7
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/component/chart.lit.d.ts +2 -0
- package/dist/component/chart.lit.js +37 -17
- package/dist/main.js +10 -6
- package/package.json +1 -1
|
@@ -20,10 +20,12 @@ interface StockData {
|
|
|
20
20
|
}
|
|
21
21
|
declare class ChartElement extends LitElement {
|
|
22
22
|
stockData: StockData[];
|
|
23
|
+
zoomEnabled: boolean;
|
|
23
24
|
chart: Chart | null;
|
|
24
25
|
constructor();
|
|
25
26
|
firstUpdated(): void;
|
|
26
27
|
_resetZoom(): void;
|
|
28
|
+
_Zoomenalbe(): void;
|
|
27
29
|
willUpdate(changedProperties: {
|
|
28
30
|
has: (arg0: string) => any;
|
|
29
31
|
}): Promise<void>;
|
|
@@ -24,6 +24,7 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
24
24
|
constructor() {
|
|
25
25
|
super();
|
|
26
26
|
this.stockData = [];
|
|
27
|
+
this.zoomEnabled = false;
|
|
27
28
|
this.chart = null;
|
|
28
29
|
// Define the custom plugin
|
|
29
30
|
this.customLinePlugin = {
|
|
@@ -110,17 +111,6 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
110
111
|
ctx.fillText("Bear", x + 6, y - 6);
|
|
111
112
|
const stop = currClose * (1 + RISK_PERCENT);
|
|
112
113
|
const target = currClose - (stop - currClose) * REWARD_RATIO;
|
|
113
|
-
const yStop = scales.yPrice.getPixelForValue(stop);
|
|
114
|
-
const yTarget = scales.yPrice.getPixelForValue(target);
|
|
115
|
-
// // Stop-Loss (SL) line
|
|
116
|
-
// ctx.fillStyle = "purple";
|
|
117
|
-
// ctx.fillRect(x, yStop, 100, 1); // 100px wide, 1px high
|
|
118
|
-
// ctx.font = "bold 12px sans-serif";
|
|
119
|
-
// ctx.fillText("BEAR-SL", x + 12, yStop - 4);
|
|
120
|
-
// // Take-Profit (TP) line
|
|
121
|
-
// ctx.fillStyle = "purple";
|
|
122
|
-
// ctx.fillRect(x, yTarget, 100, 1); // 100px wide, 1px high
|
|
123
|
-
// ctx.fillText("BEAR-TP", x + 12, yTarget - 4);
|
|
124
114
|
}
|
|
125
115
|
ctx.setLineDash([]);
|
|
126
116
|
}
|
|
@@ -136,6 +126,21 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
136
126
|
var _a;
|
|
137
127
|
(_a = this.chart) === null || _a === void 0 ? void 0 : _a.resetZoom();
|
|
138
128
|
}
|
|
129
|
+
_Zoomenalbe() {
|
|
130
|
+
var _a, _b, _c, _d;
|
|
131
|
+
if ((_b = (_a = this.chart) === null || _a === void 0 ? void 0 : _a.options.plugins) === null || _b === void 0 ? void 0 : _b.zoom) {
|
|
132
|
+
const zoomOptions = this.chart.options.plugins.zoom;
|
|
133
|
+
const newState = !this.zoomEnabled;
|
|
134
|
+
if ((_c = zoomOptions.zoom) === null || _c === void 0 ? void 0 : _c.wheel)
|
|
135
|
+
zoomOptions.zoom.wheel.enabled = newState;
|
|
136
|
+
if ((_d = zoomOptions.zoom) === null || _d === void 0 ? void 0 : _d.pinch)
|
|
137
|
+
zoomOptions.zoom.pinch.enabled = newState;
|
|
138
|
+
if (zoomOptions.pan)
|
|
139
|
+
zoomOptions.pan.enabled = newState;
|
|
140
|
+
this.zoomEnabled = newState;
|
|
141
|
+
this.chart.update();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
139
144
|
willUpdate(changedProperties) {
|
|
140
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
146
|
if (changedProperties.has("stockData")) {
|
|
@@ -356,11 +361,18 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
356
361
|
color: (ctx) => {
|
|
357
362
|
const label = ctx.tick.label;
|
|
358
363
|
if (typeof label === "string") {
|
|
359
|
-
|
|
364
|
+
// Replace space with T to make it ISO-compliant
|
|
365
|
+
const safeLabel = label.includes(" ") ? label.replace(" ", "T") : label;
|
|
366
|
+
const labelDate = new Date(safeLabel);
|
|
367
|
+
// If the date is invalid, return default color
|
|
368
|
+
if (isNaN(labelDate.getTime()))
|
|
369
|
+
return "black";
|
|
370
|
+
// Compare date part only
|
|
360
371
|
const todayStr = new Date().toISOString().split("T")[0];
|
|
361
|
-
|
|
372
|
+
const labelStr = labelDate.toISOString().split("T")[0];
|
|
373
|
+
return labelStr === todayStr ? "Salmon" : "black";
|
|
362
374
|
}
|
|
363
|
-
return "black"; //
|
|
375
|
+
return "black"; // fallback for non-string labels
|
|
364
376
|
},
|
|
365
377
|
},
|
|
366
378
|
},
|
|
@@ -397,16 +409,16 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
397
409
|
tooltip: { mode: "index", axis: "x" },
|
|
398
410
|
zoom: {
|
|
399
411
|
pan: {
|
|
400
|
-
enabled:
|
|
412
|
+
enabled: false,
|
|
401
413
|
mode: "xy",
|
|
402
414
|
modifierKey: undefined, // Optional: only pan while holding Ctrl
|
|
403
415
|
},
|
|
404
416
|
zoom: {
|
|
405
417
|
wheel: {
|
|
406
|
-
enabled:
|
|
418
|
+
enabled: false,
|
|
407
419
|
},
|
|
408
420
|
pinch: {
|
|
409
|
-
enabled:
|
|
421
|
+
enabled: false,
|
|
410
422
|
},
|
|
411
423
|
mode: "x",
|
|
412
424
|
},
|
|
@@ -420,6 +432,10 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
420
432
|
}
|
|
421
433
|
render() {
|
|
422
434
|
return html `
|
|
435
|
+
<button @click="${this._Zoomenalbe}">
|
|
436
|
+
${this.zoomEnabled ? "Disable Zoom" : "Enable Zoom"}
|
|
437
|
+
</button>
|
|
438
|
+
|
|
423
439
|
<button @click="${this._resetZoom}">Reset Zoom</button>
|
|
424
440
|
<canvas id="stockChart"></canvas>
|
|
425
441
|
`;
|
|
@@ -429,6 +445,10 @@ __decorate([
|
|
|
429
445
|
property({ type: Array }),
|
|
430
446
|
__metadata("design:type", Array)
|
|
431
447
|
], ChartElement.prototype, "stockData", void 0);
|
|
448
|
+
__decorate([
|
|
449
|
+
property({ type: Boolean }),
|
|
450
|
+
__metadata("design:type", Boolean)
|
|
451
|
+
], ChartElement.prototype, "zoomEnabled", void 0);
|
|
432
452
|
ChartElement = __decorate([
|
|
433
453
|
customElement("stock-chart-display"),
|
|
434
454
|
__metadata("design:paramtypes", [])
|