Initial commit

This commit is contained in:
Pit Friedrich
2026-07-05 17:06:59 +02:00
parent 0935b7a98a
commit 23b392a19b
11 changed files with 5144 additions and 0 deletions
@@ -0,0 +1,43 @@
import { html, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';
import ApexCharts from 'apexcharts';
@customElement('apex-chart')
export class ApexChart extends LitElement {
private chart?: ApexCharts;
protected createRenderRoot() {
return this;
}
render() {
return html`<div id="container" style="width:100%;height:100%"></div>`;
}
async renderChart(optionsJson: string) {
await this.updateComplete;
const options = JSON.parse(optionsJson);
options.chart = {
...options.chart,
events: {
dataPointSelection: (_e: unknown, _ctx: unknown, cfg: any) => {
(this as any).$server.onPointClick(cfg.seriesIndex, cfg.dataPointIndex);
},
},
};
const container = this.querySelector('#container') as HTMLElement;
if (this.chart) {
await this.chart.updateOptions(options);
} else {
this.chart = new ApexCharts(container, options);
await this.chart.render();
}
}
disconnectedCallback() {
super.disconnectedCallback();
this.chart?.destroy();
}
}