Skip to content

Commit

Permalink
[TASK] Add function to set the correct chart color for for the curren…
Browse files Browse the repository at this point in the history
…t color scheme
  • Loading branch information
deoostfrees committed Oct 28, 2024
1 parent cc4a7cd commit 72f2db5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Resources/Private/Build/JavaScript/Backend/Diagram.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
import { Chart, registerables } from "@in2code/lux/vendor/chartjs.js";

const setDefaultChartColor = () => {
const colorScheme = document.documentElement.getAttribute('data-color-scheme') || 'auto';
const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;

if (colorScheme === 'light') {
Chart.defaults.color = '#1A1A1A';
} else if (colorScheme === 'dark' || (colorScheme === 'auto' && prefersDarkMode)) {
Chart.defaults.color = '#D9D9D9';
} else {
Chart.defaults.color = '#1A1A1A';
}
};

setDefaultChartColor();

Chart.register(...registerables);

/**
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/Lux/Diagram.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 72f2db5

Please sign in to comment.