@mozaic-ds/chart 0.1.0-beta.29 → 0.1.0-beta.30

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.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/dist/mozaic-chart.js +2303 -2109
  3. package/dist/mozaic-chart.umd.cjs +9 -9
  4. package/dist/style.css +1 -1
  5. package/package.json +1 -1
  6. package/src/assets/base.css +1 -1
  7. package/src/components/bar/BarChart.stories.ts +99 -99
  8. package/src/components/bar/BarChart.vue +70 -53
  9. package/src/components/bar/index.ts +3 -3
  10. package/src/components/bubble/BubbleChart.stories.ts +12 -12
  11. package/src/components/bubble/BubbleChart.vue +118 -91
  12. package/src/components/bubble/index.ts +3 -3
  13. package/src/components/doughnut/DoughnutChart.stories.ts +38 -37
  14. package/src/components/doughnut/DoughnutChart.vue +89 -71
  15. package/src/components/doughnut/index.ts +3 -3
  16. package/src/components/index.ts +4 -4
  17. package/src/components/line/LineChart.stories.ts +38 -38
  18. package/src/components/line/LineChart.vue +54 -51
  19. package/src/components/line/index.ts +3 -3
  20. package/src/components/mixed/MixedBarLineChart.stories.ts +15 -15
  21. package/src/components/mixed/MixedBarLineChart.vue +44 -44
  22. package/src/components/mixed/index.ts +1 -1
  23. package/src/components/radar/RadarChart.stories.ts +100 -100
  24. package/src/components/radar/RadarChart.vue +41 -34
  25. package/src/components/radar/index.ts +3 -3
  26. package/src/main.ts +14 -7
  27. package/src/plugin.ts +9 -9
  28. package/src/services/BarChartFunctions.ts +133 -35
  29. package/src/services/BubbleTooltipService.ts +58 -56
  30. package/src/services/ChartsCommonLegend.ts +271 -127
  31. package/src/services/ColorFunctions.ts +1 -1
  32. package/src/services/DoughnutChartFunctions.ts +42 -13
  33. package/src/services/FormatUtilities.ts +28 -14
  34. package/src/services/GenericTooltipService.ts +125 -65
  35. package/src/services/MixedBarLineFunctions.ts +46 -44
  36. package/src/services/PatternFunctions.ts +25 -18
  37. package/src/services/RadarChartFunctions.ts +5 -5
  38. package/src/services/patterns/ChartDesign.ts +35 -24
  39. package/src/services/patterns/patternCircles.ts +63 -36
  40. package/src/services/patterns/patternDashedDiagonals.ts +64 -57
  41. package/src/services/patterns/patternDiagonals.ts +138 -106
  42. package/src/services/patterns/patternSquares.ts +86 -80
  43. package/src/services/patterns/patternVerticalLines.ts +76 -69
  44. package/src/services/patterns/patternZigzag.ts +92 -85
  45. package/src/stories/Changelog.mdx +2 -2
  46. package/src/stories/Contributing.mdx +2 -2
  47. package/src/stories/GettingStarted.mdx +5 -5
  48. package/src/stories/SupportAndOnboarding.mdx +6 -6
  49. package/src/types/AxisDefinition.ts +0 -2
  50. package/src/types/Chart.ts +9 -7
  51. package/src/types/DoughnutData.ts +8 -0
  52. package/src/types/GenericData.ts +10 -10
  53. package/src/types/LineChart.ts +4 -4
  54. package/src/types/RadarData.ts +33 -29
  55. package/src/types/TooltipChartType.ts +7 -7
  56. package/src/vite-env.d.ts +3 -3
