@mozaic-ds/chart 0.1.0-beta.0 → 0.1.0-beta.10
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/dist/mozaic-chart.js +3390 -2582
- package/dist/mozaic-chart.umd.cjs +11 -11
- package/dist/style.css +1 -1
- package/package.json +38 -24
- package/src/components/bar/BarChart.stories.ts +13 -9
- package/src/components/bar/BarChart.vue +234 -106
- package/src/components/bar/index.ts +8 -0
- package/src/components/doughnut/DoughnutChart.stories.ts +3 -0
- package/src/components/doughnut/DoughnutChart.vue +205 -95
- package/src/components/doughnut/index.ts +8 -0
- package/src/components/index.ts +4 -0
- package/src/components/line/LineChart.stories.ts +0 -1
- package/src/components/line/LineChart.vue +310 -219
- package/src/components/line/index.ts +8 -0
- package/src/components/mixed/MixedBarLineChart.stories.ts +87 -0
- package/src/components/mixed/MixedBarLineChart.vue +404 -0
- package/src/components/mixed/index.ts +8 -0
- package/src/components/radar/RadarChart.stories.ts +2 -2
- package/src/components/radar/RadarChart.vue +231 -126
- package/src/components/radar/index.ts +8 -0
- package/src/main.ts +2 -1
- package/src/plugin.ts +19 -0
- package/src/services/BarChartFunctions.ts +16 -20
- package/src/services/ChartsCommonLegend.ts +54 -47
- package/src/services/ColorFunctions.ts +4 -0
- package/src/services/DoughnutChartFunctions.ts +111 -59
- package/src/services/FormatUtilities.ts +1 -1
- package/src/services/GenericTooltipService.ts +55 -34
- package/src/services/MixedBarLineFunctions.ts +280 -0
- package/src/services/RadarChartFunctions.ts +13 -11
- package/src/services/patterns/ChartDesign.ts +15 -9
- package/src/services/patterns/patternCircles.ts +63 -50
- package/src/services/patterns/patternDashedDiagonals.ts +46 -32
- package/src/services/patterns/patternDiagonals.ts +85 -71
- package/src/services/patterns/patternSquares.ts +56 -44
- package/src/services/patterns/patternVerticalLines.ts +41 -28
- package/src/services/patterns/patternZigzag.ts +20 -7
- package/src/stories/Changelog.mdx +6 -0
- package/src/stories/Contributing.mdx +101 -0
- package/src/stories/GettingStarted.mdx +92 -0
- package/src/stories/SupportAndOnboarding.mdx +44 -0
- package/src/types/MixedBarLineData.ts +7 -0
- package/src/types/TooltipChartType.ts +1 -0
|
@@ -1,180 +1,265 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="container">
|
|
3
3
|
<div class="main">
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<div ref="legendContainer" />
|
|
4
|
+
<Line
|
|
5
|
+
v-if="chartData"
|
|
6
|
+
ref="lineChartRef"
|
|
7
|
+
:id="chartId"
|
|
8
|
+
:data="chartData"
|
|
9
|
+
:options="options"
|
|
10
|
+
:plugins="htmlLegendPlugin"
|
|
11
|
+
:class="cssClasses"
|
|
12
|
+
:style="[{ width, height, cursor: 'pointer' }, styles]"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
<div ref="legendContainer" />
|
|
17
16
|
</div>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import type { Ref } from 'vue';
|
|
21
|
+
import { computed, ref, PropType } from 'vue';
|
|
22
|
+
import { Line } from 'vue-chartjs';
|
|
23
|
+
import { LineData } from '../../types/LineChart';
|
|
24
|
+
import { GenericTooltipService } from '../../services/GenericTooltipService';
|
|
25
|
+
import type { Context } from '../../services/GenericTooltipService';
|
|
26
|
+
import { TooltipChartType } from '../../types/TooltipChartType';
|
|
27
|
+
import { formatWithThousandsSeprators } from '../../services/FormatUtilities';
|
|
28
|
+
import type { ChartItem } from '../../services/ChartsCommonLegend';
|
|
29
|
+
import ChartDesign from '../../services/patterns/ChartDesign';
|
|
30
|
+
|
|
31
|
+
import {
|
|
32
|
+
createHtmlLegendItemText,
|
|
33
|
+
createHtmlLegendListElement,
|
|
34
|
+
createLegendElementWithSquareArea,
|
|
35
|
+
getOrCreateLegendList,
|
|
36
|
+
createLegendCheckbox,
|
|
37
|
+
switchItemVisibility,
|
|
38
|
+
} from '../../services/ChartsCommonLegend';
|
|
39
|
+
|
|
40
|
+
import {
|
|
41
|
+
CategoryScale,
|
|
42
|
+
Chart as ChartJS,
|
|
43
|
+
Legend,
|
|
44
|
+
LinearScale,
|
|
45
|
+
LineElement,
|
|
46
|
+
PointElement,
|
|
47
|
+
Title,
|
|
48
|
+
Tooltip,
|
|
49
|
+
Plugin,
|
|
50
|
+
} from 'chart.js';
|
|
51
|
+
|
|
52
|
+
ChartJS.register(
|
|
53
|
+
Title,
|
|
54
|
+
Tooltip,
|
|
55
|
+
Legend,
|
|
56
|
+
PointElement,
|
|
57
|
+
LineElement,
|
|
58
|
+
CategoryScale,
|
|
59
|
+
LinearScale
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const { colourSets, patternsStandardList } = ChartDesign();
|
|
63
|
+
|
|
64
|
+
const legendContainer = ref(null);
|
|
65
|
+
const selectMode = ref(false);
|
|
66
|
+
const lineDataProps = defineProps({
|
|
67
|
+
/**
|
|
68
|
+
* Value of the id attribute present on the <canvas> tag element the chart
|
|
69
|
+
*/
|
|
70
|
+
chartId: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: 'radar-chart',
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Label of the first line in the Tooltip
|
|
76
|
+
*/
|
|
77
|
+
tooltipFirstLineLabel: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: 'content',
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Label of the second line in the Tooltip
|
|
83
|
+
*/
|
|
84
|
+
tooltipSecondLineLabel: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: 'content2',
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* Value of the `width` css property used to define the width of the <canvas> element
|
|
90
|
+
*/
|
|
91
|
+
width: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: '200px',
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* Value of the `height` css property used to define the height of the <canvas> element
|
|
97
|
+
*/
|
|
98
|
+
height: {
|
|
99
|
+
type: String,
|
|
100
|
+
default: '400px',
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* Disable accessibility patterns
|
|
104
|
+
*/
|
|
105
|
+
disableAccessibility: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
default: false,
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* Used to choose the colour set of the charts as defined in the Figma prototypes.
|
|
111
|
+
* 7 colour sets are currently defined:
|
|
112
|
+
* - Default 0 corresponds to the current one
|
|
113
|
+
* - 1 to 6 corresponds to the "new" [colour sets](https://www.figma.com/file/Hn6PyvnR385Ta0XN3KqOI9/04.-Dataviz---Documentation-(read-only)?type=design&node-id=1-69316&mode=design&t=sDytQ5BipsryWkuA-0)
|
|
114
|
+
* Note: All the sets are defined in /src/services/patterns/ChartDesign.ts
|
|
115
|
+
*/
|
|
116
|
+
colourSet: {
|
|
117
|
+
type: Number,
|
|
118
|
+
default: 0,
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* 6 patterns exist and are not randomly given but follow the order defined in [patternsStandardList](/src/services/patterns/ChartDesign.ts)
|
|
122
|
+
* Additionally, a pattern has only one possible colour per colour set as defined in the Figma prototype.
|
|
123
|
+
* In some use cases, the chart may need to show a different orders of these patterns, this can be changed using the props newPatternsOrder
|
|
124
|
+
*/
|
|
125
|
+
newPatternsOrder: {
|
|
126
|
+
type: Array as PropType<number[]>,
|
|
127
|
+
default: () => [0, 1, 2, 3, 4, 5],
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* Line data _(can contain `label`, `data` and `unit` keys)_
|
|
131
|
+
*/
|
|
132
|
+
lines: {
|
|
133
|
+
type: Array as PropType<LineData[]>,
|
|
134
|
+
default: () => {},
|
|
135
|
+
},
|
|
136
|
+
/**
|
|
137
|
+
* Labels used to label the index axis (default x axes). See [Data structures documentation](https://www.chartjs.org/docs/latest/general/data-structures.html)
|
|
138
|
+
*/
|
|
139
|
+
labels: {
|
|
140
|
+
type: Array as PropType<string[]>,
|
|
141
|
+
default: () => [],
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
* Add custom CSS classes to the <canvas> element
|
|
145
|
+
*/
|
|
146
|
+
cssClasses: {
|
|
147
|
+
type: String,
|
|
148
|
+
default: undefined,
|
|
149
|
+
},
|
|
150
|
+
/**
|
|
151
|
+
* Add custom CSS styles to the <canvas> element
|
|
152
|
+
*/
|
|
153
|
+
styles: {
|
|
154
|
+
type: Object as PropType<Partial<CSSStyleDeclaration>>,
|
|
155
|
+
default: () => {},
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* Value of the `plugins` key passed to the Chart config
|
|
159
|
+
*/
|
|
160
|
+
plugins: {
|
|
161
|
+
type: Array as PropType<Plugin<'line'>[]>,
|
|
162
|
+
default: () => [],
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const patternsColors = computed(() =>
|
|
167
|
+
lineDataProps.newPatternsOrder.length !== 6
|
|
168
|
+
? colourSets[lineDataProps.colourSet]
|
|
169
|
+
: lineDataProps.newPatternsOrder.map((id) => {
|
|
170
|
+
return colourSets[lineDataProps.colourSet][id];
|
|
171
|
+
})
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const patternsOrderedList =
|
|
175
|
+
lineDataProps.newPatternsOrder.length !== 6
|
|
176
|
+
? patternsStandardList
|
|
177
|
+
: lineDataProps.newPatternsOrder.map((id) => {
|
|
178
|
+
return patternsStandardList[id];
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const getTooltipData = (context: Context) => {
|
|
182
|
+
const datasetIndex = context.tooltip.dataPoints[0].datasetIndex as number;
|
|
183
|
+
const dataIndex = context.tooltip.dataPoints[0].dataIndex as number;
|
|
184
|
+
const formattedValue =
|
|
185
|
+
lineDataProps.lines[datasetIndex].data[dataIndex].toFixed(2);
|
|
186
|
+
return lineDataProps.lines[datasetIndex].unit
|
|
187
|
+
? formattedValue + ' ' + lineDataProps.lines[datasetIndex].unit
|
|
188
|
+
: formattedValue;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const tooltipFirstLine = computed(() => {
|
|
192
|
+
return lineDataProps.tooltipFirstLineLabel;
|
|
193
|
+
});
|
|
194
|
+
const tooltipSecondLine = computed(() => {
|
|
195
|
+
return lineDataProps.tooltipSecondLineLabel;
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const chartData = computed(() => {
|
|
199
|
+
return {
|
|
200
|
+
labels: lineDataProps.labels.map((label: string) => label),
|
|
201
|
+
datasets: [
|
|
202
|
+
{
|
|
203
|
+
type: 'line' as const,
|
|
204
|
+
borderColor: patternsColors.value[0],
|
|
205
|
+
pointStyle: 'rectRot',
|
|
206
|
+
pointBackgroundColor: '#FFFFFF',
|
|
207
|
+
pointRadius: 5,
|
|
208
|
+
label: lineDataProps.lines[0].label,
|
|
209
|
+
data: lineDataProps.lines[0].data,
|
|
210
|
+
borderWidth: 2,
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
type: 'line' as const,
|
|
214
|
+
borderColor: patternsColors.value[1],
|
|
215
|
+
pointStyle: 'circle',
|
|
216
|
+
pointBackgroundColor: '#FFFFFF',
|
|
217
|
+
pointRadius: 5,
|
|
218
|
+
label: lineDataProps.lines[1].label,
|
|
219
|
+
data: lineDataProps.lines[1].data,
|
|
220
|
+
borderWidth: 2,
|
|
221
|
+
},
|
|
222
|
+
],
|
|
114
223
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const chartData = computed(() => {
|
|
122
|
-
return {
|
|
123
|
-
labels: lineDataProps.labels.map((label: string) => label),
|
|
124
|
-
datasets: [
|
|
125
|
-
{
|
|
126
|
-
type: 'line' as const,
|
|
127
|
-
borderColor: '#605F9D',
|
|
128
|
-
pointStyle: 'rectRot',
|
|
129
|
-
pointBackgroundColor: '#FFFFFF',
|
|
130
|
-
pointRadius: 5,
|
|
131
|
-
label: lineDataProps.lines[0].label,
|
|
132
|
-
data: lineDataProps.lines[0].data,
|
|
133
|
-
borderWidth: 2
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
type: 'line' as const,
|
|
137
|
-
borderColor: '#00919F',
|
|
138
|
-
pointStyle: 'circle',
|
|
139
|
-
pointBackgroundColor: '#FFFFFF',
|
|
140
|
-
pointRadius: 5,
|
|
141
|
-
label: lineDataProps.lines[1].label,
|
|
142
|
-
data: lineDataProps.lines[1].data,
|
|
143
|
-
borderWidth: 2
|
|
144
|
-
}
|
|
145
|
-
]
|
|
146
|
-
};
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
function getHtmlLegendPlugin(legendContainer: Ref, selectMode: Ref) {
|
|
150
|
-
return [{
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
function getHtmlLegendPlugin(legendContainer: Ref, selectMode: Ref) {
|
|
227
|
+
return [
|
|
228
|
+
{
|
|
151
229
|
id: 'htmlLegend',
|
|
152
|
-
afterUpdate
|
|
230
|
+
afterUpdate(chart: any) {
|
|
153
231
|
const ul = getOrCreateLegendList(legendContainer, 'column');
|
|
154
232
|
ul.style.display = 'flex';
|
|
155
233
|
ul.style.flexDirection = 'row';
|
|
234
|
+
ul.style.margin = '1.375rem 1.0625rem';
|
|
156
235
|
while (ul.firstChild) {
|
|
157
236
|
ul.firstChild.remove();
|
|
158
237
|
}
|
|
159
238
|
const items = chart.options.plugins.legend.labels.generateLabels(chart);
|
|
160
239
|
items.forEach((item: ChartItem) => {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
240
|
+
const li = createHtmlLegendListElement(
|
|
241
|
+
chart,
|
|
242
|
+
selectMode,
|
|
243
|
+
item.datasetIndex
|
|
244
|
+
);
|
|
245
|
+
let liContent: HTMLElement;
|
|
246
|
+
if (!selectMode.value) {
|
|
247
|
+
liContent = createLegendElementWithSquareArea(item, null);
|
|
248
|
+
} else {
|
|
249
|
+
liContent = createLegendElementWithCheckbox(chart, item);
|
|
250
|
+
}
|
|
251
|
+
liContent.style.boxSizing = 'border-box';
|
|
252
|
+
li.style.marginRight = '10px';
|
|
253
|
+
li.appendChild(liContent);
|
|
254
|
+
li.appendChild(createHtmlLegendItemText(item));
|
|
255
|
+
ul.appendChild(li);
|
|
172
256
|
});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
];
|
|
260
|
+
}
|
|
176
261
|
|
|
177
|
-
|
|
262
|
+
function createLegendElementWithCheckbox(chart: any, item: ChartItem) {
|
|
178
263
|
const liContent = createLegendCheckbox(chart, item);
|
|
179
264
|
liContent.onclick = (e: Event) => {
|
|
180
265
|
switchItemVisibility(chart, item.datasetIndex, selectMode);
|
|
@@ -182,64 +267,70 @@
|
|
|
182
267
|
};
|
|
183
268
|
return liContent;
|
|
184
269
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
270
|
+
|
|
271
|
+
const htmlLegendPlugin = getHtmlLegendPlugin(legendContainer, selectMode);
|
|
272
|
+
|
|
273
|
+
const options = computed(() => ({
|
|
274
|
+
responsive: true,
|
|
275
|
+
maintainAspectRatio: false,
|
|
276
|
+
plugins: {
|
|
277
|
+
legend: {
|
|
278
|
+
display: false,
|
|
279
|
+
},
|
|
280
|
+
tooltip: {
|
|
281
|
+
enabled: false,
|
|
282
|
+
external: function (context: Context) {
|
|
283
|
+
new GenericTooltipService().createTooltip(
|
|
284
|
+
context,
|
|
285
|
+
getTooltipData,
|
|
286
|
+
{
|
|
287
|
+
chartType: TooltipChartType.LINE_CHART,
|
|
288
|
+
firstLineLabel: tooltipFirstLine.value,
|
|
289
|
+
secondLineLabel: tooltipSecondLine.value,
|
|
290
|
+
},
|
|
291
|
+
patternsColors.value,
|
|
292
|
+
patternsOrderedList,
|
|
293
|
+
lineDataProps.disableAccessibility
|
|
294
|
+
);
|
|
194
295
|
},
|
|
195
|
-
tooltip: {
|
|
196
|
-
enabled: false,
|
|
197
|
-
external: function (context: Context) {
|
|
198
|
-
new GenericTooltipService().createTooltip(
|
|
199
|
-
context,
|
|
200
|
-
getTooltipData,
|
|
201
|
-
{
|
|
202
|
-
chartType: TooltipChartType.LINE_CHART,
|
|
203
|
-
firstLineLabel: tooltipFirstLine,
|
|
204
|
-
secondLineLabel: tooltipValueAttribute.value
|
|
205
|
-
}
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
296
|
},
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
297
|
+
},
|
|
298
|
+
scales: {
|
|
299
|
+
x: {
|
|
300
|
+
offset: true,
|
|
301
|
+
},
|
|
302
|
+
y: {
|
|
303
|
+
type: 'linear' as const,
|
|
304
|
+
display: true,
|
|
305
|
+
position: 'left' as const,
|
|
306
|
+
grid: {
|
|
307
|
+
drawOnChartArea: true,
|
|
308
|
+
},
|
|
309
|
+
ticks: {
|
|
310
|
+
callback: function (val: number | string) {
|
|
311
|
+
const unit = lineDataProps.lines[0].unit;
|
|
312
|
+
return `${formatWithThousandsSeprators(val as number)} ${
|
|
313
|
+
unit ? unit : ''
|
|
314
|
+
}`;
|
|
217
315
|
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
flex-direction: column;
|
|
240
|
-
justify-content: center;
|
|
241
|
-
align-items: center;
|
|
242
|
-
margin-bottom: 20px;
|
|
243
|
-
}
|
|
244
|
-
</style>
|
|
245
|
-
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
}));
|
|
320
|
+
</script>
|
|
321
|
+
|
|
322
|
+
<style scoped>
|
|
323
|
+
.container {
|
|
324
|
+
-moz-osx-font-smoothing: grayscale;
|
|
325
|
+
-webkit-font-smoothing: antialiased;
|
|
326
|
+
font-weight: 400;
|
|
327
|
+
font-family: 'Roboto', sans-serif;
|
|
328
|
+
}
|
|
329
|
+
.main {
|
|
330
|
+
display: flex;
|
|
331
|
+
flex-direction: column;
|
|
332
|
+
justify-content: center;
|
|
333
|
+
align-items: center;
|
|
334
|
+
margin-bottom: 20px;
|
|
335
|
+
}
|
|
336
|
+
</style>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// MixedBarLineChart.stories.ts
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
4
|
+
import MixedBarLineChart from './MixedBarLineChart.vue';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Charts/MixedBarLine',
|
|
8
|
+
component: MixedBarLineChart,
|
|
9
|
+
} satisfies Meta<typeof MixedBarLineChart>;
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
|
|
14
|
+
export const Default = {
|
|
15
|
+
args: {
|
|
16
|
+
width: '500px',
|
|
17
|
+
height: '400px',
|
|
18
|
+
tooltipFirstLineLabel: 'content',
|
|
19
|
+
tooltipSecondLineLabel: 'content2',
|
|
20
|
+
disableAccessibility: false,
|
|
21
|
+
newPatternsOrder: [0, 1, 0, 1, 2, 3],
|
|
22
|
+
colourSet: 0,
|
|
23
|
+
barDatasets: [
|
|
24
|
+
{
|
|
25
|
+
type: 'bar',
|
|
26
|
+
label: 'Bar Label 1',
|
|
27
|
+
data: [10, 20, 30, 40],
|
|
28
|
+
borderColor: 'rgb(255, 99, 132)',
|
|
29
|
+
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
lineDatasets: [
|
|
33
|
+
{
|
|
34
|
+
type: 'line',
|
|
35
|
+
label: 'Line Label 1',
|
|
36
|
+
data: [5, 15, 20, 25],
|
|
37
|
+
borderColor: 'rgb(54, 162, 235)',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
labels: ['Label 1', 'Label 2', 'Label 3', 'Label 4'],
|
|
41
|
+
unit: '%',
|
|
42
|
+
},
|
|
43
|
+
} satisfies Story;
|
|
44
|
+
|
|
45
|
+
export const Multiple_Data = {
|
|
46
|
+
args: {
|
|
47
|
+
width: '500px',
|
|
48
|
+
height: '400px',
|
|
49
|
+
tooltipFirstLineLabel: 'content',
|
|
50
|
+
tooltipSecondLineLabel: 'content2',
|
|
51
|
+
disableAccessibility: false,
|
|
52
|
+
newPatternsOrder: [0, 1, 0, 1, 2, 3],
|
|
53
|
+
colourSet: 0,
|
|
54
|
+
barDatasets: [
|
|
55
|
+
{
|
|
56
|
+
type: 'bar',
|
|
57
|
+
label: 'Bar Label 1',
|
|
58
|
+
data: [10, 20, 30, 40],
|
|
59
|
+
borderColor: 'rgb(255, 99, 132)',
|
|
60
|
+
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'bar',
|
|
64
|
+
label: 'Bar Label 2',
|
|
65
|
+
data: [20, 20, 30, 40],
|
|
66
|
+
borderColor: 'rgb(255, 99, 132)',
|
|
67
|
+
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
lineDatasets: [
|
|
71
|
+
{
|
|
72
|
+
type: 'line',
|
|
73
|
+
label: 'Line Label 1',
|
|
74
|
+
data: [5, 15, 20, 25],
|
|
75
|
+
borderColor: 'rgb(54, 162, 235)',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'line',
|
|
79
|
+
label: 'Line Label 2',
|
|
80
|
+
data: [1, 8, 6, 24],
|
|
81
|
+
borderColor: 'rgb(54, 162, 235)',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
labels: ['Label 1', 'Label 2', 'Label 3', 'Label 4'],
|
|
85
|
+
unit: '%',
|
|
86
|
+
},
|
|
87
|
+
} satisfies Story;
|