@sit-onyx/chartjs-plugin 0.0.0 → 0.0.1-alpha.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
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": "0.0.0",
4
+ "version": "0.0.1-alpha.0",
5
5
  "type": "module",
6
6
  "author": "Schwarz IT KG",
7
7
  "license": "Apache-2.0",
@@ -10,7 +10,8 @@
10
10
  ],
11
11
  "types": "./src/index.ts",
12
12
  "exports": {
13
- ".": "./src/index.ts"
13
+ ".": "./src/index.ts",
14
+ "./examples/*": "./src/stories/*"
14
15
  },
15
16
  "homepage": "https://onyx.schwarz/development/packages/chartjs-plugin.html",
16
17
  "repository": {
package/src/plugin.ts CHANGED
@@ -28,13 +28,24 @@ import { getCSSVariableValue, hexToRgb } from "./utils";
28
28
  * ```
29
29
  */
30
30
  export const registerOnyxPlugin = (chart: typeof Chart) => {
31
+ //
32
+ // IMPLEMENTATION NOTES:
33
+ // is you use "getCSSVariableValue" here, make sure its either a function
34
+ // or a getter defined with "Object.defineProperty".
35
+ // Otherwise if called directly, this is not compatible with server side rendering.
36
+ //
31
37
  chart.register(plugin);
32
38
  chart.defaults.plugins.colors.enabled = false;
33
39
 
34
40
  //
35
41
  // General default styles for all chart types
36
42
  //
37
- chart.defaults.font.family = getCSSVariableValue("--onyx-font-family");
43
+ Object.defineProperty(chart.defaults.font, "family", {
44
+ configurable: true,
45
+ enumerable: true,
46
+ get: () => getCSSVariableValue("--onyx-font-family"),
47
+ });
48
+
38
49
  chart.defaults.font.size = 13;
39
50
 
40
51
  chart.defaults.borderColor = () => getCSSVariableValue("--onyx-color-base-neutral-300");
@@ -23,11 +23,13 @@ const chartData: ChartData<"bar"> = {
23
23
  </script>
24
24
 
25
25
  <template>
26
- <Bar :data="chartData" :options="chartOptions" class="chart" />
26
+ <div>
27
+ <Bar :data="chartData" :options="chartOptions" class="chart" />
28
+ </div>
27
29
  </template>
28
30
 
29
31
  <style lang="scss" scoped>
30
32
  .chart {
31
- height: 32rem;
33
+ height: 24rem;
32
34
  }
33
35
  </style>
@@ -26,11 +26,13 @@ const chartData: ChartData<"bubble"> = {
26
26
  </script>
27
27
 
28
28
  <template>
29
- <Bubble :data="chartData" :options="chartOptions" class="chart" />
29
+ <div>
30
+ <Bubble :data="chartData" :options="chartOptions" class="chart" />
31
+ </div>
30
32
  </template>
31
33
 
32
34
  <style lang="scss" scoped>
33
35
  .chart {
34
- height: 32rem;
36
+ height: 24rem;
35
37
  }
36
38
  </style>
@@ -4,7 +4,7 @@ import { Doughnut } from "vue-chartjs";
4
4
  import { chartOptions } from "../data";
5
5
 
6
6
  const chartData: ChartData<"doughnut"> = {
7
- labels: ["VueJs", "EmberJs", "ReactJs", "AngularJs"],
7
+ labels: ["Label 1", "Label 2", "Label 3", "Label 4"],
8
8
  datasets: [
9
9
  {
10
10
  data: [40, 20, 80, 10],
@@ -14,11 +14,13 @@ const chartData: ChartData<"doughnut"> = {
14
14
  </script>
15
15
 
16
16
  <template>
17
- <Doughnut :data="chartData" :options="chartOptions" class="chart" />
17
+ <div>
18
+ <Doughnut :data="chartData" :options="chartOptions" class="chart" />
19
+ </div>
18
20
  </template>
19
21
 
20
22
  <style lang="scss" scoped>
21
23
  .chart {
22
- height: 32rem;
24
+ height: 24rem;
23
25
  }
24
26
  </style>
@@ -23,11 +23,13 @@ const chartData: ChartData<"line"> = {
23
23
  </script>
24
24
 
25
25
  <template>
26
- <Line :data="chartData" :options="chartOptions" class="chart" />
26
+ <div>
27
+ <Line :data="chartData" :options="chartOptions" class="chart" />
28
+ </div>
27
29
  </template>
28
30
 
29
31
  <style lang="scss" scoped>
30
32
  .chart {
31
- height: 32rem;
33
+ height: 24rem;
32
34
  }
33
35
  </style>
@@ -4,21 +4,19 @@ import { Pie } from "vue-chartjs";
4
4
  import { chartOptions } from "../data";
5
5
 
6
6
  const chartData: ChartData<"pie"> = {
7
- labels: ["VueJs", "EmberJs", "ReactJs", "AngularJs"],
8
- datasets: [
9
- {
10
- data: [40, 20, 80, 10],
11
- },
12
- ],
7
+ labels: ["Label 1", "Label 2", "Label 3", "Label 4"],
8
+ datasets: [{ data: [40, 20, 80, 10] }],
13
9
  };
14
10
  </script>
15
11
 
16
12
  <template>
17
- <Pie :data="chartData" :options="chartOptions" class="chart" />
13
+ <div>
14
+ <Pie :data="chartData" :options="chartOptions" class="chart" />
15
+ </div>
18
16
  </template>
19
17
 
20
18
  <style lang="scss" scoped>
21
19
  .chart {
22
- height: 32rem;
20
+ height: 24rem;
23
21
  }
24
22
  </style>
@@ -4,14 +4,14 @@ import { PolarArea } from "vue-chartjs";
4
4
  import { chartOptionsWithoutScales } from "../data";
5
5
 
6
6
  const chartData: ChartData<"polarArea"> = {
7
- labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
7
+ labels: ["Label 1", "Label 2", "Label 3", "Label 4", "Label 5", "Label 6", "Label 7"],
8
8
  datasets: [
9
9
  {
10
- label: "My First dataset",
10
+ label: "Dataset A",
11
11
  data: [65, 59, 90, 81, 56, 55, 40],
12
12
  },
13
13
  {
14
- label: "My Second dataset",
14
+ label: "Dataset B",
15
15
  data: [28, 48, 40, 19, 96, 27, 100],
16
16
  },
17
17
  ],
@@ -19,11 +19,13 @@ const chartData: ChartData<"polarArea"> = {
19
19
  </script>
20
20
 
21
21
  <template>
22
- <PolarArea :data="chartData" :options="chartOptionsWithoutScales" class="chart" />
22
+ <div>
23
+ <PolarArea :data="chartData" :options="chartOptionsWithoutScales" class="chart" />
24
+ </div>
23
25
  </template>
24
26
 
25
27
  <style lang="scss" scoped>
26
28
  .chart {
27
- height: 32rem;
29
+ height: 24rem;
28
30
  }
29
31
  </style>
@@ -19,11 +19,13 @@ const chartData: ChartData<"radar"> = {
19
19
  </script>
20
20
 
21
21
  <template>
22
- <Radar :data="chartData" :options="chartOptionsWithoutScales" class="chart" />
22
+ <div>
23
+ <Radar :data="chartData" :options="chartOptionsWithoutScales" class="chart" />
24
+ </div>
23
25
  </template>
24
26
 
25
27
  <style lang="scss" scoped>
26
28
  .chart {
27
- height: 32rem;
29
+ height: 24rem;
28
30
  }
29
31
  </style>
@@ -7,7 +7,6 @@ const chartData: ChartData<"scatter"> = {
7
7
  datasets: [
8
8
  {
9
9
  label: "Dataset A",
10
- fill: false,
11
10
  data: [
12
11
  { x: -2, y: 4 },
13
12
  { x: -1, y: 1 },
@@ -18,7 +17,6 @@ const chartData: ChartData<"scatter"> = {
18
17
  },
19
18
  {
20
19
  label: "Dataset B",
21
- fill: false,
22
20
  data: [
23
21
  { x: -2, y: -4 },
24
22
  { x: -1, y: -1 },
@@ -32,11 +30,13 @@ const chartData: ChartData<"scatter"> = {
32
30
  </script>
33
31
 
34
32
  <template>
35
- <Scatter :data="chartData" :options="chartOptions" class="chart" />
33
+ <div>
34
+ <Scatter :data="chartData" :options="chartOptions" class="chart" />
35
+ </div>
36
36
  </template>
37
37
 
38
38
  <style lang="scss" scoped>
39
39
  .chart {
40
- height: 32rem;
40
+ height: 24rem;
41
41
  }
42
42
  </style>
@@ -4,8 +4,7 @@ import type { ChartOptions } from "chart.js";
4
4
  * Shared chart options for all example charts (without scales for polar area and radar chart).
5
5
  */
6
6
  export const chartOptionsWithoutScales = {
7
- responsive: true,
8
- maintainAspectRatio: false,
7
+ maintainAspectRatio: false, // needed to allow setting the actual chart height via CSS
9
8
  hover: {
10
9
  intersect: false,
11
10
  },