@@ -1,101 +1,108 @@
1
- export default function PatternZigzag(hover: boolean, color: string = '#00A3B2', disableAccessibility: boolean = false): CanvasPattern {
1
+ export default function PatternZigzag(
2
+ hover: boolean,
3
+ color: string = '#00A3B2',
4
+ disableAccessibility: boolean = false
5
+ ): CanvasPattern {
2
6
  const canvasPattern: HTMLCanvasElement = document.createElement('canvas');
3
7
  const ctx: CanvasRenderingContext2D | null = canvasPattern.getContext('2d');
4
8
  if (!ctx) {
5
- return new CanvasPattern;
9
+ return new CanvasPattern();
6
10
  }
7
-
11
+
8
12
  const patternSize = 50;
9
-
13
+
10
14
  canvasPattern.width = patternSize;
11
15
  canvasPattern.height = patternSize;
12
16
 
13
17
  if (disableAccessibility === true) {
14
18
  ctx.beginPath();
15
19
  ctx.fillStyle = color;
16
- ctx.rect(0.000000, 0.000000, patternSize, patternSize);
20
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
17
21
  ctx.fill();
18
22
  } else {
19
- // background
20
- ctx.beginPath();
21
- ctx.fillStyle = '#FFFFFF';
22
- ctx.lineWidth = 0.005 * patternSize;
23
- ctx.rect(0.000000, 0.000000, patternSize, patternSize);
24
- ctx.fill();
25
- ctx.beginPath();
26
- ctx.globalAlpha = 0.1;
27
- ctx.fillStyle = color;
28
- ctx.lineWidth = 0.005 * patternSize;
29
- ctx.rect(0.000000, 0.000000, patternSize, patternSize);
30
- ctx.fill();
31
-
32
- // #path4
33
- ctx.beginPath();
34
- ctx.globalAlpha = 0.7;
35
- ctx.strokeStyle = color;
36
- ctx.lineWidth = 0.08 * patternSize;
37
- ctx.moveTo(- patternSize / 2, patternSize / 2);
38
- ctx.lineTo(0.000000, 0.000000);
39
- ctx.lineTo(patternSize / 2, patternSize / 2);
40
- ctx.lineTo(patternSize, 0.000000);
41
- ctx.stroke();
42
-
43
- // #path6
44
- ctx.beginPath();
45
- ctx.globalAlpha = 0.3;
46
- ctx.strokeStyle = color;
47
- ctx.lineWidth = 0.08 * patternSize;
48
- ctx.moveTo(- patternSize / 2, patternSize);
49
- ctx.lineTo(0.000000, patternSize / 2);
50
- ctx.lineTo(patternSize / 2, patternSize);
51
- ctx.lineTo(patternSize, patternSize / 2);
52
- ctx.lineTo(patternSize + (patternSize / 2), patternSize);
53
- ctx.stroke();
54
-
55
- // #path6-6
56
- ctx.beginPath();
57
- ctx.globalAlpha = 0.3;
58
- ctx.strokeStyle = color;
59
- ctx.lineWidth = 0.08 * patternSize;
60
- ctx.moveTo(- patternSize / 2, 0.000111);
61
- ctx.lineTo(0.000004 * patternSize, - patternSize / 2);
62
- ctx.lineTo(patternSize / 2, 0.000111);
63
- ctx.lineTo(patternSize, - patternSize / 2);
64
- ctx.lineTo(patternSize + (patternSize / 2), 0.000111);
65
- ctx.stroke();
66
-
67
- // #path6-5
68
- ctx.beginPath();
69
- ctx.globalAlpha = 0.7;
70
- ctx.strokeStyle = color;
71
- ctx.lineWidth = 0.08 * patternSize;
72
- ctx.moveTo(- patternSize / 2, patternSize + (patternSize / 2));
73
- ctx.lineTo(0.000000, patternSize);
74
- ctx.lineTo(patternSize / 2, patternSize + (patternSize / 2));
75
- ctx.lineTo(patternSize, patternSize);
76
- ctx.lineTo(patternSize + (patternSize / 2), patternSize + (patternSize / 2));
77
- ctx.stroke();
78
- }
23
+ // background
24
+ ctx.beginPath();
25
+ ctx.fillStyle = '#FFFFFF';
26
+ ctx.lineWidth = 0.005 * patternSize;
27
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
28
+ ctx.fill();
29
+ ctx.beginPath();
30
+ ctx.globalAlpha = 0.1;
31
+ ctx.fillStyle = color;
32
+ ctx.lineWidth = 0.005 * patternSize;
33
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
34
+ ctx.fill();
35
+
36
+ // #path4
37
+ ctx.beginPath();
38
+ ctx.globalAlpha = 0.7;
39
+ ctx.strokeStyle = color;
40
+ ctx.lineWidth = 0.08 * patternSize;
41
+ ctx.moveTo(-patternSize / 2, patternSize / 2);
42
+ ctx.lineTo(0.0, 0.0);
43
+ ctx.lineTo(patternSize / 2, patternSize / 2);
44
+ ctx.lineTo(patternSize, 0.0);
45
+ ctx.stroke();
79
46
 
80
- // Hover Style
81
- if (hover) {
82
- ctx.beginPath();
83
- ctx.globalAlpha = 0.5;
84
- ctx.fillStyle = '#FFFFFF';
85
- ctx.lineWidth = 0.006 * patternSize;
86
- ctx.rect(0.000000, 0.000000, patternSize, patternSize);
87
- ctx.fill();
88
- }
47
+ // #path6
48
+ ctx.beginPath();
49
+ ctx.globalAlpha = 0.3;
50
+ ctx.strokeStyle = color;
51
+ ctx.lineWidth = 0.08 * patternSize;
52
+ ctx.moveTo(-patternSize / 2, patternSize);
53
+ ctx.lineTo(0.0, patternSize / 2);
54
+ ctx.lineTo(patternSize / 2, patternSize);
55
+ ctx.lineTo(patternSize, patternSize / 2);
56
+ ctx.lineTo(patternSize + patternSize / 2, patternSize);
57
+ ctx.stroke();
89
58
 
90
- const canvas: HTMLCanvasElement = document.createElement('canvas');
91
- const context: CanvasRenderingContext2D | null = canvas.getContext('2d');
92
- if (!context) {
93
- return new CanvasPattern;
94
- }
95
- const pattern: CanvasPattern | null = context.createPattern(canvasPattern, 'repeat');
96
- if (!pattern) {
97
- return new CanvasPattern;
98
- }
59
+ // #path6-6
60
+ ctx.beginPath();
61
+ ctx.globalAlpha = 0.3;
62
+ ctx.strokeStyle = color;
63
+ ctx.lineWidth = 0.08 * patternSize;
64
+ ctx.moveTo(-patternSize / 2, 0.000111);
65
+ ctx.lineTo(0.000004 * patternSize, -patternSize / 2);
66
+ ctx.lineTo(patternSize / 2, 0.000111);
67
+ ctx.lineTo(patternSize, -patternSize / 2);
68
+ ctx.lineTo(patternSize + patternSize / 2, 0.000111);
69
+ ctx.stroke();
99
70
 
100
- return pattern;
101
- }
71
+ // #path6-5
72
+ ctx.beginPath();
73
+ ctx.globalAlpha = 0.7;
74
+ ctx.strokeStyle = color;
75
+ ctx.lineWidth = 0.08 * patternSize;
76
+ ctx.moveTo(-patternSize / 2, patternSize + patternSize / 2);
77
+ ctx.lineTo(0.0, patternSize);
78
+ ctx.lineTo(patternSize / 2, patternSize + patternSize / 2);
79
+ ctx.lineTo(patternSize, patternSize);
80
+ ctx.lineTo(patternSize + patternSize / 2, patternSize + patternSize / 2);
81
+ ctx.stroke();
82
+ }
83
+
84
+ // Hover Style
85
+ if (hover) {
86
+ ctx.beginPath();
87
+ ctx.globalAlpha = 0.5;
88
+ ctx.fillStyle = '#FFFFFF';
89
+ ctx.lineWidth = 0.006 * patternSize;
90
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
91
+ ctx.fill();
92
+ }
93
+
94
+ const canvas: HTMLCanvasElement = document.createElement('canvas');
95
+ const context: CanvasRenderingContext2D | null = canvas.getContext('2d');
96
+ if (!context) {
97
+ return new CanvasPattern();
98
+ }
99
+ const pattern: CanvasPattern | null = context.createPattern(
100
+ canvasPattern,
101
+ 'repeat'
102
+ );
103
+ if (!pattern) {
104
+ return new CanvasPattern();
105
+ }
106
+
107
+ return pattern;
108
+ }
@@ -1,5 +1,5 @@
1
- import { Meta, Markdown } from "@storybook/blocks";
2
- import Changelog from "../../CHANGELOG.md?raw";
1
+ import { Meta, Markdown } from '@storybook/blocks';
2
+ import Changelog from '../../CHANGELOG.md?raw';
3
3
 
