lit-litelements 2.2.4 → 2.2.5
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 +1 -0
- package/dist/component/chart.lit.js +29 -1
- package/dist/main.js +25 -10
- package/package.json +2 -1
|
@@ -18,6 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
};
|
|
19
19
|
import { LitElement, html } from "lit";
|
|
20
20
|
import Chart from "chart.js/auto";
|
|
21
|
+
import zoomPlugin from "chartjs-plugin-zoom";
|
|
21
22
|
import { customElement, property } from "lit/decorators.js";
|
|
22
23
|
let ChartElement = class ChartElement extends LitElement {
|
|
23
24
|
constructor() {
|
|
@@ -131,6 +132,10 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
131
132
|
firstUpdated() {
|
|
132
133
|
this._createChart();
|
|
133
134
|
}
|
|
135
|
+
_resetZoom() {
|
|
136
|
+
var _a;
|
|
137
|
+
(_a = this.chart) === null || _a === void 0 ? void 0 : _a.resetZoom();
|
|
138
|
+
}
|
|
134
139
|
willUpdate(changedProperties) {
|
|
135
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
141
|
if (changedProperties.has("stockData")) {
|
|
@@ -200,6 +205,7 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
200
205
|
}
|
|
201
206
|
// Register the custom plugin
|
|
202
207
|
Chart.register(this.customLinePlugin);
|
|
208
|
+
Chart.register(zoomPlugin);
|
|
203
209
|
this.chart = new Chart(ctx, {
|
|
204
210
|
type: "line",
|
|
205
211
|
data: {
|
|
@@ -389,12 +395,34 @@ let ChartElement = class ChartElement extends LitElement {
|
|
|
389
395
|
interaction: { mode: "index", intersect: false },
|
|
390
396
|
plugins: {
|
|
391
397
|
tooltip: { mode: "index", axis: "x" },
|
|
398
|
+
zoom: {
|
|
399
|
+
pan: {
|
|
400
|
+
enabled: true,
|
|
401
|
+
mode: "xy",
|
|
402
|
+
modifierKey: undefined, // Optional: only pan while holding Ctrl
|
|
403
|
+
},
|
|
404
|
+
zoom: {
|
|
405
|
+
wheel: {
|
|
406
|
+
enabled: true,
|
|
407
|
+
},
|
|
408
|
+
pinch: {
|
|
409
|
+
enabled: true,
|
|
410
|
+
},
|
|
411
|
+
mode: "x",
|
|
412
|
+
},
|
|
413
|
+
limits: {
|
|
414
|
+
x: { minRange: 10 }, // prevent zooming too far
|
|
415
|
+
},
|
|
416
|
+
},
|
|
392
417
|
},
|
|
393
418
|
},
|
|
394
419
|
});
|
|
395
420
|
}
|
|
396
421
|
render() {
|
|
397
|
-
return html
|
|
422
|
+
return html `
|
|
423
|
+
<button @click="${this._resetZoom}">Reset Zoom</button>
|
|
424
|
+
<canvas id="stockChart"></canvas>
|
|
425
|
+
`;
|
|
398
426
|
}
|
|
399
427
|
};
|
|
400
428
|
__decorate([
|