Skip to content
Merged

Trunk #219

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,23 @@ const merged = mergeConfigs({
});
```

## Multiline data labels

Some components will display labels on mutliple lines when the provided text contains a line break. (example: "I contain\na line break").
Below is a table of the places where such line breaks can be used:

| Component | Label displayed | Where to use line breaks |
| --------------------------- | -------------------- | ------------------------------------------------------ |
| VueUiXy | Time labels (x axis) | config.chart.grid.labels.xAxisLabels.values |
| VueUiDonutEvolution | Time labels (x axis) | config.style.chart.layout.grid.xAxis.dataLabels.values |
| VueUiHistoryPlot | Plot labels | dataset names |
| VueUiParallelCoordinatePlot | Axis labels | config.style.chart.yAxis.labels.axisNames |
| VueUiQuadrant | Plot labels | dataset names |
| VueUiQuickChart | Time labels (x axis) | config.xyPeriods |
| VueUiRidgeline | Time labels (x axis) | config.style.chart.xAxis.labels.values |
| VueUiStackbar | Time labels (x axis) | config.style.chart.grid.x.timeLabels.values |
| VueUiStripPlot | x axis labels | dataset names |

## PDF generation

This package requires jspdf as a peer dependency. Please install it in your project if you intend on using the PDF printing feature.
2 changes: 1 addition & 1 deletion TestingArena/ArenaVueUiHistoryPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const dataset = ref([
{
name: 'Series 1',
values: [
{ x: 2, y: 0, label: 'T1'},
{ x: 2, y: 0, label: 'T1 with some sort\nof long name'},
{ x: 18, y: 0.2, label: 'T2'},
{ x: 21, y: 0.8, label: 'T3'},
{ x: 19, y: 1.2, label: 'T4'},
Expand Down
2 changes: 1 addition & 1 deletion TestingArena/ArenaVueUiParallelCoordinatePlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const config = computed(() => {
...c.style.chart.yAxis.labels,
roundings: [0, 0, 0, 1],
suffixes: ['$', '€', '£', '%'],
axisNames: ['Axis 1', 'Axis 2', 'Axis 3', ''],
axisNames: ['Axis 1 with some\nsort of long name', 'Axis 2', 'Axis 3', ''],
formatters: [
({value, config}) => {
return `f0 | ${value}`
Expand Down
2 changes: 1 addition & 1 deletion TestingArena/ArenaVueUiQuadrant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function makeDs(n,m) {
const arr = [];
for(let i = 0; i < n; i += 1) {
arr.push({
name: 'Serie',
name: 'Serie with a name\n that is way too long',
x: Math.random() > 0.5 ? Math.random()*m : -Math.random()*m,
y: Math.random() > 0.5 ? Math.random()*m : -Math.random()*m,
})
Expand Down
7 changes: 5 additions & 2 deletions TestingArena/ArenaVueUiQuickChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,12 @@ const config = computed(() => {
},
theme: currentTheme.value,
customPalette: ['#6376DD', "#DD3322", "#66DDAA"],
xyPeriods: monthValues.value,
// xyPeriods: monthValues.value,
xyPeriods: new Array(100).fill(0).map((el,i) => {
return `Some long label\nfor index ${i}`
}),
datetimeFormatter: {
enable: true
enable: false
}
}
})
Expand Down
7 changes: 5 additions & 2 deletions TestingArena/ArenaVueUiRidgeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ const config = computed(() => {
...c.style.chart.xAxis,
labels: {
...c.style.chart.xAxis.labels,
values: monthValues.value,
// values: monthValues.value,
values: new Array(12).fill(0).map((el,i) => {
return `Some long label\n with index ${i}`
}),
datetimeFormatter: {
enable: true,
enable: false,
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions TestingArena/ArenaVueUiStackbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,12 @@ const config = computed(() => {
...c.style.chart.grid.x,
timeLabels: {
...c.style.chart.grid.x.timeLabels,
values: monthValues.value,
// values: monthValues.value,
values: new Array(6).fill(0).map((d, i) => {
return `Some long name\nfor dataset of index ${i}`
}),
datetimeFormatter: {
enable: true
enable: false
}
// values: ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG']
}
Expand Down Expand Up @@ -337,7 +340,7 @@ function selectTimeLabel(data) {

<template #local>
<LocalVueUiStackbar :dataset="dataset" :config="config" :key="`local_${step}`">
<template #time-label="{x, y, fontSize, fill, transform, absoluteIndex, content, textAnchor }">
<!-- <template #time-label="{x, y, fontSize, fill, transform, absoluteIndex, content, textAnchor }">
<g @click="() => selectTimeLabel({x, y, fontSize, absoluteIndex })">
<text
:x="x"
Expand All @@ -358,7 +361,7 @@ function selectTimeLabel(data) {
{{ content }}
</text>
</g>
</template>
</template> -->
</LocalVueUiStackbar>
</template>

Expand Down
4 changes: 2 additions & 2 deletions TestingArena/ArenaVueUiStripPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const { local, build, vduiLocal, vduiBuild, toggleTable, toggleLabels } = useAre

const dataset = ref([
{
name: "Asia",
name: "Some continent\nwith a long name",
plots: [
{ name: "Shanghai", value: 24.9 },
{ name: "Some Country with\na long name", value: 24.9 },
{ name: "Beijing", value: 21.9 },
{ name: "Delhi", value: 16.8 },
{ name: "Guangzhou", value: 16.1 },
Expand Down
2 changes: 1 addition & 1 deletion TestingArena/ArenaVueUiTreemap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const dataset = ref([
value: 100,
children: [
{
name: 'Some kind of child',
name: 'Some kind of child with a very long name that is way too long',
value: 50
},
{
Expand Down
2 changes: 1 addition & 1 deletion TestingArena/ArenaVueUiVerticalBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { local, build, vduiLocal, vduiBuild, toggleTable, toggleSort } = useArena

const dataset = ref([
{
name: "Serie 1",
name: "Serie 1 with",
value: 100.987987,
children: [
{
Expand Down
6 changes: 3 additions & 3 deletions TestingArena/ArenaVueUiWaffle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const { local, build, vduiLocal, vduiBuild, toggleTable } = useArena()
const dataset = ref([
{
name: 'Lorem Ipsum',
values: [100.27],
values: [1],
},
{
name: 'Dolor Amet',
values: [66.3367]
values: [1]
},
{
name: 'Dignissimos Ducimus',
values: [44.25]
values: [2]
}
]);

Expand Down
7 changes: 5 additions & 2 deletions TestingArena/ArenaVueUiXy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,12 @@ const config = computed(() => {
},
xAxisLabels: {
...c.chart.grid.labels.xAxisLabels,
values: monthValues.value,
// values: monthValues.value,
values: new Array(13).fill(0).map((d,i) => {
return `Some long name\nwith a value ${i}`
}),
datetimeFormatter: {
enable: true,
enable: false,
locale: 'en',
useUTC: false,
januaryAsYear: true,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-data-ui",
"private": false,
"version": "2.14.2",
"version": "2.14.3-beta.1",
"type": "module",
"description": "A user-empowering data visualization Vue 3 components library for eloquent data storytelling",
"keywords": [
Expand Down
42 changes: 31 additions & 11 deletions src/components/vue-ui-donut-evolution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
convertCustomPalette,
createCsvContent,
createUid,
createTSpansFromLineBreaksOnX,
dataLabel,
deepEmptyObjectToNull,
downloadCsv,
Expand Down Expand Up @@ -838,17 +839,36 @@ defineExpose({
<!-- X LABELS -->
<g v-if="FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.show" :class="{'donut-opacity': true,}">
<g v-for="(_, i) in (slicer.end - slicer.start)">
<text
data-cy="axis-x-label"
v-if="(FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.showOnlyFirstAndLast && (i === 0 || i === maxLength - 1)) || !FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.showOnlyFirstAndLast"
:text-anchor="FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.rotation > 0 ? 'start' : FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.rotation < 0 ? 'end' : 'middle'"
:font-size="FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.fontSize"
:fill="FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.color"
:transform="`translate(${padding.left + (slit * i) + (slit / 2)}, ${FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.offsetY + svg.absoluteHeight - padding.bottom + FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.fontSize * 2}), rotate(${FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.rotation})`"

>
{{ timeLabels[i] ? timeLabels[i].text : '' }}
</text>
<g v-if="((FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.showOnlyFirstAndLast && (i === 0 || i === maxLength - 1)) || !FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.showOnlyFirstAndLast) && timeLabels[i] && timeLabels[i].text">
<!-- SINGLE LINE -->
<text
v-if="!String(timeLabels[i].text).includes('\n')"
data-cy="axis-x-label"
:text-anchor="FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.rotation > 0 ? 'start' : FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.rotation < 0 ? 'end' : 'middle'"
:font-size="FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.fontSize"
:fill="FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.color"
:transform="`translate(${padding.left + (slit * i) + (slit / 2)}, ${FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.offsetY + svg.absoluteHeight - padding.bottom + FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.fontSize * 2}), rotate(${FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.rotation})`"

>
{{ timeLabels[i].text }}
</text>
<!-- MULTILINE -->
<text
v-else
data-cy="axis-x-label"
:text-anchor="FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.rotation > 0 ? 'start' : FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.rotation < 0 ? 'end' : 'middle'"
:font-size="FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.fontSize"
:fill="FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.color"
:transform="`translate(${padding.left + (slit * i) + (slit / 2)}, ${FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.offsetY + svg.absoluteHeight - padding.bottom + FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.fontSize * 2}), rotate(${FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.rotation})`"
v-html="createTSpansFromLineBreaksOnX({
content: String(timeLabels[i].text),
fontSize: FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.fontSize,
fill: FINAL_CONFIG.style.chart.layout.grid.xAxis.dataLabels.color,
x: 0,
y: 0
})"
/>
</g>
</g>
</g>

Expand Down
12 changes: 6 additions & 6 deletions src/components/vue-ui-donut.vue
Original file line number Diff line number Diff line change
Expand Up @@ -973,19 +973,19 @@ defineExpose({
<template v-if="total && FINAL_CONFIG.type === 'classic'">
<path v-for="(arc, i) in noGhostDonut" :stroke="FINAL_CONFIG.style.chart.backgroundColor"
:d="arc.arcSlice" fill="#FFFFFF" />
<path v-for="(arc, i) in noGhostDonut" class="vue-ui-donut-arc-path" :data-cy="`donut-arc-${i}`"
:d="arc.arcSlice" :fill="arc.color"
:stroke="FINAL_CONFIG.style.chart.backgroundColor"
:stroke-width="FINAL_CONFIG.style.chart.layout.donut.borderWidth" :filter="getBlurFilter(i)"

/>
<g v-if="$slots.pattern">
<path v-for="(arc, i) in noGhostDonut" class="vue-ui-donut-arc-path"
:data-cy="`donut-arc-pattern-${arc.patternIndex}`" :d="arc.arcSlice"
:fill="`url(#${arc.pattern})`"
:stroke="FINAL_CONFIG.style.chart.backgroundColor"
:stroke-width="FINAL_CONFIG.style.chart.layout.donut.borderWidth" :filter="getBlurFilter(i)" />
</g>
<path v-for="(arc, i) in noGhostDonut" class="vue-ui-donut-arc-path" :data-cy="`donut-arc-${i}`"
:d="arc.arcSlice" :fill="setOpacity(arc.color, 80)"
:stroke="FINAL_CONFIG.style.chart.backgroundColor"
:stroke-width="FINAL_CONFIG.style.chart.layout.donut.borderWidth" :filter="getBlurFilter(i)"

/>
</template>

<template v-if="total && FINAL_CONFIG.type === 'polar'">
Expand Down
64 changes: 46 additions & 18 deletions src/components/vue-ui-history-plot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
calculateNiceScale,
convertColorToHex,
convertCustomPalette,
createCsvContent,
createCsvContent,
createTSpansFromLineBreaksOnX,
createUid,
darkenHexColor,
dataLabel,
Expand Down Expand Up @@ -1036,23 +1037,50 @@ defineExpose({
/>

<g v-if="FINAL_CONFIG.style.chart.plots.labels.show">
<text
data-cy="datapoint-label"
v-for="plot in ds.plots"
:x="plot.x + FINAL_CONFIG.style.chart.plots.labels.offsetX"
:y="plot.y + FINAL_CONFIG.style.chart.plots.labels.offsetY + sizes.plots + sizes.labels"
:font-size="sizes.labels"
:fill="FINAL_CONFIG.style.chart.plots.labels.color"
:font-weight="FINAL_CONFIG.style.chart.plots.labels.bold ? 'bold' : 'normal'"
text-anchor="middle"
:class="{ 'animated' : FINAL_CONFIG.useCssAnimation }"
:style="{
opacity: selectedDatapoint === null ? 1 : selectedDatapoint.id === plot.id ? 1 : 0.3,
transition: 'opacity 0.2s ease-in-out'
}"
>
{{ plot.label }}
</text>
<g v-for="plot in ds.plots">
<!-- SINGLE LINE -->
<text
v-if="!String(plot.label).includes('\n')"
data-cy="datapoint-label"
:x="plot.x + FINAL_CONFIG.style.chart.plots.labels.offsetX"
:y="plot.y + FINAL_CONFIG.style.chart.plots.labels.offsetY + sizes.plots + sizes.labels"
:font-size="sizes.labels"
:fill="FINAL_CONFIG.style.chart.plots.labels.color"
:font-weight="FINAL_CONFIG.style.chart.plots.labels.bold ? 'bold' : 'normal'"
text-anchor="middle"
:class="{ 'animated' : FINAL_CONFIG.useCssAnimation }"
:style="{
opacity: selectedDatapoint === null ? 1 : selectedDatapoint.id === plot.id ? 1 : 0.3,
transition: 'opacity 0.2s ease-in-out'
}"
>
{{ plot.label }}
</text>

<!-- MULTILINE -->
<text
v-else
data-cy="datapoint-label"
:x="plot.x + FINAL_CONFIG.style.chart.plots.labels.offsetX"
:y="plot.y + FINAL_CONFIG.style.chart.plots.labels.offsetY + sizes.plots + sizes.labels"
:font-size="sizes.labels"
:fill="FINAL_CONFIG.style.chart.plots.labels.color"
:font-weight="FINAL_CONFIG.style.chart.plots.labels.bold ? 'bold' : 'normal'"
text-anchor="middle"
:class="{ 'animated' : FINAL_CONFIG.useCssAnimation }"
:style="{
opacity: selectedDatapoint === null ? 1 : selectedDatapoint.id === plot.id ? 1 : 0.3,
transition: 'opacity 0.2s ease-in-out'
}"
v-html="createTSpansFromLineBreaksOnX({
content: String(plot.label),
fontSize: sizes.labels,
fill: FINAL_CONFIG.style.chart.plots.labels.color,
x: plot.x + FINAL_CONFIG.style.chart.plots.labels.offsetX,
y: plot.y + FINAL_CONFIG.style.chart.plots.labels.offsetY + sizes.plots + sizes.labels
})"
/>
</g>
</g>

<!-- INDEX LABELS -->
Expand Down
Loading