4
4
  <Meta title="Changelog" />
5
5
 
@@ -1,5 +1,5 @@
1
- import { Meta } from "@storybook/blocks";
2
- import { Mermaid } from "mdx-mermaid/Mermaid";
1
+ import { Meta } from '@storybook/blocks';
2
+ import { Mermaid } from 'mdx-mermaid/Mermaid';
3
3
 
4
4
  <Meta title="Contributing" />
5
5
 
@@ -1,6 +1,6 @@
1
- import { Meta } from "@storybook/blocks";
2
- import { Badge, OutlineCTA, Link } from "@storybook/design-system";
3
- import pkg from "../../package.json";
1
+ import { Meta } from '@storybook/blocks';
2
+ import { Badge, OutlineCTA, Link } from '@storybook/design-system';
3
+ import pkg from '../../package.json';
4
4
 
5
5
  <Meta title="Getting Started" />
6
6
 
@@ -61,8 +61,8 @@ In your entry point file, insert the following code:
61
61
  ```javascript
62
62
  // In the entry point file of your application - usually src/main.js
63
63
 
64
- import MozaicChart from "@mozaic-ds/chart";
65
- import "@mozaic-ds/chart/dist/style.css";
64
+ import MozaicChart from '@mozaic-ds/chart';
65
+ import '@mozaic-ds/chart/dist/style.css';
66
66
 
67
67
  Vue.use(MozaicChart);
68
68
  ```
