@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,25 +1,32 @@
1
1
  export default function () {
2
- function getPatternCanvas(pattern: CanvasPattern, width = 50, height = 50): HTMLCanvasElement {
3
- const canvas: HTMLCanvasElement = document.createElement('canvas');
4
- const ctx: CanvasRenderingContext2D | null = canvas.getContext('2d');
5
- if (!ctx) {
6
- return canvas;
7
- }
8
- canvas.width = width;
9
- canvas.height = height;
10
- ctx.fillStyle = pattern;
11
- ctx.fillRect(0, 0, width, height);
2
+ function getPatternCanvas(
3
+ pattern: CanvasPattern,
4
+ width = 50,
5
+ height = 50
6
+ ): HTMLCanvasElement {
7
+ const canvas: HTMLCanvasElement = document.createElement('canvas');
8
+ const ctx: CanvasRenderingContext2D | null = canvas.getContext('2d');
9
+ if (!ctx) {
12
10
  return canvas;
13
11
  }
12
+ canvas.width = width;
13
+ canvas.height = height;
14
+ ctx.fillStyle = pattern;
15
+ ctx.fillRect(0, 0, width, height);
16
+ return canvas;
17
+ }
14
18
 
15
- function getPatternIndexWithShift (dataSetIndex: number, patternShifting?: number) {
16
- return (patternShifting
17
- ? dataSetIndex + patternShifting
18
- : dataSetIndex) % 6;
19
- }
19
+ function getPatternIndexWithShift(
20
+ dataSetIndex: number,
21
+ patternShifting?: number
22
+ ) {
23
+ return (
24
+ (patternShifting ? dataSetIndex + patternShifting : dataSetIndex) % 6
25
+ );
26
+ }
20
27
 
21
28
  return {
22
- getPatternCanvas,
23
- getPatternIndexWithShift
29
+ getPatternCanvas,
30
+ getPatternIndexWithShift
24
31
  };
25
- }
32
+ }
@@ -74,17 +74,17 @@ const buildColorArray = (props: any): string[] => {
74
74
  export function splitLabelIfTooLong(axisLabel: string, buildValue: string) {
75
75
  const radarLimitLabelLength = 7;
76
76
  if (
77
- axisLabel.length > radarLimitLabelLength &&
78
- axisLabel.includes(' ', radarLimitLabelLength)
77
+ axisLabel.length > radarLimitLabelLength &&
78
+ axisLabel.includes(' ', radarLimitLabelLength)
79
79
  ) {
80
80
  const indexOfFirstSpaceAfterLimit: number = axisLabel.indexOf(
81
- ' ',
82
- radarLimitLabelLength
81
+ ' ',
82
+ radarLimitLabelLength
83
83
  );
84
84
  return [
85
85
  axisLabel.substring(0, indexOfFirstSpaceAfterLimit),
86
86
  axisLabel.substring(indexOfFirstSpaceAfterLimit),
87
- buildValue,
87
+ buildValue
88
88
  ];
89
89
  }
90
90
  return [axisLabel, buildValue];
@@ -5,29 +5,40 @@ import PatternVerticalLines from './patternVerticalLines';
5
5
  import PatternDashedDiagonals from './patternDashedDiagonals';
6
6
  import PatternCircles from './patternCircles';
7
7
 
8
- export default function() {
9
- const patternsStandardList = [
10
- PatternSquares,
11
- PatternDiagonals,
12
- PatternZigzag,
13
- PatternVerticalLines,
14
- PatternDashedDiagonals,
15
- PatternCircles
16
- ] as ((hover: boolean, color: string, disableAccessibility: boolean) => CanvasPattern)[];
8
+ export default function () {
9
+ const patternsStandardList = [
10
+ PatternSquares,
11
+ PatternDiagonals,
12
+ PatternZigzag,
13
+ PatternVerticalLines,
14
+ PatternDashedDiagonals,
15
+ PatternCircles
16
+ ] as ((
17
+ hover: boolean,
18
+ color: string,
19
+ disableAccessibility: boolean
20
+ ) => CanvasPattern)[];
17
21
 
18
- const colourSets: [string[], string[], string[], string[], string[], string[], string[]] = [
19
- ['#393879', '#006974', '#405D68', '#005C91', '#8C3500', '#8C0003'],
20
- ['#A274FF', '#143666', '#00A3B2', '#8C1551', '#F255A3', '#095359'],
21
- ['#00A3B2', '#143666', '#3D993D', '#8C1551', '#E56D17', '#4C3380'],
22
- ['#8C1551', '#E56D17', '#4C3380', '#4588E5', '#095359', '#F255A3'],
23
- ['#4588E5', '#4C3380', '#E56D17', '#143666', '#D94141', '#8C1551'],
24
- ['#143666', '#F255A3', '#095359', '#4588E5', '#8C1551', '#E56D17'],
25
- ['#A274FF', '#B0BBC0', '#B0BBC0', '#B0BBC0', '#B0BBC0', '#B0BBC0']
26
- ];
27
-
28
- return {
29
- patternsStandardList,
30
- colourSets
31
- };
22
+ const colourSets: [
23
+ string[],
24
+ string[],
25
+ string[],
26
+ string[],
27
+ string[],
28
+ string[],
29
+ string[]
30
+ ] = [
31
+ ['#393879', '#006974', '#405D68', '#005C91', '#8C3500', '#8C0003'],
32
+ ['#A274FF', '#143666', '#00A3B2', '#8C1551', '#F255A3', '#095359'],
33
+ ['#00A3B2', '#143666', '#3D993D', '#8C1551', '#E56D17', '#4C3380'],
34
+ ['#8C1551', '#E56D17', '#4C3380', '#4588E5', '#095359', '#F255A3'],
35
+ ['#4588E5', '#4C3380', '#E56D17', '#143666', '#D94141', '#8C1551'],
36
+ ['#143666', '#F255A3', '#095359', '#4588E5', '#8C1551', '#E56D17'],
37
+ ['#A274FF', '#B0BBC0', '#B0BBC0', '#B0BBC0', '#B0BBC0', '#B0BBC0']
38
+ ];
32
39
 
33
- }
40
+ return {
41
+ patternsStandardList,
42
+ colourSets
43
+ };
44
+ }
@@ -1,95 +1,122 @@
1
- export default function PatternCircles(hover: boolean, color: string = '#095359', disableAccessibility: boolean = false): CanvasPattern {
1
+ export default function PatternCircles(
2
+ hover: boolean,
3
+ color: string = '#095359',
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
 
5
9
  if (!ctx) {
6
- return new CanvasPattern;
10
+ return new CanvasPattern();
7
11
  }
8
-
12
+
9
13
  const patternSize = 50;
10
14
  const lineWidthPattern = 0.04 * patternSize;
11
-
15
+
12
16
  canvasPattern.width = patternSize;
13
17
  canvasPattern.height = patternSize;
14
-
18
+
15
19
  if (disableAccessibility === true) {
16
20
  ctx.beginPath();
17
21
  ctx.fillStyle = color;
18
- ctx.rect(0.000000, 0.000000, patternSize, patternSize);
22
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
19
23
  ctx.fill();
20
24
  } else {
21
25
  // Background
22
26
  ctx.beginPath();
23
27
  ctx.fillStyle = '#FFFFFF';
24
28
  ctx.lineWidth = 0.1005 * patternSize;
25
- ctx.rect(0.000000, 0.000000, patternSize, patternSize);
29
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
26
30
  ctx.fill();
27
31
  ctx.beginPath();
28
32
  ctx.globalAlpha = 0.1;
29
33
  ctx.fillStyle = color;
30
34
  ctx.lineWidth = 0.1005 * patternSize;
31
- ctx.rect(0.000000, 0.000000, patternSize, patternSize);
35
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
32
36
  ctx.fill();
33
-
37
+
34
38
  // #circle4
35
39
  ctx.beginPath();
36
40
  ctx.globalAlpha = 0.3;
37
41
  ctx.strokeStyle = color;
38
42
  ctx.lineWidth = lineWidthPattern;
39
- ctx.arc(lineWidthPattern + 0.06 * patternSize,
40
- lineWidthPattern + 0.06 * patternSize, 0.06 * patternSize, 0, 2 * Math.PI);
43
+ ctx.arc(
44
+ lineWidthPattern + 0.06 * patternSize,
45
+ lineWidthPattern + 0.06 * patternSize,
46
+ 0.06 * patternSize,
47
+ 0,
48
+ 2 * Math.PI
49
+ );
41
50
  ctx.stroke();
42
-
51
+
43
52
  // #circle6
44
53
  ctx.beginPath();
45
54
  ctx.globalAlpha = 0.7;
46
55
  ctx.strokeStyle = color;
47
56
  ctx.lineWidth = lineWidthPattern;
48
- ctx.arc(lineWidthPattern + 0.56 * patternSize,
49
- lineWidthPattern + 0.06 * patternSize, 0.06 * patternSize, 0, 2 * Math.PI);
57
+ ctx.arc(
58
+ lineWidthPattern + 0.56 * patternSize,
59
+ lineWidthPattern + 0.06 * patternSize,
60
+ 0.06 * patternSize,
61
+ 0,
62
+ 2 * Math.PI
63
+ );
50
64
  ctx.stroke();
51
-
65
+
52
66
  // #circle104
53
67
  ctx.beginPath();
54
68
  ctx.globalAlpha = 0.3;
55
69
  ctx.strokeStyle = color;
56
70
  ctx.lineWidth = 0.04 * patternSize;
57
- ctx.arc(-lineWidthPattern + 0.44 * patternSize,
58
- lineWidthPattern + 0.56 * patternSize, 0.06 * patternSize, 0, 2 * Math.PI);
71
+ ctx.arc(
72
+ -lineWidthPattern + 0.44 * patternSize,
73
+ lineWidthPattern + 0.56 * patternSize,
74
+ 0.06 * patternSize,
75
+ 0,
76
+ 2 * Math.PI
77
+ );
59
78
  ctx.stroke();
60
-
79
+
61
80
  // #circle106
62
81
  ctx.beginPath();
63
82
  ctx.globalAlpha = 0.7;
64
83
  ctx.strokeStyle = color;
65
84
  ctx.lineWidth = 0.04 * patternSize;
66
- ctx.arc(-lineWidthPattern + 0.94 * patternSize,
67
- lineWidthPattern + 0.56 * patternSize, 0.06 * patternSize, 0, 2 * Math.PI);
85
+ ctx.arc(
86
+ -lineWidthPattern + 0.94 * patternSize,
87
+ lineWidthPattern + 0.56 * patternSize,
88
+ 0.06 * patternSize,
89
+ 0,
90
+ 2 * Math.PI
91
+ );
68
92
  ctx.stroke();
69
93
  }
70
94
 
71
- // Hover Style
72
- if (hover) {
73
- ctx.beginPath();
74
- ctx.globalAlpha = 0.5;
75
- ctx.fillStyle = '#FFFFFF';
76
- ctx.lineWidth = 0.006 * patternSize;
77
- ctx.rect(0.000000, 0.000000, patternSize, patternSize);
78
- ctx.fill();
79
- }
80
-
81
- const canvas: HTMLCanvasElement = document.createElement('canvas');
95
+ // Hover Style
96
+ if (hover) {
97
+ ctx.beginPath();
98
+ ctx.globalAlpha = 0.5;
99
+ ctx.fillStyle = '#FFFFFF';
100
+ ctx.lineWidth = 0.006 * patternSize;
101
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
102
+ ctx.fill();
103
+ }
104
+
105
+ const canvas: HTMLCanvasElement = document.createElement('canvas');
82
106
  const context: CanvasRenderingContext2D | null = canvas.getContext('2d');
83
107
  if (!context) {
84
- return new CanvasPattern;
108
+ return new CanvasPattern();
85
109
  }
86
- const pattern: CanvasPattern | null = context.createPattern(canvasPattern, 'repeat');
110
+ const pattern: CanvasPattern | null = context.createPattern(
111
+ canvasPattern,
112
+ 'repeat'
113
+ );
87
114
  if (!pattern) {
88
- return new CanvasPattern;
115
+ return new CanvasPattern();
89
116
  }
90
-
117
+
91
118
  context.fillStyle = pattern;
92
119
  context.fillRect(0, 0, canvas.width, canvas.height);
93
120
 
94
121
  return pattern;
95
- }
122
+ }
@@ -1,39 +1,43 @@
1
- export default function PatternDashedDiagonals(hover: boolean, color: string = '#F255A3', disableAccessibility: boolean = false): CanvasPattern {
2
- const canvasPattern: HTMLCanvasElement = document.createElement('canvas');
3
- const ctx: CanvasRenderingContext2D | null = canvasPattern.getContext('2d');
1
+ export default function PatternDashedDiagonals(
2
+ hover: boolean,
3
+ color: string = '#F255A3',
4
+ disableAccessibility: boolean = false
5
+ ): CanvasPattern {
6
+ const canvasPattern: HTMLCanvasElement = document.createElement('canvas');
7
+ const ctx: CanvasRenderingContext2D | null = canvasPattern.getContext('2d');
4
8
 
5
- if (!ctx) {
6
- return new CanvasPattern;
7
- }
9
+ if (!ctx) {
10
+ return new CanvasPattern();
11
+ }
8
12
 
9
- const matrix = new DOMMatrix();
13
+ const matrix = new DOMMatrix();
10
14
 
11
- const patternSize = 21;
12
- const lineWidth = 0.1 * patternSize;
15
+ const patternSize = 21;
16
+ const lineWidth = 0.1 * patternSize;
13
17
 
14
- canvasPattern.width = patternSize;
15
- canvasPattern.height = patternSize;
18
+ canvasPattern.width = patternSize;
19
+ canvasPattern.height = patternSize;
16
20
 
17
- if (disableAccessibility === true) {
18
- ctx.beginPath();
19
- ctx.fillStyle = color;
20
- ctx.rect(0.000000, 0.000000, patternSize, patternSize);
21
- ctx.fill();
22
- } else {
23
- // Background
24
- ctx.beginPath();
25
- ctx.fillStyle = '#FFFFFF';
26
- ctx.lineWidth = 0.005 * patternSize;
27
- ctx.rect(0.000000, 0.000000, 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.000000, 0.000000, patternSize, patternSize);
34
- ctx.fill();
21
+ if (disableAccessibility === true) {
22
+ ctx.beginPath();
23
+ ctx.fillStyle = color;
24
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
25
+ ctx.fill();
26
+ } else {
27
+ // Background
28
+ ctx.beginPath();
29
+ ctx.fillStyle = '#FFFFFF';
30
+ ctx.lineWidth = 0.005 * patternSize;
31
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
32
+ ctx.fill();
33
+ ctx.beginPath();
34
+ ctx.globalAlpha = 0.1;
35
+ ctx.fillStyle = color;
36
+ ctx.lineWidth = 0.005 * patternSize;
37
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
38
+ ctx.fill();
35
39
 
36
- // #path991
40
+ // #path991
37
41
  ctx.beginPath();
38
42
  ctx.globalAlpha = 0.3;
39
43
  ctx.strokeStyle = color;
@@ -42,7 +46,7 @@ export default function PatternDashedDiagonals(hover: boolean, color: string = '
42
46
  ctx.lineTo(lineWidth, 0.5 * patternSize);
43
47
  ctx.stroke();
44
48
 
45
- // #path991
49
+ // #path991
46
50
  ctx.beginPath();
47
51
  ctx.globalAlpha = 0.7;
48
52
  ctx.strokeStyle = color;
@@ -52,29 +56,32 @@ export default function PatternDashedDiagonals(hover: boolean, color: string = '
52
56
  ctx.stroke();
53
57
  }
54
58
 
55
- // Hover Style
56
- if (hover) {
57
- ctx.beginPath();
58
- ctx.fillStyle = '#FFFFFF';
59
- ctx.globalAlpha = 0.5;
60
- ctx.lineWidth = 0.006 * patternSize;
61
- ctx.rect(0.000000, 0.000000, patternSize, patternSize);
62
- ctx.fill();
63
- }
64
-
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(canvasPattern, 'repeat');
71
- if (!pattern) {
72
- return new CanvasPattern;
73
- }
74
-
75
- context.fillStyle = pattern;
76
- context.fillRect(0, 0, canvas.width, canvas.height);
77
- pattern.setTransform(matrix.rotate(45));
78
-
79
- return pattern;
80
- }
59
+ // Hover Style
60
+ if (hover) {
61
+ ctx.beginPath();
62
+ ctx.fillStyle = '#FFFFFF';
63
+ ctx.globalAlpha = 0.5;
64
+ ctx.lineWidth = 0.006 * patternSize;
65
+ ctx.rect(0.0, 0.0, patternSize, patternSize);
66
+ ctx.fill();
67
+ }
68
+
69
+ const canvas: HTMLCanvasElement = document.createElement('canvas');
70
+ const context: CanvasRenderingContext2D | null = canvas.getContext('2d');
71
+ if (!context) {
72
+ return new CanvasPattern();
73
+ }
74
+ const pattern: CanvasPattern | null = context.createPattern(
75
+ canvasPattern,
76
+ 'repeat'
77
+ );
78
+ if (!pattern) {
79
+ return new CanvasPattern();
80
+ }
81
+
82
+ context.fillStyle = pattern;
83
+ context.fillRect(0, 0, canvas.width, canvas.height);
84
+ pattern.setTransform(matrix.rotate(45));
85
+
86
+ return pattern;
87
+ }