@mozaic-ds/chart 0.1.0-beta.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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -0
  3. package/dist/mozaic-chart.js +9858 -0
  4. package/dist/mozaic-chart.umd.cjs +22 -0
  5. package/dist/style.css +1 -0
  6. package/dist/vite.svg +1 -0
  7. package/package.json +79 -0
  8. package/src/assets/base.css +2 -0
  9. package/src/components/bar/BarChart.stories.ts +298 -0
  10. package/src/components/bar/BarChart.vue +247 -0
  11. package/src/components/doughnut/DoughnutChart.stories.ts +80 -0
  12. package/src/components/doughnut/DoughnutChart.vue +208 -0
  13. package/src/components/line/LineChart.stories.ts +60 -0
  14. package/src/components/line/LineChart.vue +245 -0
  15. package/src/components/radar/RadarChart.stories.ts +346 -0
  16. package/src/components/radar/RadarChart.vue +265 -0
  17. package/src/main.ts +6 -0
  18. package/src/services/BarChartFunctions.ts +126 -0
  19. package/src/services/ChartsCommonLegend.ts +366 -0
  20. package/src/services/DoughnutChartFunctions.ts +89 -0
  21. package/src/services/FormatUtilities.ts +30 -0
  22. package/src/services/GenericTooltipService.ts +305 -0
  23. package/src/services/PatternFunctions.ts +25 -0
  24. package/src/services/RadarChartFunctions.ts +70 -0
  25. package/src/services/patterns/ChartDesign.ts +27 -0
  26. package/src/services/patterns/patternCircles.ts +82 -0
  27. package/src/services/patterns/patternDashedDiagonals.ts +66 -0
  28. package/src/services/patterns/patternDiagonals.ts +101 -0
  29. package/src/services/patterns/patternSquares.ts +76 -0
  30. package/src/services/patterns/patternVerticalLines.ts +61 -0
  31. package/src/services/patterns/patternZigzag.ts +88 -0
  32. package/src/types/BarData.ts +11 -0
  33. package/src/types/ButtonName.ts +7 -0
  34. package/src/types/Chart.ts +10 -0
  35. package/src/types/DoughnutData.ts +6 -0
  36. package/src/types/GenericData.ts +11 -0
  37. package/src/types/LineChart.ts +5 -0
  38. package/src/types/RadarData.ts +36 -0
  39. package/src/types/TooltipChartType.ts +7 -0
  40. package/src/vite-env.d.ts +7 -0
