@sit-onyx/chartjs-plugin 1.0.0-beta.30 → 1.0.0-beta.301
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -5
- package/package.json +15 -4
- package/src/index.ts +2 -2
- package/src/plugin.ts +4 -3
- package/src/stories/BarChart/BarChart.ct.tsx +1 -1
- package/src/stories/BarChart/BarChart.stories.ts +1 -1
- package/src/stories/BarChart/BarChart.vue +1 -1
- package/src/stories/BubbleChart/BubbleChart.ct.tsx +1 -1
- package/src/stories/BubbleChart/BubbleChart.stories.ts +1 -1
- package/src/stories/BubbleChart/BubbleChart.vue +1 -1
- package/src/stories/DoughnutChart/DoughnutChart.ct.tsx +1 -1
- package/src/stories/DoughnutChart/DoughnutChart.stories.ts +1 -1
- package/src/stories/DoughnutChart/DoughnutChart.vue +1 -1
- package/src/stories/LineChart/LineChart.ct.tsx +1 -1
- package/src/stories/LineChart/LineChart.stories.ts +1 -1
- package/src/stories/LineChart/LineChart.vue +1 -1
- package/src/stories/PieChart/PieChart.ct.tsx +1 -1
- package/src/stories/PieChart/PieChart.stories.ts +1 -1
- package/src/stories/PieChart/PieChart.vue +1 -1
- package/src/stories/PolarAreaChart/PolarAreaChart.ct.tsx +1 -1
- package/src/stories/PolarAreaChart/PolarAreaChart.stories.ts +1 -1
- package/src/stories/PolarAreaChart/PolarAreaChart.vue +1 -1
- package/src/stories/RadarChart/RadarChart.ct.tsx +1 -1
- package/src/stories/RadarChart/RadarChart.stories.ts +1 -1
- package/src/stories/RadarChart/RadarChart.vue +1 -1
- package/src/stories/ScatterChart/ScatterChart.ct.tsx +1 -1
- package/src/stories/ScatterChart/ScatterChart.stories.ts +1 -1
- package/src/stories/ScatterChart/ScatterChart.vue +1 -1
- package/src/utils.spec.ts +1 -1
- package/src/utils.ts +11 -2
package/README.md
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
<div align="center" style="text-align: center">
|
|
2
|
-
<
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" type="image/svg+xml" srcset="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo-light.svg">
|
|
4
|
-
<source media="(prefers-color-scheme: light)" type="image/svg+xml" srcset="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo-dark.svg">
|
|
5
|
-
<img alt="onyx logo" src="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo-dark.svg" width="160px">
|
|
6
|
-
</picture>
|
|
2
|
+
<img alt="onyx logo" src="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo.svg" height="96px">
|
|
7
3
|
</div>
|
|
8
4
|
|
|
9
5
|
<br>
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sit-onyx/chartjs-plugin",
|
|
3
3
|
"description": "A Chart.js plugin for the onyx design system created by Schwarz IT",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.301",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Schwarz IT KG",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=20"
|
|
10
|
+
},
|
|
8
11
|
"files": [
|
|
9
12
|
"src"
|
|
10
13
|
],
|
|
@@ -24,16 +27,24 @@
|
|
|
24
27
|
},
|
|
25
28
|
"peerDependencies": {
|
|
26
29
|
"chart.js": ">= 4.0.0",
|
|
27
|
-
"sit-onyx": "^1.0.0-beta.
|
|
30
|
+
"sit-onyx": "^1.0.0-beta.319"
|
|
28
31
|
},
|
|
29
32
|
"devDependencies": {
|
|
30
|
-
"vue
|
|
33
|
+
"@playwright/experimental-ct-vue": "1.55.0",
|
|
34
|
+
"@playwright/test": "1.55.0",
|
|
35
|
+
"@vue/compiler-dom": "3.5.20",
|
|
36
|
+
"chart.js": "4.5.0",
|
|
37
|
+
"vue": "3.5.20",
|
|
38
|
+
"vue-chartjs": "^5.3.2",
|
|
39
|
+
"@sit-onyx/shared": "^1.0.0-beta.4",
|
|
40
|
+
"@sit-onyx/storybook-utils": "^1.0.0-beta.103",
|
|
41
|
+
"sit-onyx": "^1.0.0-beta.319"
|
|
31
42
|
},
|
|
32
43
|
"scripts": {
|
|
33
44
|
"dev": "storybook dev -p 6006 --no-open",
|
|
34
45
|
"build": "vue-tsc --noEmit",
|
|
35
46
|
"test": "vitest",
|
|
36
47
|
"test:coverage": "vitest run --coverage",
|
|
37
|
-
"test:
|
|
48
|
+
"test:playwright": "playwright install && playwright test"
|
|
38
49
|
}
|
|
39
50
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./plugin";
|
|
2
|
-
export * from "./utils";
|
|
1
|
+
export * from "./plugin.js";
|
|
2
|
+
export * from "./utils.js";
|
package/src/plugin.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Chart,
|
|
3
2
|
DoughnutController,
|
|
4
3
|
PieController,
|
|
5
4
|
PolarAreaController,
|
|
5
|
+
type Chart,
|
|
6
6
|
type ChartDataset,
|
|
7
7
|
type ChartType,
|
|
8
8
|
type Color,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
type ScaleOptionsByType,
|
|
11
11
|
type ScaleTypeRegistry,
|
|
12
12
|
} from "chart.js";
|
|
13
|
-
import { QUANTITATIVE_COLOR_STEPS, getCSSVariableValue, hexToRgb } from "./utils";
|
|
13
|
+
import { QUANTITATIVE_COLOR_STEPS, getCSSVariableValue, hexToRgb } from "./utils.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Registers the onyx Chart.js plugin and updates the default styles (colors, fonts etc.) to match
|
|
@@ -146,6 +146,7 @@ const plugin: Plugin<ChartType, undefined> = {
|
|
|
146
146
|
*/
|
|
147
147
|
afterInit: (chart) => {
|
|
148
148
|
const darkModeObserver = new MutationObserver((mutations) => {
|
|
149
|
+
if (!mutations[0]) return;
|
|
149
150
|
const oldClasses = mutations[0].oldValue ?? "";
|
|
150
151
|
const newClasses = (mutations[0].target as HTMLElement).className;
|
|
151
152
|
|
|
@@ -214,7 +215,7 @@ const COLORS = QUANTITATIVE_COLOR_STEPS.map(
|
|
|
214
215
|
/**
|
|
215
216
|
* Gets a border color.
|
|
216
217
|
*/
|
|
217
|
-
const getBorderColor = (i: number) => getCSSVariableValue(COLORS[i % COLORS.length]);
|
|
218
|
+
const getBorderColor = (i: number) => getCSSVariableValue(COLORS[i % COLORS.length]!);
|
|
218
219
|
|
|
219
220
|
/**
|
|
220
221
|
* Gets a background color (same as border color + 30% transparency).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test } from "@playwright/experimental-ct-vue";
|
|
2
|
-
import { executeChartScreenshotTest } from "../playwright-utils";
|
|
2
|
+
import { executeChartScreenshotTest } from "../playwright-utils.js";
|
|
3
3
|
import BarChart from "./BarChart.vue";
|
|
4
4
|
|
|
5
5
|
test("should render bar chart", async ({ mount, page }) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { ChartData } from "chart.js";
|
|
3
3
|
import { Bar } from "vue-chartjs";
|
|
4
|
-
import { chartOptions } from "../data";
|
|
4
|
+
import { chartOptions } from "../data.js";
|
|
5
5
|
|
|
6
6
|
const labels = ["01.01.2024", "01.02.2024", "01.03.2024", "01.04.2024", "01.05.2024"];
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test } from "@playwright/experimental-ct-vue";
|
|
2
|
-
import { executeChartScreenshotTest } from "../playwright-utils";
|
|
2
|
+
import { executeChartScreenshotTest } from "../playwright-utils.js";
|
|
3
3
|
import BubbleChart from "./BubbleChart.vue";
|
|
4
4
|
|
|
5
5
|
test("should render bubble chart", async ({ mount, page }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test } from "@playwright/experimental-ct-vue";
|
|
2
|
-
import { executeChartScreenshotTest } from "../playwright-utils";
|
|
2
|
+
import { executeChartScreenshotTest } from "../playwright-utils.js";
|
|
3
3
|
import DoughnutChart from "./DoughnutChart.vue";
|
|
4
4
|
|
|
5
5
|
test("should render doughnut chart", async ({ mount, page }) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { ChartData } from "chart.js";
|
|
3
3
|
import { Doughnut } from "vue-chartjs";
|
|
4
|
-
import { chartOptions } from "../data";
|
|
4
|
+
import { chartOptions } from "../data.js";
|
|
5
5
|
|
|
6
6
|
const chartData: ChartData<"doughnut"> = {
|
|
7
7
|
labels: ["Label 1", "Label 2", "Label 3", "Label 4"],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test } from "@playwright/experimental-ct-vue";
|
|
2
|
-
import { executeChartScreenshotTest } from "../playwright-utils";
|
|
2
|
+
import { executeChartScreenshotTest } from "../playwright-utils.js";
|
|
3
3
|
import LineChart from "./LineChart.vue";
|
|
4
4
|
|
|
5
5
|
test("should render line chart", async ({ mount, page }) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { ChartData } from "chart.js";
|
|
3
3
|
import { Line } from "vue-chartjs";
|
|
4
|
-
import { chartOptions } from "../data";
|
|
4
|
+
import { chartOptions } from "../data.js";
|
|
5
5
|
|
|
6
6
|
const labels = ["01.01.2024", "01.02.2024", "01.03.2024", "01.04.2024", "01.05.2024"];
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test } from "@playwright/experimental-ct-vue";
|
|
2
|
-
import { executeChartScreenshotTest } from "../playwright-utils";
|
|
2
|
+
import { executeChartScreenshotTest } from "../playwright-utils.js";
|
|
3
3
|
import PieChart from "./PieChart.vue";
|
|
4
4
|
|
|
5
5
|
test("should render pie chart", async ({ mount, page }) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { ChartData } from "chart.js";
|
|
3
3
|
import { Pie } from "vue-chartjs";
|
|
4
|
-
import { chartOptions } from "../data";
|
|
4
|
+
import { chartOptions } from "../data.js";
|
|
5
5
|
|
|
6
6
|
const chartData: ChartData<"pie"> = {
|
|
7
7
|
labels: ["Label 1", "Label 2", "Label 3", "Label 4"],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test } from "@playwright/experimental-ct-vue";
|
|
2
|
-
import { executeChartScreenshotTest } from "../playwright-utils";
|
|
2
|
+
import { executeChartScreenshotTest } from "../playwright-utils.js";
|
|
3
3
|
import PolarAreaChart from "./PolarAreaChart.vue";
|
|
4
4
|
|
|
5
5
|
test("should render polar area chart", async ({ mount, page }) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { ChartData } from "chart.js";
|
|
3
3
|
import { PolarArea } from "vue-chartjs";
|
|
4
|
-
import { chartOptionsWithoutScales } from "../data";
|
|
4
|
+
import { chartOptionsWithoutScales } from "../data.js";
|
|
5
5
|
|
|
6
6
|
const chartData: ChartData<"polarArea"> = {
|
|
7
7
|
labels: ["Label 1", "Label 2", "Label 3", "Label 4", "Label 5", "Label 6", "Label 7"],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test } from "@playwright/experimental-ct-vue";
|
|
2
|
-
import { executeChartScreenshotTest } from "../playwright-utils";
|
|
2
|
+
import { executeChartScreenshotTest } from "../playwright-utils.js";
|
|
3
3
|
import RadarChart from "./RadarChart.vue";
|
|
4
4
|
|
|
5
5
|
test("should render radar chart", async ({ mount, page }) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { ChartData } from "chart.js";
|
|
3
3
|
import { Radar } from "vue-chartjs";
|
|
4
|
-
import { chartOptionsWithoutScales } from "../data";
|
|
4
|
+
import { chartOptionsWithoutScales } from "../data.js";
|
|
5
5
|
|
|
6
6
|
const chartData: ChartData<"radar"> = {
|
|
7
7
|
labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test } from "@playwright/experimental-ct-vue";
|
|
2
|
-
import { executeChartScreenshotTest } from "../playwright-utils";
|
|
2
|
+
import { executeChartScreenshotTest } from "../playwright-utils.js";
|
|
3
3
|
import ScatterChart from "./ScatterChart.vue";
|
|
4
4
|
|
|
5
5
|
test("should render scatter chart", async ({ mount, page }) => {
|
package/src/utils.spec.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -39,8 +39,17 @@ export const getDatasetColors = (color: OnyxColor | `quantitatives-${Quantitativ
|
|
|
39
39
|
* Gets the current value of the given CSS variable.
|
|
40
40
|
* @param CSS variable name, e.g. `--onyx-color-base-primary-500`
|
|
41
41
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
|
|
43
|
+
export const getCSSVariableValue = (variableName: string): string => {
|
|
44
|
+
const isDark = getComputedStyle(document.body).colorScheme === "dark";
|
|
45
|
+
const computedValue = getComputedStyle(document.body).getPropertyValue(variableName).trim();
|
|
46
|
+
const lightDarkMatch = /^light-dark\(([^,]+),\s*([^)]+)\)$/.exec(computedValue);
|
|
47
|
+
|
|
48
|
+
if (lightDarkMatch) {
|
|
49
|
+
return lightDarkMatch[isDark ? 2 : 1]!.trim();
|
|
50
|
+
} else {
|
|
51
|
+
return computedValue;
|
|
52
|
+
}
|
|
44
53
|
};
|
|
45
54
|
|
|
46
55
|
/**
|