@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.
- package/README.md +1 -1
- package/dist/mozaic-chart.js +2303 -2109
- package/dist/mozaic-chart.umd.cjs +9 -9
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/assets/base.css +1 -1
- package/src/components/bar/BarChart.stories.ts +99 -99
- package/src/components/bar/BarChart.vue +70 -53
- package/src/components/bar/index.ts +3 -3
- package/src/components/bubble/BubbleChart.stories.ts +12 -12
- package/src/components/bubble/BubbleChart.vue +118 -91
- package/src/components/bubble/index.ts +3 -3
- package/src/components/doughnut/DoughnutChart.stories.ts +38 -37
- package/src/components/doughnut/DoughnutChart.vue +89 -71
- package/src/components/doughnut/index.ts +3 -3
- package/src/components/index.ts +4 -4
- package/src/components/line/LineChart.stories.ts +38 -38
- package/src/components/line/LineChart.vue +54 -51
- package/src/components/line/index.ts +3 -3
- package/src/components/mixed/MixedBarLineChart.stories.ts +15 -15
- package/src/components/mixed/MixedBarLineChart.vue +44 -44
- package/src/components/mixed/index.ts +1 -1
- package/src/components/radar/RadarChart.stories.ts +100 -100
- package/src/components/radar/RadarChart.vue +41 -34
- package/src/components/radar/index.ts +3 -3
- package/src/main.ts +14 -7
- package/src/plugin.ts +9 -9
- package/src/services/BarChartFunctions.ts +133 -35
- package/src/services/BubbleTooltipService.ts +58 -56
- package/src/services/ChartsCommonLegend.ts +271 -127
- package/src/services/ColorFunctions.ts +1 -1
- package/src/services/DoughnutChartFunctions.ts +42 -13
- package/src/services/FormatUtilities.ts +28 -14
- package/src/services/GenericTooltipService.ts +125 -65
- package/src/services/MixedBarLineFunctions.ts +46 -44
- package/src/services/PatternFunctions.ts +25 -18
- package/src/services/RadarChartFunctions.ts +5 -5
- package/src/services/patterns/ChartDesign.ts +35 -24
- package/src/services/patterns/patternCircles.ts +63 -36
- package/src/services/patterns/patternDashedDiagonals.ts +64 -57
- package/src/services/patterns/patternDiagonals.ts +138 -106
- package/src/services/patterns/patternSquares.ts +86 -80
- package/src/services/patterns/patternVerticalLines.ts +76 -69
- package/src/services/patterns/patternZigzag.ts +92 -85
- package/src/stories/Changelog.mdx +2 -2
- package/src/stories/Contributing.mdx +2 -2
- package/src/stories/GettingStarted.mdx +5 -5
- package/src/stories/SupportAndOnboarding.mdx +6 -6
- package/src/types/AxisDefinition.ts +0 -2
- package/src/types/Chart.ts +9 -7
- package/src/types/DoughnutData.ts +8 -0
- package/src/types/GenericData.ts +10 -10
- package/src/types/LineChart.ts +4 -4
- package/src/types/RadarData.ts +33 -29
- package/src/types/TooltipChartType.ts +7 -7
- package/src/vite-env.d.ts +3 -3
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
export default function () {
|
|
2
|
-
function getPatternCanvas(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
|
|
78
|
-
|
|
77
|
+
axisLabel.length > radarLimitLabelLength &&
|
|
78
|
+
axisLabel.includes(' ', radarLimitLabelLength)
|
|
79
79
|
) {
|
|
80
80
|
const indexOfFirstSpaceAfterLimit: number = axisLabel.indexOf(
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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(
|
|
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.
|
|
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.
|
|
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.
|
|
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(
|
|
40
|
-
lineWidthPattern + 0.06 * patternSize,
|
|
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(
|
|
49
|
-
lineWidthPattern + 0.
|
|
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(
|
|
58
|
-
lineWidthPattern + 0.
|
|
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(
|
|
67
|
-
lineWidthPattern + 0.
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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(
|
|
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(
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
if (!ctx) {
|
|
10
|
+
return new CanvasPattern();
|
|
11
|
+
}
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
const matrix = new DOMMatrix();
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
const patternSize = 21;
|
|
16
|
+
const lineWidth = 0.1 * patternSize;
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
canvasPattern.width = patternSize;
|
|
19
|
+
canvasPattern.height = patternSize;
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
+
}
|