Skip to content

Commit f37391d

Browse files
committed
VueUiQuadrant add plotLabels showAsTag option
1 parent 3b858c1 commit f37391d

File tree

5 files changed

+50
-32
lines changed

5 files changed

+50
-32
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-data-ui",
33
"private": false,
4-
"version": "2.0.3",
4+
"version": "2.0.4",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue components library",
77
"keywords": [

src/components/vue-ui-quadrant.vue

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup>
22
import { ref, computed, onMounted, nextTick, watch } from "vue";
3-
import { palette, createUid, giftWrap, shiftHue, opacity, convertColorToHex, createCsvContent, downloadCsv } from "../lib";
3+
import { palette, createUid, giftWrap, shiftHue, opacity, convertColorToHex, createCsvContent, downloadCsv, adaptColorToBackground } from "../lib";
44
import pdf from "../pdf.js";
55
import img from "../img.js";
66
import mainConfig from "../default_configs.json";
@@ -818,36 +818,52 @@ defineExpose({
818818
</g>
819819

820820
<!-- PLOTS -->
821-
<g v-for="category in drawableDataset">
822-
<Shape
823-
v-for="plot in category.series"
824-
:color="category.color"
825-
:isSelected="hoveredPlotId && plot.uid === hoveredPlotId"
826-
:plot="plot"
827-
:radius="quadrantConfig.style.chart.layout.plots.radius"
828-
:shape="category.shape"
829-
:stroke="quadrantConfig.style.chart.layout.plots.outline ? quadrantConfig.style.chart.layout.plots.outlineColor : 'none'"
830-
:strokeWidth="quadrantConfig.style.chart.layout.plots.outlineWidth"
831-
@mouseover="hoverPlot(category, plot)"
832-
@mouseleave="isTooltip = false; hoveredPlotId = null; hoveredPlot = null"
833-
@click="selectPlot(category, plot)"
834-
/>
835-
</g>
836-
837-
<g v-if="mutableConfig.plotLabels.show">
821+
<template v-if="!quadrantConfig.style.chart.layout.labels.plotLabels.showAsTag">
838822
<g v-for="category in drawableDataset">
839-
<text
840-
v-for="plot in category.series"
841-
:x="plot.x"
842-
:y="plot.y + quadrantConfig.style.chart.layout.labels.plotLabels.offsetY + quadrantConfig.style.chart.layout.plots.radius"
843-
text-anchor="middle"
844-
:font-size="quadrantConfig.style.chart.layout.labels.plotLabels.fontSize"
845-
:fill="quadrantConfig.style.chart.layout.labels.plotLabels.color"
846-
>
847-
{{ plot.name }}
848-
</text>
823+
<Shape
824+
v-for="plot in category.series"
825+
:color="category.color"
826+
:isSelected="hoveredPlotId && plot.uid === hoveredPlotId"
827+
:plot="plot"
828+
:radius="quadrantConfig.style.chart.layout.plots.radius"
829+
:shape="category.shape"
830+
:stroke="quadrantConfig.style.chart.layout.plots.outline ? quadrantConfig.style.chart.layout.plots.outlineColor : 'none'"
831+
:strokeWidth="quadrantConfig.style.chart.layout.plots.outlineWidth"
832+
@mouseover="hoverPlot(category, plot)"
833+
@mouseleave="isTooltip = false; hoveredPlotId = null; hoveredPlot = null"
834+
@click="selectPlot(category, plot)"
835+
/>
849836
</g>
850-
</g>
837+
838+
<g v-if="mutableConfig.plotLabels.show">
839+
<g v-for="category in drawableDataset">
840+
<text
841+
v-for="plot in category.series"
842+
:x="plot.x"
843+
:y="plot.y + quadrantConfig.style.chart.layout.labels.plotLabels.offsetY + quadrantConfig.style.chart.layout.plots.radius"
844+
text-anchor="middle"
845+
:font-size="quadrantConfig.style.chart.layout.labels.plotLabels.fontSize"
846+
:fill="quadrantConfig.style.chart.layout.labels.plotLabels.color"
847+
>
848+
{{ plot.name }}
849+
</text>
850+
</g>
851+
</g>
852+
</template>
853+
854+
<template v-else>
855+
<g v-if="mutableConfig.plotLabels.show">
856+
<template v-for="category in drawableDataset">
857+
<foreignObject v-for="plot in category.series" style="overflow: visible;" height="10" width="100" :x="plot.x - 50" :y="plot.y - (quadrantConfig.style.chart.layout.labels.plotLabels.fontSize)" @mouseover="hoverPlot(category, plot)"
858+
@mouseleave="isTooltip = false; hoveredPlotId = null; hoveredPlot = null"
859+
@click="selectPlot(category, plot)">
860+
<div :style="`color:${adaptColorToBackground(category.color)};margin: 0 auto; font-size:${quadrantConfig.style.chart.layout.labels.plotLabels.fontSize}px; text-align:center;background:${category.color}; padding: 2px 4px; border-radius: 12px; height: ${quadrantConfig.style.chart.layout.labels.plotLabels.fontSize*1.5}px`">
861+
{{ plot.name }}
862+
</div>
863+
</foreignObject>
864+
</template>
865+
</g>
866+
</template>
851867

852868
<!-- LEGEND AS G -->
853869
<foreignObject

src/default_configs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@
700700
}
701701
},
702702
"plotLabels": {
703+
"showAsTag": false,
703704
"show": true,
704705
"fontSize": 10,
705706
"color": "#2D353C",

types/vue-data-ui.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,6 +2351,7 @@ declare module 'vue-data-ui' {
23512351
};
23522352
};
23532353
plotLabels?: {
2354+
showAsTag?: boolean;
23542355
show?: boolean;
23552356
fontSize?: number;
23562357
color?: string;

0 commit comments

Comments
 (0)