@@ -0,0 +1,76 @@
1
+ export default function PatternSquares(hover: boolean): CanvasPattern {
2
+
3
+ const patternCanvas: HTMLCanvasElement = document.createElement('canvas');
4
+ const ctx: CanvasRenderingContext2D | null = patternCanvas.getContext('2d');
5
+ if (!ctx) {
6
+ return new CanvasPattern;
7
+ }
8
+
9
+ const patternSize = 50;
10
+ const squareSize = patternSize * 0.15;
11
+
12
+ patternCanvas.width = patternSize;
13
+ patternCanvas.height = patternSize;
14
+
15
+ // #rect1258
16
+ ctx.beginPath();
17
+ ctx.fillStyle = 'rgb(231, 231, 240)';
18
+ ctx.lineWidth = 0.005 * patternSize;
19
+ ctx.rect(0.000000, 0.000000, patternSize, patternSize);
20
+ ctx.fill();
21
+
22
+ // #rect4
23
+ ctx.beginPath();
24
+ ctx.globalAlpha = 0.7;
25
+ ctx.fillStyle = 'rgb(57, 56, 121)';
26
+ ctx.lineWidth = 0.006 * patternSize;
27
+ ctx.rect(0.5 * patternSize, 0.000000, squareSize, squareSize);
28
+ ctx.fill();
29
+
30
+ // #rect54
31
+ ctx.beginPath();
32
+ ctx.globalAlpha = 0.7;
33
+ ctx.fillStyle = 'rgb(57, 56, 121)';
34
+ ctx.lineWidth = 0.006 * patternSize;
35
+ ctx.rect(0.75 * patternSize, patternSize / 2, squareSize, squareSize);
36
+ ctx.fill();
37
+
38
+ // #rect104
39
+ ctx.beginPath();
40
+ ctx.globalAlpha = 0.3;
41
+ ctx.fillStyle = 'rgb(57, 56, 121)';
42
+ ctx.lineWidth = 0.006 * patternSize;
43
+ ctx.rect(0.000000, 0.000000, squareSize, squareSize);
44
+ ctx.fill();
45
+
46
+ // #rect154
47
+ ctx.beginPath();
48
+ ctx.globalAlpha = 0.3;
49
+ ctx.fillStyle = 'rgb(57, 56, 121)';
50
+ ctx.lineWidth = 0.006 * patternSize;
51
+ ctx.rect(0.25 * patternSize, patternSize / 2, squareSize, squareSize);
52
+ ctx.fill();
53
+
54
+ // Hover Style
55
+ if (hover) {
56
+ ctx.beginPath();
57
+ ctx.globalAlpha = 0.5;
58
+ ctx.fillStyle = '#FFFFFF';
59
+ ctx.lineWidth = 0.006 * patternSize;
60
+ ctx.rect(0.000000, 0.000000, patternSize, patternSize);
61
+ ctx.fill();
62
+ }
63
+
64
+ // Create our primary canvas and fill it with the pattern
65
+ const canvas: HTMLCanvasElement = document.createElement('canvas');
66
+ const context: CanvasRenderingContext2D | null = canvas.getContext('2d');
67
+ if (!context) {
68
+ return new CanvasPattern;
69
+ }
70
+ const pattern: CanvasPattern | null = context.createPattern(patternCanvas, 'repeat');
71
+ if (!pattern) {
72
+ return new CanvasPattern;
73
+ }
74
+
75
+ return pattern;
76
+ }
@@ -0,0 +1,61 @@
1
+ export default function PatternVerticalLines(hover: boolean): CanvasPattern {
2
+ const canvasPattern: HTMLCanvasElement = document.createElement('canvas');
3
+ const ctx: CanvasRenderingContext2D | null = canvasPattern.getContext('2d');
4
+ if (!ctx) {
5
+ return new CanvasPattern;
6
+ }
7
+
8
+ const patternSize = 50;
9
+ const lineSize = patternSize * 0.15;
10
+
11
+ canvasPattern.width = patternSize;
12
+ canvasPattern.height = patternSize;
13
+
14
+ // #rect1258
15
+ ctx.beginPath();
16
+ ctx.fillStyle = 'rgb(218, 239, 247)';
17
+ ctx.lineWidth = 0.005 * patternSize;
18
+ ctx.rect(0.000000, 0.000000, patternSize, patternSize);
19
+ ctx.fill();
20
+
21
+ // #rect4
22
+ ctx.beginPath();
23
+ ctx.globalAlpha = 0.3;
24
+ ctx.fillStyle = 'rgb(0, 92, 145)';
25
+ ctx.lineWidth = 0.005 * patternSize;
26
+ ctx.rect(0.000000, 0.000000, lineSize, patternSize);
27
+ ctx.fill();
28
+
29
+ // #rect6
30
+ ctx.beginPath();
31
+ ctx.globalAlpha = 0.7;
32
+ ctx.fillStyle = 'rgb(0, 92, 145)';
33
+ ctx.lineWidth = 0.005 * patternSize;
34
+ ctx.rect(patternSize / 2, 0.000000, lineSize, patternSize);
35
+ ctx.fill();
36
+
37
+ // Hover Style
38
+ if (hover) {
39
+ ctx.beginPath();
40
+ ctx.globalAlpha = 0.5;
41
+ ctx.fillStyle = '#FFFFFF';
42
+ ctx.lineWidth = 0.006 * patternSize;
43
+ ctx.rect(0.000000, 0.000000, patternSize, patternSize);
44
+ ctx.fill();
45
+ }
46
+
47
+ const canvas: HTMLCanvasElement = document.createElement('canvas');
48
+ const context: CanvasRenderingContext2D | null = canvas.getContext('2d');
49
+ if (!context) {
50
+ return new CanvasPattern;
51
+ }
52
+ const pattern: CanvasPattern | null = context.createPattern(canvasPattern, 'repeat');
53
+ if (!pattern) {
54
+ return new CanvasPattern;
55
+ }
56
+
57
+ context.fillStyle = pattern;
58
+ context.fillRect(0, 0, patternSize, patternSize);
59
+
60
+ return pattern;
61
+ }
@@ -0,0 +1,88 @@
1
+ export default function PatternZigzag(hover: boolean): CanvasPattern {
2
+ const canvasPattern: HTMLCanvasElement = document.createElement('canvas');
3
+ const ctx: CanvasRenderingContext2D | null = canvasPattern.getContext('2d');
4
+ if (!ctx) {
5
+ return new CanvasPattern;
6
+ }
7
+
8
+ const patternSize = 50;
9
+
10
+ canvasPattern.width = patternSize;
11
+ canvasPattern.height = patternSize;
12
+
13
+ // #rect1258
14
+ ctx.beginPath();
15
+ ctx.fillStyle = 'rgb(234, 237, 239)';
16
+ ctx.lineWidth = 0.005 * patternSize;
17
+ ctx.rect(0.000000, 0.000000, patternSize, patternSize);
18
+ ctx.fill();
19
+
20
+ // #path4
21
+ ctx.beginPath();
22
+ ctx.globalAlpha = 0.7;
23
+ ctx.strokeStyle = 'rgb(64, 93, 104)';
24
+ ctx.lineWidth = 0.08 * patternSize;
25
+ ctx.moveTo(- patternSize / 2, patternSize / 2);
26
+ ctx.lineTo(0.000000, 0.000000);
27
+ ctx.lineTo(patternSize / 2, patternSize / 2);
28
+ ctx.lineTo(patternSize, 0.000000);
29
+ ctx.stroke();
30
+
31
+ // #path6
32
+ ctx.beginPath();
33
+ ctx.globalAlpha = 0.3;
34
+ ctx.strokeStyle = 'rgb(64, 93, 104)';
35
+ ctx.lineWidth = 0.08 * patternSize;
36
+ ctx.moveTo(- patternSize / 2, patternSize);
37
+ ctx.lineTo(0.000000, patternSize / 2);
38
+ ctx.lineTo(patternSize / 2, patternSize);
39
+ ctx.lineTo(patternSize, patternSize / 2);
40
+ ctx.lineTo(patternSize + (patternSize / 2), patternSize);
41
+ ctx.stroke();
42
+
43
+ // #path6-6
44
+ ctx.beginPath();
45
+ ctx.globalAlpha = 0.3;
46
+ ctx.strokeStyle = 'rgb(64, 93, 104)';
47
+ ctx.lineWidth = 0.08 * patternSize;
48
+ ctx.moveTo(- patternSize / 2, 0.000111);
49
+ ctx.lineTo(0.000004 * patternSize, - patternSize / 2);
50
+ ctx.lineTo(patternSize / 2, 0.000111);
51
+ ctx.lineTo(patternSize, - patternSize / 2);
52
+ ctx.lineTo(patternSize + (patternSize / 2), 0.000111);
53
+ ctx.stroke();
54
+
55
+ // #path6-5
56
+ ctx.beginPath();
57
+ ctx.globalAlpha = 0.7;
58
+ ctx.strokeStyle = 'rgb(64, 93, 104)';
59
+ ctx.lineWidth = 0.08 * patternSize;
60
+ ctx.moveTo(- patternSize / 2, patternSize + (patternSize / 2));
61
+ ctx.lineTo(0.000000, patternSize);
62
+ ctx.lineTo(patternSize / 2, patternSize + (patternSize / 2));
63
+ ctx.lineTo(patternSize, patternSize);
64
+ ctx.lineTo(patternSize + (patternSize / 2), patternSize + (patternSize / 2));
65
+ ctx.stroke();
66
+
67
+ // Hover Style
68
+ if (hover) {
69
+ ctx.beginPath();
70
+ ctx.globalAlpha = 0.5;
71
+ ctx.fillStyle = '#FFFFFF';
72
+ ctx.lineWidth = 0.006 * patternSize;
73
+ ctx.rect(0.000000, 0.000000, patternSize, patternSize);
74
+ ctx.fill();
75
+ }
76
+
77
+ const canvas: HTMLCanvasElement = document.createElement('canvas');
78
+ const context: CanvasRenderingContext2D | null = canvas.getContext('2d');
79
+ if (!context) {
80
+ return new CanvasPattern;
81
+ }
82
+ const pattern: CanvasPattern | null = context.createPattern(canvasPattern, 'repeat');
83
+ if (!pattern) {
84
+ return new CanvasPattern;
85
+ }
86
+
87
+ return pattern;
88
+ }
@@ -0,0 +1,11 @@
1
+ export interface DataBarData {
2
+ amount: number;
3
+ amountUnit: string;
4
+ rate: number;
5
+ }
6
+
7
+ export interface BarData {
8
+ label: string;
9
+ backgroundColor?: string;
10
+ data: DataBarData[];
11
+ }
@@ -0,0 +1,7 @@
1
+ export enum ButtonName {
2
+ SALES = 'sales',
3
+ PURCHASES = 'purchases',
4
+ PROFITABILITY = 'profitability',
5
+ COMPETITORS = 'vsConcurrency',
6
+ PREVIOUS_YEAR = 'vsN-1'
7
+ }
@@ -0,0 +1,10 @@
1
+ export interface ChartData {
2
+ data: any;
3
+ loading: boolean;
4
+ error: boolean;
5
+ }
6
+
7
+ export interface HTMLLegendPlugin {
8
+ id: string;
9
+ afterUpdate: (chart: any) => void;
10
+ }
@@ -0,0 +1,6 @@
1
+ export interface DoughnutData {
2
+ tooltipLabel?: number;
3
+ value: number;
4
+ unit: string;
5
+ rate: number;
6
+ }
@@ -0,0 +1,11 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ export interface LineData {
2
+ label: string;
3
+ data: number[];
4
+ unit?: string;
5
+ }
@@ -0,0 +1,36 @@
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;
11
+ }
12
+
13
+ export interface Area {
14
+ label: string;
15
+ areaData: AreaData[];
16
+ }
17
+
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
+ }
@@ -0,0 +1,7 @@
1
+ export enum TooltipChartType {
2
+ RADAR = 'RADAR',
3
+ BAR_CHART = 'BAR_CHART',
4
+ DETAILS_BAR_CHART = 'DETAILS_BAR_CHART',
5
+ LINE_CHART = 'LINE_CHART',
6
+ DOUGHNUT = 'DOUGHNUT'
7
+ }
@@ -0,0 +1,7 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module '*.vue' {
4
+ import type { DefineComponent } from 'vue'
5
+ const component: DefineComponent<{}, {}, any>
6
+ export default component
7
+ }