Skip to content

Commit 49b8150

Browse files
committed
VueUiXy add highlightArea config option
1 parent 143ffa4 commit 49b8150

File tree

6 files changed

+87
-4
lines changed

6 files changed

+87
-4
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": "1.9.8",
4+
"version": "1.9.9",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue components library",
77
"keywords": [

src/App.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ const config = ref({
8282
highlighter: {
8383
color: "#FF0000",
8484
},
85+
highlightArea: {
86+
show: true,
87+
from: 3,
88+
to: 5,
89+
color: "#2D353C",
90+
opacity: 20,
91+
caption: {
92+
text: 'Lorem ipsum dolor sic amet and some more thoughts',
93+
fontSize: 12,
94+
color: "#2D353C",
95+
bold: true,
96+
offsetY: 0,
97+
width: 'auto',
98+
padding: 3,
99+
textAlign: 'center'
100+
}
101+
},
85102
tooltip: {
86103
roundingPercentage: 0,
87104
backgroundColor: "#FFFFFF",

src/components/vue-ui-xy.vue

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,29 @@
528528
</g>
529529
</g>
530530

531+
<!-- HIGHLITGHT AREA -->
532+
<g v-if="hasHighlightArea">
533+
<rect
534+
data-cy="xy-highlight-area"
535+
:x="drawingArea.left + (drawingArea.width / maxSeries) * (chartConfig.chart.highlightArea.from - (slicer.start))"
536+
:y="drawingArea.top"
537+
:height="drawingArea.height"
538+
:width="(drawingArea.width / maxSeries) * highlightAreaSpan"
539+
:fill="`${chartConfig.chart.highlightArea.color}${opacity[chartConfig.chart.highlightArea.opacity]}`"
540+
/>
541+
<foreignObject v-if="chartConfig.chart.highlightArea.caption.text"
542+
:x="(drawingArea.left + (drawingArea.width / maxSeries) * (chartConfig.chart.highlightArea.from - (slicer.start))) - (chartConfig.chart.highlightArea.caption.width === 'auto' ? 0 : chartConfig.chart.highlightArea.caption.width / 2 - (drawingArea.width / maxSeries) * highlightAreaSpan / 2)"
543+
:y="drawingArea.top + chartConfig.chart.highlightArea.caption.offsetY"
544+
style="overflow:visible"
545+
:width="chartConfig.chart.highlightArea.caption.width === 'auto' ? (drawingArea.width / maxSeries) * highlightAreaSpan : chartConfig.chart.highlightArea.caption.width"
546+
547+
>
548+
<div :style="`padding:${chartConfig.chart.highlightArea.caption.padding}px;text-align:${chartConfig.chart.highlightArea.caption.textAlign};font-size:${chartConfig.chart.highlightArea.caption.fontSize}px;color:${chartConfig.chart.highlightArea.caption.color};font-weight:${chartConfig.chart.highlightArea.caption.bold ? 'bold' : 'normal'}`">
549+
{{ chartConfig.chart.highlightArea.caption.text }}
550+
</div>
551+
</foreignObject>
552+
</g>
553+
531554
<!-- TOOLTIP TRAPS -->
532555
<g v-if="chartConfig.chart.tooltip.show">
533556
<g v-for="(trap, i) in maxSeries" :key="`tooltip_trap_${i}`">
@@ -724,6 +747,16 @@ export default {
724747
return val;
725748
}
726749
},
750+
hasHighlightArea() {
751+
return this.chartConfig.chart.highlightArea && this.chartConfig.chart.highlightArea.show;
752+
},
753+
highlightAreaSpan() {
754+
const { from, to } = this.chartConfig.chart.highlightArea;
755+
console.log({ from, to})
756+
if (from === to) return 1;
757+
if (to < from) return 0;
758+
return to - from + 1;
759+
},
727760
relativeZero() {
728761
if(this.min >= 0) return 0;
729762
return Math.abs(this.min);

src/default_configs.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,30 @@
186186
"color": "#2D353C",
187187
"opacity": 5
188188
},
189+
"highlightArea": {
190+
"show": false,
191+
"from": 0,
192+
"to": 0,
193+
"color": "#2D353C",
194+
"opacity": 20,
195+
"caption": {
196+
"text": "",
197+
"fontSize": 10,
198+
"color":"#2D353C",
199+
"bold": false,
200+
"offsetY": 0,
201+
"width": "auto",
202+
"padding": 3,
203+
"textAlign": "center"
204+
}
205+
},
189206
"grid": {
190207
"stroke": "#e1e5e8",
191208
"showVerticalLines": false,
192209
"labels": {
193210
"color": "#2D353C",
194211
"show": true,
195-
"fontSize": 10,
212+
"fontSize": 12,
196213
"axis": {
197214
"yLabel": "",
198215
"xLabel": "",

types/vue-data-ui.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,22 @@ declare module 'vue-data-ui' {
998998
color?: string;
999999
opacity?: number;
10001000
};
1001+
highlightArea?: {
1002+
show?: boolean;
1003+
from?: number;
1004+
to?: number;
1005+
color?: string;
1006+
opacity?: number;
1007+
caption?: {
1008+
text?: string;
1009+
fontSize?: number;
1010+
color?:number;
1011+
bold?:boolean;
1012+
offsetY?: boolean;
1013+
width?: "auto" | number;
1014+
textAlign?: "left" | "center" | "right";
1015+
};
1016+
};
10011017
grid?: {
10021018
stroke?: string;
10031019
showVerticalLines?: boolean;

0 commit comments

Comments
 (0)