@@ -1,14 +1,14 @@
1
- import { Meta } from "@storybook/blocks";
2
- import { Button } from "@storybook/design-system";
1
+ import { Meta } from '@storybook/blocks';
2
+ import { Button } from '@storybook/design-system';
3
3
 
4
4
  <Meta
5
5
  title="Support & Onboarding"
6
6
  parameters={{
7
- layout: "fullscreen",
8
- viewMode: "docs",
7
+ layout: 'fullscreen',
8
+ viewMode: 'docs',
9
9
  previewTabs: {
10
- canvas: { hidden: true },
11
- },
10
+ canvas: { hidden: true }
11
+ }
12
12
  }}
13
13
  />
14
14
 
@@ -2,5 +2,3 @@ export interface AxisDefinition {
2
2
  title: string;
3
3
  unit: string;
4
4
  }
5
-
6
-
@@ -1,10 +1,12 @@
1
+ import { Plugin } from 'chart.js';
2
+
1
3
  export interface ChartData {
2
- data: any;
3
- loading: boolean;
4
- error: boolean;
4
+ data: any;
5
+ loading: boolean;
6
+ error: boolean;
5
7
  }
6
8
 
7
- export interface HTMLLegendPlugin {
8
- id: string;
9
- afterUpdate: (chart: any) => void;
10
- }
9
+ export type HTMLLegendPlugin = Plugin<
10
+ 'bar' | 'doughnut' | 'line',
11
+ Record<string, any>
12
+ >;
@@ -1,6 +1,14 @@
1
+ import { ChartData, Plugin } from 'chart.js';
2
+
3
+ type AnyObject = Record<string, any>;
4
+
1
5
  export interface DoughnutData {
2
6
  tooltipLabel?: number;
3
7
  value: number;
4
8
  unit: string;
5
9
  rate: number;
6
10
  }
