forked from MapComplete/MapComplete
Reformat all files with prettier
This commit is contained in:
parent
e22d189376
commit
b541d3eab4
382 changed files with 50893 additions and 35566 deletions
|
@ -1,35 +1,38 @@
|
|||
import BaseUIElement from "../BaseUIElement";
|
||||
import {Chart, ChartConfiguration, ChartType, DefaultDataPoint, registerables} from 'chart.js';
|
||||
Chart?.register(...(registerables ?? []));
|
||||
|
||||
import BaseUIElement from "../BaseUIElement"
|
||||
import { Chart, ChartConfiguration, ChartType, DefaultDataPoint, registerables } from "chart.js"
|
||||
Chart?.register(...(registerables ?? []))
|
||||
|
||||
export default class ChartJs<
|
||||
TType extends ChartType = ChartType,
|
||||
TData = DefaultDataPoint<TType>,
|
||||
TLabel = unknown
|
||||
> extends BaseUIElement{
|
||||
private readonly _config: ChartConfiguration<TType, TData, TLabel>;
|
||||
|
||||
> extends BaseUIElement {
|
||||
private readonly _config: ChartConfiguration<TType, TData, TLabel>
|
||||
|
||||
constructor(config: ChartConfiguration<TType, TData, TLabel>) {
|
||||
super();
|
||||
this._config = config;
|
||||
super()
|
||||
this._config = config
|
||||
}
|
||||
|
||||
|
||||
protected InnerConstructElement(): HTMLElement {
|
||||
const canvas = document.createElement("canvas");
|
||||
const canvas = document.createElement("canvas")
|
||||
// A bit exceptional: we apply the styles before giving them to 'chartJS'
|
||||
if(this.style !== undefined){
|
||||
if (this.style !== undefined) {
|
||||
canvas.style.cssText = this.style
|
||||
}
|
||||
if (this.clss?.size > 0) {
|
||||
try {
|
||||
canvas.classList.add(...Array.from(this.clss))
|
||||
} catch (e) {
|
||||
console.error("Invalid class name detected in:", Array.from(this.clss).join(" "), "\nErr msg is ", e)
|
||||
console.error(
|
||||
"Invalid class name detected in:",
|
||||
Array.from(this.clss).join(" "),
|
||||
"\nErr msg is ",
|
||||
e
|
||||
)
|
||||
}
|
||||
}
|
||||
new Chart(canvas, this._config);
|
||||
return canvas;
|
||||
new Chart(canvas, this._config)
|
||||
return canvas
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue