Sha256: b1a3120fd642748eb25e40f1ccc295c4b14d9b0b255e45d9d0cf3019e0f9ac31
Contents?: true
Size: 988 Bytes
Versions: 1
Compression:
Stored size: 988 Bytes
Contents
import { Controller } from "@hotwired/stimulus" import { Chart, Colors, registerables } from "https://cdn.skypack.dev/chart.js@4.4.6" 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 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 } } } // Helpers function getCssVariableValue(variableName) { return getComputedStyle(document.documentElement).getPropertyValue(variableName).trim() }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
css-zero-0.0.56 | lib/generators/css_zero/add/templates/app/javascript/controllers/chart_controller.js |