magnetar/fe_calckey/frontend/client/src/scripts/init-chart.ts

59 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-07-07 19:22:30 +00:00
import {
Chart,
ArcElement,
LineElement,
BarElement,
PointElement,
BarController,
LineController,
DoughnutController,
CategoryScale,
LinearScale,
TimeScale,
Legend,
Title,
Tooltip,
SubTitle,
Filler,
2023-07-07 19:22:30 +00:00
} from "chart.js";
import gradient from "chartjs-plugin-gradient";
import zoomPlugin from "chartjs-plugin-zoom";
import { MatrixController, MatrixElement } from "chartjs-chart-matrix";
import { defaultStore } from "@/store";
import "chartjs-adapter-date-fns";
export function initChart() {
Chart.register(
ArcElement,
LineElement,
BarElement,
PointElement,
BarController,
LineController,
DoughnutController,
CategoryScale,
LinearScale,
TimeScale,
Legend,
Title,
Tooltip,
SubTitle,
Filler,
MatrixController,
MatrixElement,
zoomPlugin,
gradient
);
2023-07-07 19:22:30 +00:00
// フォントカラー
Chart.defaults.color = getComputedStyle(
document.documentElement
).getPropertyValue("--fg");
2023-07-07 19:22:30 +00:00
Chart.defaults.borderColor = defaultStore.state.darkMode
? "rgba(255, 255, 255, 0.1)"
: "rgba(0, 0, 0, 0.1)";
2023-07-07 19:22:30 +00:00
Chart.defaults.animation = false;
2023-07-07 19:22:30 +00:00
}