Sha256: 063d0f91388febae472bb3c61ce58c776a299bdd4a8487ce56a2ad04716e6d1f
Contents?: true
Size: 971 Bytes
Versions: 18
Compression:
Stored size: 971 Bytes
Contents
import { Controller } from "@hotwired/stimulus" import { Chart, registerables } from "https://esm.sh/chart.js@4.4.7?standalone" Chart.register(...registerables) Chart.defaults.backgroundColor = getCssVariableValue("--color-primary") Chart.defaults.borderColor = getCssVariableValue("--color-border") Chart.defaults.color = getCssVariableValue("--color-text") Chart.defaults.font.family = getCssVariableValue("--font-system-ui") Chart.defaults.font.size = 12 function getCssVariableValue(variableName) { return getComputedStyle(document.documentElement).getPropertyValue(variableName).trim() } export default class extends Controller { static values = { type: { type: String, default: "line" }, data: Object, options: Object } connect() { this.chart = new Chart(this.element, this.#settings) } disconnect() { this.chart.destroy() } get #settings() { return { type: this.typeValue, data: this.dataValue, options: this.optionsValue } } }
Version data entries
18 entries across 18 versions & 1 rubygems