lit-litelements 2.2.5 → 2.2.6
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 +27 -14
- 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")) {
|
|
@@ -397,16 +402,16 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
397
402
|
tooltip: { mode: "index", axis: "x" },
|
|
398
403
|
zoom: {
|
|
399
404
|
pan: {
|
|
400
|
-
enabled:
|
|
405
|
+
enabled: false,
|
|
401
406
|
mode: "xy",
|
|
402
407
|
modifierKey: undefined, // Optional: only pan while holding Ctrl
|
|
403
408
|
},
|
|
404
409
|
zoom: {
|
|
405
410
|
wheel: {
|
|
406
|
-
enabled:
|
|
411
|
+
enabled: false,
|
|
407
412
|
},
|
|
408
413
|
pinch: {
|
|
409
|
-
enabled:
|
|
414
|
+
enabled: false,
|
|
410
415
|
},
|
|
411
416
|
mode: "x",
|
|
412
417
|
},
|
|
@@ -420,6 +425,10 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
420
425
|
}
|
|
421
426
|
render() {
|
|
422
427
|
return html `
|
|
428
|
+
<button @click="${this._Zoomenalbe}">
|
|
429
|
+
${this.zoomEnabled ? "Disable Zoom" : "Enable Zoom"}
|
|
430
|
+
</button>
|
|
431
|
+
|
|
423
432
|
<button @click="${this._resetZoom}">Reset Zoom</button>
|
|
424
433
|
<canvas id="stockChart"></canvas>
|
|
425
434
|
`;
|
|
@@ -429,6 +438,10 @@ __decorate([
|
|
|
429
438
|
property({ type: Array }),
|
|
430
439
|
__metadata("design:type", Array)
|
|
431
440
|
], ChartElement.prototype, "stockData", void 0);
|
|
441
|
+
__decorate([
|
|
442
|
+
property({ type: Boolean }),
|
|
443
|
+
__metadata("design:type", Boolean)
|
|
444
|
+
], ChartElement.prototype, "zoomEnabled", void 0);
|
|
432
445
|
ChartElement = __decorate([
|
|
433
446
|
customElement("stock-chart-display"),
|
|
434
447
|
__metadata("design:paramtypes", [])
|