@primevue/mcp 4.5.5 → 5.0.0-rc.2
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/LICENSE.md +45 -21
- package/README.md +48 -250
- package/data/components.json +47269 -0
- package/data/llms/components/accordion.md +629 -0
- package/data/llms/components/animateonscroll.md +165 -0
- package/data/llms/components/autocomplete.md +995 -0
- package/data/llms/components/avatar.md +264 -0
- package/data/llms/components/badge.md +200 -0
- package/data/llms/components/blockui.md +99 -0
- package/data/llms/components/breadcrumb.md +269 -0
- package/data/llms/components/button.md +902 -0
- package/data/llms/components/card.md +209 -0
- package/data/llms/components/carousel.md +506 -0
- package/data/llms/components/cascadeselect.md +1207 -0
- package/data/llms/components/chart.md +1022 -0
- package/data/llms/components/checkbox.md +401 -0
- package/data/llms/components/chip.md +206 -0
- package/data/llms/components/colorpicker.md +213 -0
- package/data/llms/components/commandmenu.md +660 -0
- package/data/llms/components/compare.md +407 -0
- package/data/llms/components/confirmdialog.md +343 -0
- package/data/llms/components/confirmpopup.md +252 -0
- package/data/llms/components/contextmenu.md +522 -0
- package/data/llms/components/datatable.md +5266 -0
- package/data/llms/components/dataview.md +569 -0
- package/data/llms/components/datepicker.md +964 -0
- package/data/llms/components/deferredcontent.md +96 -0
- package/data/llms/components/dialog.md +702 -0
- package/data/llms/components/divider.md +152 -0
- package/data/llms/components/dock.md +488 -0
- package/data/llms/components/drawer.md +469 -0
- package/data/llms/components/dynamicdialog.md +214 -0
- package/data/llms/components/editor.md +205 -0
- package/data/llms/components/fieldset.md +253 -0
- package/data/llms/components/fileupload.md +459 -0
- package/data/llms/components/floatlabel.md +144 -0
- package/data/llms/components/fluid.md +104 -0
- package/data/llms/components/focustrap.md +59 -0
- package/data/llms/components/forms.md +344 -0
- package/data/llms/components/galleria.md +1119 -0
- package/data/llms/components/gallery.md +1003 -0
- package/data/llms/components/iconfield.md +283 -0
- package/data/llms/components/iftalabel.md +96 -0
- package/data/llms/components/image.md +179 -0
- package/data/llms/components/imagecompare.md +108 -0
- package/data/llms/components/inplace.md +183 -0
- package/data/llms/components/inputcolor.md +869 -0
- package/data/llms/components/inputgroup.md +419 -0
- package/data/llms/components/inputmask.md +345 -0
- package/data/llms/components/inputnumber.md +551 -0
- package/data/llms/components/inputotp.md +345 -0
- package/data/llms/components/inputpassword.md +738 -0
- package/data/llms/components/inputtags.md +432 -0
- package/data/llms/components/inputtext.md +569 -0
- package/data/llms/components/installation.md +1 -0
- package/data/llms/components/keyfilter.md +116 -0
- package/data/llms/components/knob.md +318 -0
- package/data/llms/components/label.md +151 -0
- package/data/llms/components/laravel.md +53 -0
- package/data/llms/components/listbox.md +636 -0
- package/data/llms/components/mask.md +203 -0
- package/data/llms/components/mcp.md +39 -0
- package/data/llms/components/megamenu.md +563 -0
- package/data/llms/components/menu.md +651 -0
- package/data/llms/components/menubar.md +446 -0
- package/data/llms/components/message.md +497 -0
- package/data/llms/components/metergroup.md +281 -0
- package/data/llms/components/multiselect.md +752 -0
- package/data/llms/components/orderlist.md +224 -0
- package/data/llms/components/organizationchart.md +418 -0
- package/data/llms/components/paginator.md +221 -0
- package/data/llms/components/panel.md +321 -0
- package/data/llms/components/panelmenu.md +703 -0
- package/data/llms/components/password.md +657 -0
- package/data/llms/components/picklist.md +286 -0
- package/data/llms/components/popover.md +145 -0
- package/data/llms/components/progressbar.md +242 -0
- package/data/llms/components/progressspinner.md +104 -0
- package/data/llms/components/radiobutton.md +427 -0
- package/data/llms/components/rating.md +312 -0
- package/data/llms/components/ripple.md +91 -0
- package/data/llms/components/scrollarea.md +700 -0
- package/data/llms/components/scrollpanel.md +131 -0
- package/data/llms/components/scrolltop.md +87 -0
- package/data/llms/components/select.md +1251 -0
- package/data/llms/components/selectbutton.md +268 -0
- package/data/llms/components/sidebar.md +2232 -0
- package/data/llms/components/skeleton.md +302 -0
- package/data/llms/components/slider.md +416 -0
- package/data/llms/components/speeddial.md +402 -0
- package/data/llms/components/splitbutton.md +840 -0
- package/data/llms/components/splitter.md +447 -0
- package/data/llms/components/stepper.md +551 -0
- package/data/llms/components/styleclass.md +226 -0
- package/data/llms/components/tabs.md +609 -0
- package/data/llms/components/tag.md +178 -0
- package/data/llms/components/terminal.md +123 -0
- package/data/llms/components/textarea.md +519 -0
- package/data/llms/components/tieredmenu.md +578 -0
- package/data/llms/components/timeline.md +494 -0
- package/data/llms/components/toast.md +472 -0
- package/data/llms/components/togglebutton.md +276 -0
- package/data/llms/components/toggleswitch.md +271 -0
- package/data/llms/components/toolbar.md +140 -0
- package/data/llms/components/tooltip.md +160 -0
- package/data/llms/components/tree.md +1076 -0
- package/data/llms/components/treeselect.md +660 -0
- package/data/llms/components/treetable.md +2493 -0
- package/data/llms/components/virtualscroller.md +265 -0
- package/data/llms/guides/autoimport.md +28 -0
- package/data/llms/guides/cdn.md +72 -0
- package/data/llms/guides/configuration.md +158 -0
- package/data/llms/guides/customicons.md +67 -0
- package/data/llms/guides/guides/accessibility.md +27 -0
- package/data/llms/guides/guides/animations.md +119 -0
- package/data/llms/guides/guides/rtl.md +7 -0
- package/data/llms/guides/icons.md +136 -0
- package/data/llms/guides/installation.md +3 -0
- package/data/llms/guides/laravel.md +66 -0
- package/data/llms/guides/llms.md +15 -0
- package/data/llms/guides/mcp.md +104 -0
- package/data/llms/guides/migration/v4.md +15 -0
- package/data/llms/guides/migration/v5.md +15 -0
- package/data/llms/guides/nuxt.md +141 -0
- package/data/llms/guides/passthrough.md +137 -0
- package/data/llms/guides/primeclt.md +43 -0
- package/data/llms/guides/tailwind.md +151 -0
- package/data/llms/guides/theming/styled.md +497 -0
- package/data/llms/guides/theming/unstyled.md +57 -0
- package/data/llms/guides/uikit.md +3 -0
- package/data/llms/guides/vite.md +90 -0
- package/data/llms/llms-full.txt +54465 -0
- package/data/llms/llms.txt +132 -0
- package/data/llms/pages/accessibility.md +27 -0
- package/data/llms/pages/animations.md +119 -0
- package/data/llms/pages/autoimport.md +28 -0
- package/data/llms/pages/cdn.md +72 -0
- package/data/llms/pages/configuration.md +158 -0
- package/data/llms/pages/contribution.md +31 -0
- package/data/llms/pages/customicons.md +67 -0
- package/data/llms/pages/designer.md +79 -0
- package/data/llms/pages/dynamicimports.md +7 -0
- package/data/llms/pages/forms.md +63 -0
- package/data/llms/pages/guides/accessibility.md +27 -0
- package/data/llms/pages/guides/animations.md +119 -0
- package/data/llms/pages/guides/rtl.md +7 -0
- package/data/llms/pages/icons.md +136 -0
- package/data/llms/pages/installation.md +3 -0
- package/data/llms/pages/introduction.md +23 -0
- package/data/llms/pages/laravel.md +66 -0
- package/data/llms/pages/llms.md +15 -0
- package/data/llms/pages/mcp.md +104 -0
- package/data/llms/pages/migration/v4.md +15 -0
- package/data/llms/pages/migration/v5.md +15 -0
- package/data/llms/pages/nuxt.md +141 -0
- package/data/llms/pages/passthrough.md +137 -0
- package/data/llms/pages/primeclt.md +43 -0
- package/data/llms/pages/rtl.md +7 -0
- package/data/llms/pages/setup.md +3 -0
- package/data/llms/pages/styled.md +497 -0
- package/data/llms/pages/tailwind.md +151 -0
- package/data/llms/pages/theming/styled.md +497 -0
- package/data/llms/pages/theming/unstyled.md +57 -0
- package/data/llms/pages/uikit.md +3 -0
- package/data/llms/pages/unstyled.md +57 -0
- package/data/llms/pages/v4.md +15 -0
- package/data/llms/pages/v5.md +15 -0
- package/data/llms/pages/vite.md +90 -0
- package/data/manifest.json +11117 -0
- package/data/mcp-data.json +55940 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.js +66066 -72541
- package/package.json +10 -12
|
@@ -0,0 +1,1022 @@
|
|
|
1
|
+
# Chart
|
|
2
|
+
|
|
3
|
+
Chart components are based on Chart.js, an open source HTML5 based charting library.
|
|
4
|
+
|
|
5
|
+
## Chart.js
|
|
6
|
+
|
|
7
|
+
Chart component uses Chart.JS underneath so it needs to be installed as a dependency.
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
npm install chart.js
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Basic
|
|
14
|
+
|
|
15
|
+
A chart is configured with 3 properties; type , data and options . Chart type is defined using the type property that accepts pie , doughnut , line , bar , radar and polarArea as a value. The data defines datasets represented with the chart and the options provide numerous customization options to customize the presentation.
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div>
|
|
20
|
+
<Chart type="bar" :data="chartData" :options="chartOptions" />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
25
|
+
import { ref, onMounted } from "vue";
|
|
26
|
+
|
|
27
|
+
onMounted(() => {
|
|
28
|
+
chartData.value = setChartData();
|
|
29
|
+
chartOptions.value = setChartOptions();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const chartData = ref();
|
|
33
|
+
const chartOptions = ref();
|
|
34
|
+
|
|
35
|
+
const setChartData = () => {
|
|
36
|
+
return {
|
|
37
|
+
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
|
|
38
|
+
datasets: [
|
|
39
|
+
{
|
|
40
|
+
label: 'Sales',
|
|
41
|
+
data: [540, 325, 702, 620],
|
|
42
|
+
backgroundColor: ['rgba(249, 115, 22, 0.2)', 'rgba(6, 182, 212, 0.2)', 'rgb(107, 114, 128, 0.2)', 'rgba(139, 92, 246 0.2)'],
|
|
43
|
+
borderColor: ['rgb(249, 115, 22)', 'rgb(6, 182, 212)', 'rgb(107, 114, 128)', 'rgb(139, 92, 246)'],
|
|
44
|
+
borderWidth: 1
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const setChartOptions = () => {
|
|
50
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
51
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
52
|
+
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
|
|
53
|
+
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
plugins: {
|
|
57
|
+
legend: {
|
|
58
|
+
labels: {
|
|
59
|
+
color: textColor
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
scales: {
|
|
64
|
+
x: {
|
|
65
|
+
ticks: {
|
|
66
|
+
color: textColorSecondary
|
|
67
|
+
},
|
|
68
|
+
grid: {
|
|
69
|
+
color: surfaceBorder
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
y: {
|
|
73
|
+
beginAtZero: true,
|
|
74
|
+
ticks: {
|
|
75
|
+
color: textColorSecondary
|
|
76
|
+
},
|
|
77
|
+
grid: {
|
|
78
|
+
color: surfaceBorder
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
<\/script>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Pie
|
|
88
|
+
|
|
89
|
+
A pie chart is a circular statistical graphic which is divided into slices to illustrate numerical proportion.
|
|
90
|
+
|
|
91
|
+
```vue
|
|
92
|
+
<template>
|
|
93
|
+
<div class="flex justify-center">
|
|
94
|
+
<Chart type="pie" :data="chartData" :options="chartOptions" class="w-full md:w-[30rem]" />
|
|
95
|
+
</div>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<script setup>
|
|
99
|
+
import { ref, onMounted } from "vue";
|
|
100
|
+
|
|
101
|
+
onMounted(() => {
|
|
102
|
+
chartData.value = setChartData();
|
|
103
|
+
chartOptions.value = setChartOptions();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const chartData = ref();
|
|
107
|
+
const chartOptions = ref();
|
|
108
|
+
|
|
109
|
+
const setChartData = () => {
|
|
110
|
+
const documentStyle = getComputedStyle(document.body);
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
labels: ['A', 'B', 'C'],
|
|
114
|
+
datasets: [
|
|
115
|
+
{
|
|
116
|
+
data: [540, 325, 702],
|
|
117
|
+
backgroundColor: [documentStyle.getPropertyValue('--p-cyan-500'), documentStyle.getPropertyValue('--p-orange-500'), documentStyle.getPropertyValue('--p-gray-500')],
|
|
118
|
+
hoverBackgroundColor: [documentStyle.getPropertyValue('--p-cyan-400'), documentStyle.getPropertyValue('--p-orange-400'), documentStyle.getPropertyValue('--p-gray-400')]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const setChartOptions = () => {
|
|
125
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
126
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
plugins: {
|
|
130
|
+
legend: {
|
|
131
|
+
labels: {
|
|
132
|
+
usePointStyle: true,
|
|
133
|
+
color: textColor
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
<\/script>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Doughnut
|
|
143
|
+
|
|
144
|
+
A doughnut chart is a variant of the pie chart, with a blank center allowing for additional information about the data as a whole to be included.
|
|
145
|
+
|
|
146
|
+
```vue
|
|
147
|
+
<template>
|
|
148
|
+
<div class="flex justify-center">
|
|
149
|
+
<Chart type="doughnut" :data="chartData" :options="chartOptions" class="w-full md:w-[30rem]" />
|
|
150
|
+
</div>
|
|
151
|
+
</template>
|
|
152
|
+
|
|
153
|
+
<script setup>
|
|
154
|
+
import { ref, onMounted } from "vue";
|
|
155
|
+
|
|
156
|
+
onMounted(() => {
|
|
157
|
+
chartData.value = setChartData();
|
|
158
|
+
chartOptions.value = setChartOptions();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const chartData = ref();
|
|
162
|
+
const chartOptions = ref(null);
|
|
163
|
+
|
|
164
|
+
const setChartData = () => {
|
|
165
|
+
const documentStyle = getComputedStyle(document.body);
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
labels: ['A', 'B', 'C'],
|
|
169
|
+
datasets: [
|
|
170
|
+
{
|
|
171
|
+
data: [540, 325, 702],
|
|
172
|
+
backgroundColor: [documentStyle.getPropertyValue('--p-cyan-500'), documentStyle.getPropertyValue('--p-orange-500'), documentStyle.getPropertyValue('--p-gray-500')],
|
|
173
|
+
hoverBackgroundColor: [documentStyle.getPropertyValue('--p-cyan-400'), documentStyle.getPropertyValue('--p-orange-400'), documentStyle.getPropertyValue('--p-gray-400')]
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const setChartOptions = () => {
|
|
180
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
181
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
plugins: {
|
|
185
|
+
legend: {
|
|
186
|
+
labels: {
|
|
187
|
+
cutout: '60%',
|
|
188
|
+
color: textColor
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
<\/script>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Vertical Bar
|
|
198
|
+
|
|
199
|
+
A bar chart or bar graph is a chart that presents grouped data with rectangular bars with lengths proportional to the values that they represent.
|
|
200
|
+
|
|
201
|
+
```vue
|
|
202
|
+
<template>
|
|
203
|
+
<div>
|
|
204
|
+
<Chart type="bar" :data="chartData" :options="chartOptions" class="h-[30rem]" />
|
|
205
|
+
</div>
|
|
206
|
+
</template>
|
|
207
|
+
|
|
208
|
+
<script setup>
|
|
209
|
+
import { ref, onMounted } from "vue";
|
|
210
|
+
|
|
211
|
+
onMounted(() => {
|
|
212
|
+
chartData.value = setChartData();
|
|
213
|
+
chartOptions.value = setChartOptions();
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
const chartData = ref();
|
|
217
|
+
const chartOptions = ref();
|
|
218
|
+
|
|
219
|
+
const setChartData = () => {
|
|
220
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
224
|
+
datasets: [
|
|
225
|
+
{
|
|
226
|
+
label: 'My First dataset',
|
|
227
|
+
backgroundColor: documentStyle.getPropertyValue('--p-cyan-500'),
|
|
228
|
+
borderColor: documentStyle.getPropertyValue('--p-cyan-500'),
|
|
229
|
+
data: [65, 59, 80, 81, 56, 55, 40]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
label: 'My Second dataset',
|
|
233
|
+
backgroundColor: documentStyle.getPropertyValue('--p-gray-500'),
|
|
234
|
+
borderColor: documentStyle.getPropertyValue('--p-gray-500'),
|
|
235
|
+
data: [28, 48, 40, 19, 86, 27, 90]
|
|
236
|
+
}
|
|
237
|
+
]
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
const setChartOptions = () => {
|
|
241
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
242
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
243
|
+
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
|
|
244
|
+
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
maintainAspectRatio: false,
|
|
248
|
+
aspectRatio: 0.8,
|
|
249
|
+
plugins: {
|
|
250
|
+
legend: {
|
|
251
|
+
labels: {
|
|
252
|
+
color: textColor
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
scales: {
|
|
257
|
+
x: {
|
|
258
|
+
ticks: {
|
|
259
|
+
color: textColorSecondary,
|
|
260
|
+
font: {
|
|
261
|
+
weight: 500
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
grid: {
|
|
265
|
+
display: false,
|
|
266
|
+
drawBorder: false
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
y: {
|
|
270
|
+
ticks: {
|
|
271
|
+
color: textColorSecondary
|
|
272
|
+
},
|
|
273
|
+
grid: {
|
|
274
|
+
color: surfaceBorder,
|
|
275
|
+
drawBorder: false
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
<\/script>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Horizontal Bar
|
|
285
|
+
|
|
286
|
+
A bar chart is rendered horizontally when indexAxis option is set as y .
|
|
287
|
+
|
|
288
|
+
```vue
|
|
289
|
+
<template>
|
|
290
|
+
<div>
|
|
291
|
+
<Chart type="bar" :data="chartData" :options="chartOptions" class="h-[30rem]" />
|
|
292
|
+
</div>
|
|
293
|
+
</template>
|
|
294
|
+
|
|
295
|
+
<script setup>
|
|
296
|
+
import { ref, onMounted } from "vue";
|
|
297
|
+
|
|
298
|
+
onMounted(() => {
|
|
299
|
+
chartData.value = setChartData();
|
|
300
|
+
chartOptions.value = setChartOptions();
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
const chartData = ref();
|
|
304
|
+
const chartOptions = ref();
|
|
305
|
+
|
|
306
|
+
const setChartData = () => {
|
|
307
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
311
|
+
datasets: [
|
|
312
|
+
{
|
|
313
|
+
label: 'My First dataset',
|
|
314
|
+
backgroundColor: documentStyle.getPropertyValue('--p-cyan-500'),
|
|
315
|
+
borderColor: documentStyle.getPropertyValue('--p-cyan-500'),
|
|
316
|
+
data: [65, 59, 80, 81, 56, 55, 40]
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
label: 'My Second dataset',
|
|
320
|
+
backgroundColor: documentStyle.getPropertyValue('--p-gray-500'),
|
|
321
|
+
borderColor: documentStyle.getPropertyValue('--p-gray-500'),
|
|
322
|
+
data: [28, 48, 40, 19, 86, 27, 90]
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
const setChartOptions = () => {
|
|
328
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
329
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
330
|
+
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
|
|
331
|
+
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
|
|
332
|
+
|
|
333
|
+
return {
|
|
334
|
+
indexAxis: 'y',
|
|
335
|
+
maintainAspectRatio: false,
|
|
336
|
+
aspectRatio: 0.8,
|
|
337
|
+
plugins: {
|
|
338
|
+
legend: {
|
|
339
|
+
labels: {
|
|
340
|
+
color: textColor
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
scales: {
|
|
345
|
+
x: {
|
|
346
|
+
ticks: {
|
|
347
|
+
color: textColorSecondary,
|
|
348
|
+
font: {
|
|
349
|
+
weight: 500
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
grid: {
|
|
353
|
+
display: false,
|
|
354
|
+
drawBorder: false
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
y: {
|
|
358
|
+
ticks: {
|
|
359
|
+
color: textColorSecondary
|
|
360
|
+
},
|
|
361
|
+
grid: {
|
|
362
|
+
color: surfaceBorder,
|
|
363
|
+
drawBorder: false
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
<\/script>
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Stacked Bar
|
|
373
|
+
|
|
374
|
+
Bars can be stacked on top of each other when stacked option of a scale is enabled.
|
|
375
|
+
|
|
376
|
+
```vue
|
|
377
|
+
<template>
|
|
378
|
+
<div>
|
|
379
|
+
<Chart type="bar" :data="chartData" :options="chartOptions" class="h-[30rem]" />
|
|
380
|
+
</div>
|
|
381
|
+
</template>
|
|
382
|
+
|
|
383
|
+
<script setup>
|
|
384
|
+
import { ref, onMounted } from "vue";
|
|
385
|
+
|
|
386
|
+
onMounted(() => {
|
|
387
|
+
chartData.value = setChartData();
|
|
388
|
+
chartOptions.value = setChartOptions();
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
const chartData = ref();
|
|
392
|
+
const chartOptions = ref();
|
|
393
|
+
|
|
394
|
+
const setChartData = () => {
|
|
395
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
396
|
+
|
|
397
|
+
return {
|
|
398
|
+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
399
|
+
datasets: [
|
|
400
|
+
{
|
|
401
|
+
type: 'bar',
|
|
402
|
+
label: 'Dataset 1',
|
|
403
|
+
backgroundColor: documentStyle.getPropertyValue('--p-cyan-500'),
|
|
404
|
+
data: [50, 25, 12, 48, 90, 76, 42]
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
type: 'bar',
|
|
408
|
+
label: 'Dataset 2',
|
|
409
|
+
backgroundColor: documentStyle.getPropertyValue('--p-gray-500'),
|
|
410
|
+
data: [21, 84, 24, 75, 37, 65, 34]
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
type: 'bar',
|
|
414
|
+
label: 'Dataset 3',
|
|
415
|
+
backgroundColor: documentStyle.getPropertyValue('--p-orange-500'),
|
|
416
|
+
data: [41, 52, 24, 74, 23, 21, 32]
|
|
417
|
+
}
|
|
418
|
+
]
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
const setChartOptions = () => {
|
|
422
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
423
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
424
|
+
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
|
|
425
|
+
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
|
|
426
|
+
|
|
427
|
+
return {
|
|
428
|
+
maintainAspectRatio: false,
|
|
429
|
+
aspectRatio: 0.8,
|
|
430
|
+
plugins: {
|
|
431
|
+
tooltips: {
|
|
432
|
+
mode: 'index',
|
|
433
|
+
intersect: false
|
|
434
|
+
},
|
|
435
|
+
legend: {
|
|
436
|
+
labels: {
|
|
437
|
+
color: textColor
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
scales: {
|
|
442
|
+
x: {
|
|
443
|
+
stacked: true,
|
|
444
|
+
ticks: {
|
|
445
|
+
color: textColorSecondary
|
|
446
|
+
},
|
|
447
|
+
grid: {
|
|
448
|
+
color: surfaceBorder
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
y: {
|
|
452
|
+
stacked: true,
|
|
453
|
+
ticks: {
|
|
454
|
+
color: textColorSecondary
|
|
455
|
+
},
|
|
456
|
+
grid: {
|
|
457
|
+
color: surfaceBorder
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
<\/script>
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
## Line
|
|
467
|
+
|
|
468
|
+
A line chart or line graph is a type of chart which displays information as a series of data points called 'markers' connected by straight line segments.
|
|
469
|
+
|
|
470
|
+
```vue
|
|
471
|
+
<template>
|
|
472
|
+
<div>
|
|
473
|
+
<Chart type="line" :data="chartData" :options="chartOptions" class="h-[30rem]" />
|
|
474
|
+
</div>
|
|
475
|
+
</template>
|
|
476
|
+
|
|
477
|
+
<script setup>
|
|
478
|
+
import { ref, onMounted } from "vue";
|
|
479
|
+
|
|
480
|
+
onMounted(() => {
|
|
481
|
+
chartData.value = setChartData();
|
|
482
|
+
chartOptions.value = setChartOptions();
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
const chartData = ref();
|
|
486
|
+
const chartOptions = ref();
|
|
487
|
+
|
|
488
|
+
const setChartData = () => {
|
|
489
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
490
|
+
|
|
491
|
+
return {
|
|
492
|
+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
493
|
+
datasets: [
|
|
494
|
+
{
|
|
495
|
+
label: 'First Dataset',
|
|
496
|
+
data: [65, 59, 80, 81, 56, 55, 40],
|
|
497
|
+
fill: false,
|
|
498
|
+
borderColor: documentStyle.getPropertyValue('--p-cyan-500'),
|
|
499
|
+
tension: 0.4
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
label: 'Second Dataset',
|
|
503
|
+
data: [28, 48, 40, 19, 86, 27, 90],
|
|
504
|
+
fill: false,
|
|
505
|
+
borderColor: documentStyle.getPropertyValue('--p-gray-500'),
|
|
506
|
+
tension: 0.4
|
|
507
|
+
}
|
|
508
|
+
]
|
|
509
|
+
};
|
|
510
|
+
};
|
|
511
|
+
const setChartOptions = () => {
|
|
512
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
513
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
514
|
+
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
|
|
515
|
+
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
|
|
516
|
+
|
|
517
|
+
return {
|
|
518
|
+
maintainAspectRatio: false,
|
|
519
|
+
aspectRatio: 0.6,
|
|
520
|
+
plugins: {
|
|
521
|
+
legend: {
|
|
522
|
+
labels: {
|
|
523
|
+
color: textColor
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
scales: {
|
|
528
|
+
x: {
|
|
529
|
+
ticks: {
|
|
530
|
+
color: textColorSecondary
|
|
531
|
+
},
|
|
532
|
+
grid: {
|
|
533
|
+
color: surfaceBorder
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
y: {
|
|
537
|
+
ticks: {
|
|
538
|
+
color: textColorSecondary
|
|
539
|
+
},
|
|
540
|
+
grid: {
|
|
541
|
+
color: surfaceBorder
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
<\/script>
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
## Multi Axis
|
|
551
|
+
|
|
552
|
+
Multiple axes can be added using the scales option.
|
|
553
|
+
|
|
554
|
+
```vue
|
|
555
|
+
<template>
|
|
556
|
+
<div>
|
|
557
|
+
<Chart type="line" :data="chartData" :options="chartOptions" class="h-[30rem]" />
|
|
558
|
+
</div>
|
|
559
|
+
</template>
|
|
560
|
+
|
|
561
|
+
<script setup>
|
|
562
|
+
import { ref, onMounted } from "vue";
|
|
563
|
+
|
|
564
|
+
onMounted(() => {
|
|
565
|
+
chartData.value = setChartData();
|
|
566
|
+
chartOptions.value = setChartOptions();
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
const chartData = ref();
|
|
570
|
+
const chartOptions = ref();
|
|
571
|
+
|
|
572
|
+
const setChartData = () => {
|
|
573
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
574
|
+
|
|
575
|
+
return {
|
|
576
|
+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
577
|
+
datasets: [
|
|
578
|
+
{
|
|
579
|
+
label: 'Dataset 1',
|
|
580
|
+
fill: false,
|
|
581
|
+
borderColor: documentStyle.getPropertyValue('--p-cyan-500'),
|
|
582
|
+
yAxisID: 'y',
|
|
583
|
+
tension: 0.4,
|
|
584
|
+
data: [65, 59, 80, 81, 56, 55, 10]
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
label: 'Dataset 2',
|
|
588
|
+
fill: false,
|
|
589
|
+
borderColor: documentStyle.getPropertyValue('--p-gray-500'),
|
|
590
|
+
yAxisID: 'y1',
|
|
591
|
+
tension: 0.4,
|
|
592
|
+
data: [28, 48, 40, 19, 86, 27, 90]
|
|
593
|
+
}
|
|
594
|
+
]
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
const setChartOptions = () => {
|
|
598
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
599
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
600
|
+
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
|
|
601
|
+
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
|
|
602
|
+
|
|
603
|
+
return {
|
|
604
|
+
stacked: false,
|
|
605
|
+
maintainAspectRatio: false,
|
|
606
|
+
aspectRatio: 0.6,
|
|
607
|
+
plugins: {
|
|
608
|
+
legend: {
|
|
609
|
+
labels: {
|
|
610
|
+
color: textColor
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
},
|
|
614
|
+
scales: {
|
|
615
|
+
x: {
|
|
616
|
+
ticks: {
|
|
617
|
+
color: textColorSecondary
|
|
618
|
+
},
|
|
619
|
+
grid: {
|
|
620
|
+
color: surfaceBorder
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
y: {
|
|
624
|
+
type: 'linear',
|
|
625
|
+
display: true,
|
|
626
|
+
position: 'left',
|
|
627
|
+
ticks: {
|
|
628
|
+
color: textColorSecondary
|
|
629
|
+
},
|
|
630
|
+
grid: {
|
|
631
|
+
color: surfaceBorder
|
|
632
|
+
}
|
|
633
|
+
},
|
|
634
|
+
y1: {
|
|
635
|
+
type: 'linear',
|
|
636
|
+
display: true,
|
|
637
|
+
position: 'right',
|
|
638
|
+
ticks: {
|
|
639
|
+
color: textColorSecondary
|
|
640
|
+
},
|
|
641
|
+
grid: {
|
|
642
|
+
drawOnChartArea: false,
|
|
643
|
+
color: surfaceBorder
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
<\/script>
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
## Line Styles
|
|
653
|
+
|
|
654
|
+
Various styles of a line series can be customized to display customizations like an area chart.
|
|
655
|
+
|
|
656
|
+
```vue
|
|
657
|
+
<template>
|
|
658
|
+
<div>
|
|
659
|
+
<Chart type="line" :data="chartData" :options="chartOptions" class="h-[30rem]" />
|
|
660
|
+
</div>
|
|
661
|
+
</template>
|
|
662
|
+
|
|
663
|
+
<script setup>
|
|
664
|
+
import { ref, onMounted } from "vue";
|
|
665
|
+
|
|
666
|
+
onMounted(() => {
|
|
667
|
+
chartData.value = setChartData();
|
|
668
|
+
chartOptions.value = setChartOptions();
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
const chartData = ref();
|
|
672
|
+
const chartOptions = ref();
|
|
673
|
+
|
|
674
|
+
const setChartData = () => {
|
|
675
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
676
|
+
|
|
677
|
+
return {
|
|
678
|
+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
679
|
+
datasets: [
|
|
680
|
+
{
|
|
681
|
+
label: 'First Dataset',
|
|
682
|
+
data: [65, 59, 80, 81, 56, 55, 40],
|
|
683
|
+
fill: false,
|
|
684
|
+
tension: 0.4,
|
|
685
|
+
borderColor: documentStyle.getPropertyValue('--p-cyan-500')
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
label: 'Second Dataset',
|
|
689
|
+
data: [28, 48, 40, 19, 86, 27, 90],
|
|
690
|
+
fill: false,
|
|
691
|
+
borderDash: [5, 5],
|
|
692
|
+
tension: 0.4,
|
|
693
|
+
borderColor: documentStyle.getPropertyValue('--p-orange-500')
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
label: 'Third Dataset',
|
|
697
|
+
data: [12, 51, 62, 33, 21, 62, 45],
|
|
698
|
+
fill: true,
|
|
699
|
+
borderColor: documentStyle.getPropertyValue('--p-gray-500'),
|
|
700
|
+
tension: 0.4,
|
|
701
|
+
backgroundColor: 'rgba(107, 114, 128, 0.2)'
|
|
702
|
+
}
|
|
703
|
+
]
|
|
704
|
+
};
|
|
705
|
+
};
|
|
706
|
+
const setChartOptions = () => {
|
|
707
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
708
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
709
|
+
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
|
|
710
|
+
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
|
|
711
|
+
|
|
712
|
+
return {
|
|
713
|
+
maintainAspectRatio: false,
|
|
714
|
+
aspectRatio: 0.6,
|
|
715
|
+
plugins: {
|
|
716
|
+
legend: {
|
|
717
|
+
labels: {
|
|
718
|
+
color: textColor
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
scales: {
|
|
723
|
+
x: {
|
|
724
|
+
ticks: {
|
|
725
|
+
color: textColorSecondary
|
|
726
|
+
},
|
|
727
|
+
grid: {
|
|
728
|
+
color: surfaceBorder
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
y: {
|
|
732
|
+
ticks: {
|
|
733
|
+
color: textColorSecondary
|
|
734
|
+
},
|
|
735
|
+
grid: {
|
|
736
|
+
color: surfaceBorder
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
<\/script>
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
## Polar Area
|
|
746
|
+
|
|
747
|
+
Polar area charts are similar to pie charts, but each segment has the same angle - the radius of the segment differs depending on the value.
|
|
748
|
+
|
|
749
|
+
```vue
|
|
750
|
+
<template>
|
|
751
|
+
<div class="flex justify-center">
|
|
752
|
+
<Chart type="polarArea" :data="chartData" :options="chartOptions" class="w-full md:w-[30rem]" />
|
|
753
|
+
</div>
|
|
754
|
+
</template>
|
|
755
|
+
|
|
756
|
+
<script setup>
|
|
757
|
+
import { ref, onMounted } from "vue";
|
|
758
|
+
|
|
759
|
+
onMounted(() => {
|
|
760
|
+
chartData.value = setChartData();
|
|
761
|
+
chartOptions.value = setChartOptions();
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
const chartData = ref();
|
|
765
|
+
const chartOptions = ref();
|
|
766
|
+
|
|
767
|
+
const setChartData = () => {
|
|
768
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
769
|
+
|
|
770
|
+
return {
|
|
771
|
+
datasets: [
|
|
772
|
+
{
|
|
773
|
+
data: [11, 16, 7, 3, 14],
|
|
774
|
+
backgroundColor: [
|
|
775
|
+
documentStyle.getPropertyValue('--p-pink-500'),
|
|
776
|
+
documentStyle.getPropertyValue('--p-gray-500'),
|
|
777
|
+
documentStyle.getPropertyValue('--p-orange-500'),
|
|
778
|
+
documentStyle.getPropertyValue('--p-purple-500'),
|
|
779
|
+
documentStyle.getPropertyValue('--p-cyan-500')
|
|
780
|
+
],
|
|
781
|
+
label: 'My dataset'
|
|
782
|
+
}
|
|
783
|
+
],
|
|
784
|
+
labels: ['Pink', 'Gray', 'Orange', 'Purple', 'Cyan']
|
|
785
|
+
};
|
|
786
|
+
};
|
|
787
|
+
const setChartOptions = () => {
|
|
788
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
789
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
790
|
+
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
|
|
791
|
+
|
|
792
|
+
return {
|
|
793
|
+
plugins: {
|
|
794
|
+
legend: {
|
|
795
|
+
labels: {
|
|
796
|
+
color: textColor
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
scales: {
|
|
801
|
+
r: {
|
|
802
|
+
grid: {
|
|
803
|
+
color: surfaceBorder
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
<\/script>
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
## Radar
|
|
813
|
+
|
|
814
|
+
A radar chart is a graphical method of displaying multivariate data in the form of a two-dimensional chart of three or more quantitative variables represented on axes starting from the same point.
|
|
815
|
+
|
|
816
|
+
```vue
|
|
817
|
+
<template>
|
|
818
|
+
<div class="flex justify-center">
|
|
819
|
+
<Chart type="radar" :data="chartData" :options="chartOptions" class="w-full md:w-[30rem]" />
|
|
820
|
+
</div>
|
|
821
|
+
</template>
|
|
822
|
+
|
|
823
|
+
<script setup>
|
|
824
|
+
import { ref, onMounted } from "vue";
|
|
825
|
+
|
|
826
|
+
onMounted(() => {
|
|
827
|
+
chartData.value = setChartData();
|
|
828
|
+
chartOptions.value = setChartOptions();
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
const chartData = ref();
|
|
832
|
+
const chartOptions = ref();
|
|
833
|
+
|
|
834
|
+
const setChartData = () => {
|
|
835
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
836
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
837
|
+
|
|
838
|
+
return {
|
|
839
|
+
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
|
|
840
|
+
datasets: [
|
|
841
|
+
{
|
|
842
|
+
label: 'My First dataset',
|
|
843
|
+
borderColor: documentStyle.getPropertyValue('--p-gray-400'),
|
|
844
|
+
pointBackgroundColor: documentStyle.getPropertyValue('--p-gray-400'),
|
|
845
|
+
pointBorderColor: documentStyle.getPropertyValue('--p-gray-400'),
|
|
846
|
+
pointHoverBackgroundColor: textColor,
|
|
847
|
+
pointHoverBorderColor: documentStyle.getPropertyValue('--p-gray-400'),
|
|
848
|
+
data: [65, 59, 90, 81, 56, 55, 40]
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
label: 'My Second dataset',
|
|
852
|
+
borderColor: documentStyle.getPropertyValue('--p-pink-400'),
|
|
853
|
+
pointBackgroundColor: documentStyle.getPropertyValue('--p-pink-400'),
|
|
854
|
+
pointBorderColor: documentStyle.getPropertyValue('--p-pink-400'),
|
|
855
|
+
pointHoverBackgroundColor: textColor,
|
|
856
|
+
pointHoverBorderColor: documentStyle.getPropertyValue('--p-pink-400'),
|
|
857
|
+
data: [28, 48, 40, 19, 96, 27, 100]
|
|
858
|
+
}
|
|
859
|
+
]
|
|
860
|
+
};
|
|
861
|
+
};
|
|
862
|
+
const setChartOptions = () => {
|
|
863
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
864
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
865
|
+
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
|
|
866
|
+
|
|
867
|
+
return {
|
|
868
|
+
plugins: {
|
|
869
|
+
legend: {
|
|
870
|
+
labels: {
|
|
871
|
+
color: textColor
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
},
|
|
875
|
+
scales: {
|
|
876
|
+
r: {
|
|
877
|
+
grid: {
|
|
878
|
+
color: textColorSecondary
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
<\/script>
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
## Combo
|
|
888
|
+
|
|
889
|
+
Different chart types can be combined in the same graph usign the type option of a dataset.
|
|
890
|
+
|
|
891
|
+
```vue
|
|
892
|
+
<template>
|
|
893
|
+
<div>
|
|
894
|
+
<Chart type="bar" :data="chartData" :options="chartOptions" class="h-[30rem]" />
|
|
895
|
+
</div>
|
|
896
|
+
</template>
|
|
897
|
+
|
|
898
|
+
<script setup>
|
|
899
|
+
import { ref, onMounted } from "vue";
|
|
900
|
+
|
|
901
|
+
onMounted(() => {
|
|
902
|
+
chartData.value = setChartData();
|
|
903
|
+
chartOptions.value = setChartOptions();
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
const chartData = ref();
|
|
907
|
+
const chartOptions = ref();
|
|
908
|
+
|
|
909
|
+
const setChartData = () => {
|
|
910
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
911
|
+
|
|
912
|
+
return {
|
|
913
|
+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
914
|
+
datasets: [
|
|
915
|
+
{
|
|
916
|
+
type: 'line',
|
|
917
|
+
label: 'Dataset 1',
|
|
918
|
+
borderColor: documentStyle.getPropertyValue('--p-orange-500'),
|
|
919
|
+
borderWidth: 2,
|
|
920
|
+
fill: false,
|
|
921
|
+
tension: 0.4,
|
|
922
|
+
data: [50, 25, 12, 48, 56, 76, 42]
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
type: 'bar',
|
|
926
|
+
label: 'Dataset 2',
|
|
927
|
+
backgroundColor: documentStyle.getPropertyValue('--p-gray-500'),
|
|
928
|
+
data: [21, 84, 24, 75, 37, 65, 34],
|
|
929
|
+
borderColor: 'white',
|
|
930
|
+
borderWidth: 2
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
type: 'bar',
|
|
934
|
+
label: 'Dataset 3',
|
|
935
|
+
backgroundColor: documentStyle.getPropertyValue('--p-cyan-500'),
|
|
936
|
+
data: [41, 52, 24, 74, 23, 21, 32]
|
|
937
|
+
}
|
|
938
|
+
]
|
|
939
|
+
};
|
|
940
|
+
};
|
|
941
|
+
const setChartOptions = () => {
|
|
942
|
+
const documentStyle = getComputedStyle(document.documentElement);
|
|
943
|
+
const textColor = documentStyle.getPropertyValue('--p-text-color');
|
|
944
|
+
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
|
|
945
|
+
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
|
|
946
|
+
|
|
947
|
+
return {
|
|
948
|
+
maintainAspectRatio: false,
|
|
949
|
+
aspectRatio: 0.6,
|
|
950
|
+
plugins: {
|
|
951
|
+
legend: {
|
|
952
|
+
labels: {
|
|
953
|
+
color: textColor
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
},
|
|
957
|
+
scales: {
|
|
958
|
+
x: {
|
|
959
|
+
ticks: {
|
|
960
|
+
color: textColorSecondary
|
|
961
|
+
},
|
|
962
|
+
grid: {
|
|
963
|
+
color: surfaceBorder
|
|
964
|
+
}
|
|
965
|
+
},
|
|
966
|
+
y: {
|
|
967
|
+
ticks: {
|
|
968
|
+
color: textColorSecondary
|
|
969
|
+
},
|
|
970
|
+
grid: {
|
|
971
|
+
color: surfaceBorder
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
<\/script>
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
## Accessibility
|
|
981
|
+
|
|
982
|
+
Screen Reader Chart components internally use canvas element, refer to the Chart.js accessibility guide for more information. The canvas element can be customized with canvasProps property to define aria roles and properties, in addition any content inside the component is directly passed as a child of the canvas to be able to provide fallback content like a table.
|
|
983
|
+
|
|
984
|
+
```vue
|
|
985
|
+
<template>
|
|
986
|
+
<Chart type="line" :data="data" :canvasProps="{'role': 'img', 'aria-label': 'Data'}" />
|
|
987
|
+
</template>
|
|
988
|
+
```
|
|
989
|
+
|
|
990
|
+
## Chart API
|
|
991
|
+
|
|
992
|
+
### Props
|
|
993
|
+
|
|
994
|
+
| Name |Type |Default |Description |
|
|
995
|
+
| --- | --- | --- | --- |
|
|
996
|
+
| type | string | - | Type of the chart. |
|
|
997
|
+
| data | object | - | Data to display. |
|
|
998
|
+
| options | object | - | Options to customize the chart. |
|
|
999
|
+
| plugins | any[] | - | Used to custom plugins of the chart. |
|
|
1000
|
+
| width | number | 300 | Width of the chart in non-responsive mode. |
|
|
1001
|
+
| height | number | 150 | Height of the chart in non-responsive mode. |
|
|
1002
|
+
| canvasProps | CanvasHTMLAttributes | - | Used to pass all properties of the CanvasHTMLAttributes to canvas element inside the component. |
|
|
1003
|
+
| dt | any | - | It generates scoped CSS variables using design tokens for the component. |
|
|
1004
|
+
| pt | PassThrough<ChartPassThroughOptions> | - | Used to pass attributes to DOM elements inside the component. |
|
|
1005
|
+
| ptOptions | any | - | Used to configure passthrough(pt) options of the component. |
|
|
1006
|
+
| unstyled | boolean | false | When enabled, it removes component related styles in the core. |
|
|
1007
|
+
|
|
1008
|
+
### Pass Through Options
|
|
1009
|
+
|
|
1010
|
+
| Name |Type |Description |
|
|
1011
|
+
| --- | --- | --- |
|
|
1012
|
+
| root | ChartPassThroughOptionType | Used to pass attributes to the root's DOM element. |
|
|
1013
|
+
| canvas | ChartPassThroughOptionType | Used to pass attributes to the canvas's DOM element. |
|
|
1014
|
+
| hooks | any | Used to manage all lifecycle hooks. |
|
|
1015
|
+
|
|
1016
|
+
### Theming
|
|
1017
|
+
|
|
1018
|
+
### CSS Classes
|
|
1019
|
+
|
|
1020
|
+
| Class |Description |
|
|
1021
|
+
| --- | --- |
|
|
1022
|
+
| p-chart | Class name of the root element |
|