11
+
12
+ export type DoughnutPlugin = Plugin<'doughnut', AnyObject>;
13
+
14
+ export type DoughnutChartData = ChartData<'doughnut', number[]>;
@@ -1,11 +1,11 @@
1
1
  export interface GenericData {
2
- value: number;
3
- position?: number;
4
- unit?: string;
5
- label?: string;
6
- rate?: number;
7
- color?: string;
8
- trendValue?: number
9
- trendMetricUnit?: string,
10
- tooltips?: [],
11
- }
2
+ value: number;
3
+ position?: number;
4
+ unit?: string;
5
+ label?: string;
6
+ rate?: number;
7
+ color?: string;
8
+ trendValue?: number;
9
+ trendMetricUnit?: string;
10
+ tooltips?: [];
11
+ }
@@ -1,5 +1,5 @@
1
1
  export interface LineData {
2
- label: string;
3
- data: number[];
4
- unit?: string;
5
- }
2
+ label: string;
3
+ data: number[];
4
+ unit?: string;
5
+ }
@@ -1,36 +1,40 @@
1
1
  export interface AreaData {
2
- value: number;
3
- position: number;
4
- unit: string;
5
- label: string | null;
6
- rate: number | null;
7
- color: string | null;
8
- trendValue: number | null;
9
- trendUnit: string | null;
10
- tooltips: string | null;
2
+ value: number;
3
+ position: number;
4
+ unit: string;
5
+ label: string | null;
6
+ rate: number | null;
7
+ color: string | null;
8
+ trendValue: number | null;
9
+ trendUnit: string | null;
10
+ tooltips: string | null;
11
11
  }
12
12
 
13
13
  export interface Area {
14
- label: string;
15
- areaData: AreaData[];
14
+ label: string;
15
+ areaData: AreaData[];
16
16
  }
17
17
 
18
18
  export interface RadarPropsData {
19
- radarData: {
20
- labels: string[],
21
- areas: [{
22
- label: string,
23
- areaData: [{
24
- value: number,
25
- position: number,
26
- unit: string,
27
- label?: string,
28
- rate?: null,
29
- color: string,
30
- trendValue?: number,
31
- trendUnit?: string,
32
- tooltips?: string[]
33
- }],
34
- }]
35
- }
36
- }
19
+ radarData: {
20
+ labels: string[];
21
+ areas: [
22
+ {
23
+ label: string;
24
+ areaData: [
25
+ {
26
+ value: number;
27
+ position: number;
28
+ unit: string;
29
+ label?: string;
30
+ rate?: null;
31
+ color: string;
32
+ trendValue?: number;
33
+ trendUnit?: string;
34
+ tooltips?: string[];
35
+ }
36
+ ];
37
+ }
38
+ ];
39
+ };
40
+ }
@@ -1,8 +1,8 @@
1
1
  export enum TooltipChartType {
2
- RADAR = 'RADAR',
3
- BAR_CHART = 'BAR_CHART',
4
- MIXED_BAR_LINE_CHART = 'MIXED_BAR_LINE_CHART',
5
- DETAILS_BAR_CHART = 'DETAILS_BAR_CHART',
6
- LINE_CHART = 'LINE_CHART',
7
- DOUGHNUT = 'DOUGHNUT'
8
- }
2
+ RADAR = 'RADAR',
3
+ BAR_CHART = 'BAR_CHART',
4
+ MIXED_BAR_LINE_CHART = 'MIXED_BAR_LINE_CHART',
5
+ DETAILS_BAR_CHART = 'DETAILS_BAR_CHART',
6
+ LINE_CHART = 'LINE_CHART',
7
+ DOUGHNUT = 'DOUGHNUT'
8
+ }
package/src/vite-env.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="vite/client" />
2
2
 
3
3
  declare module '*.vue' {
4
- import type { DefineComponent } from 'vue'
5
- const component: DefineComponent<{}, {}, any>
6
- export default component
4
+ import type { DefineComponent } from 'vue';
5
+ const component: DefineComponent<{}, {}, any>;
6
+ export default component;
7
7
  }