Skip to content

Commit 57a4933

Browse files
committed
VueUiTableSparkline improved interactivity
1 parent b479b5d commit 57a4933

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
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.82",
4+
"version": "1.9.83",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue components library",
77
"keywords": [

src/components/vue-ui-sparkline.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ const props = defineProps({
2424
},
2525
showInfo : {
2626
type: Boolean,
27-
default: true
27+
default: true,
28+
},
29+
selectedIndex: {
30+
type: Number,
31+
default: undefined
2832
}
2933
});
3034
@@ -217,7 +221,7 @@ const isBar = computed(() => {
217221
<!-- VERTICAL INDICATORS -->
218222
<line
219223
:data-cy="`sparkline-vertical-indicator-${i}`"
220-
v-if="sparklineConfig.style.verticalIndicator.show && selectedPlot && plot.id === selectedPlot.id"
224+
v-if="sparklineConfig.style.verticalIndicator.show && ((selectedPlot && plot.id === selectedPlot.id) || selectedIndex === i)"
221225
:x1="plot.x"
222226
:x2="plot.x"
223227
:y1="drawingArea.top - 6"
@@ -247,7 +251,7 @@ const isBar = computed(() => {
247251
<g v-if="sparklineConfig.style.plot.show" v-for="(plot, i) in mutableDataset">
248252
<circle
249253
:data-cy="`sparkline-plot-${i}`"
250-
v-if="selectedPlot && plot.id === selectedPlot.id"
254+
v-if="(selectedPlot && plot.id === selectedPlot.id) || selectedIndex === i"
251255
:cx="plot.x"
252256
:cy="plot.y"
253257
:r="sparklineConfig.style.plot.radius"

src/components/vue-ui-table-sparkline.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ defineExpose({
255255
<template>
256256
<div ref="tableContainer" :class="{ 'vue-ui-responsive': isResponsive }" style="overflow: hidden" :id="`table_${uid}`">
257257
258-
<div style="overflow: auto">
258+
<div style="overflow: auto" @pointerleave="selectedSerieIndex = undefined; selectedDataIndex = undefined">
259259
260260
<table data-cy="vue-data-ui-table-sparkline" class="vue-ui-data-table"
261261
:style="{ fontFamily: tableConfig.fontFamily, position: 'relative' }">
@@ -330,7 +330,7 @@ defineExpose({
330330
color: tableConfig.tbody.color,
331331
}" :class="{'vue-ui-data-table__tbody__row' : true, 'vue-ui-data-table__tbody__row-even': i % 2 === 0, 'vue-ui-data-table__tbody__row-odd': i % 2 !== 0}">
332332
<td role="cell" :style="{
333-
backgroundColor: tableConfig.tbody.backgroundColor,
333+
backgroundColor: 'inherit',
334334
outline: tableConfig.tbody.outline,
335335
fontSize: `${tableConfig.tbody.fontSize}px`,
336336
fontWeight: tableConfig.tbody.bold ? 'bold' : 'normal',
@@ -360,7 +360,7 @@ defineExpose({
360360
selectedSerieIndex === i
361361
? '3px'
362362
: '',
363-
}" :data-cell="colNames[j]" class="vue-ui-data-table__tbody__td">
363+
}" :data-cell="colNames[j]" class="vue-ui-data-table__tbody__td" @pointerenter="selectedSerieIndex = i; selectedDataIndex = j">
364364
{{ Number(td.toFixed(tableConfig.roundingValues)).toLocaleString() }}
365365
</td>
366366
<td role="cell" v-if="tableConfig.showTotal" :style="{
@@ -394,7 +394,7 @@ defineExpose({
394394
textAlign: tableConfig.tbody.textAlign,
395395
}" class="vue-ui-data-table__tbody__td sticky-col">
396396
<SparkLine @hoverIndex="({ index }) => hoverSparkline({ dataIndex: index, serieIndex: i })
397-
" :dataset="tr.sparklineDataset" :showInfo="false" :config="{
397+
" :dataset="tr.sparklineDataset" :showInfo="false" :selectedIndex="selectedDataIndex" :config="{
398398
type: tableConfig.sparkline.type,
399399
style: {
400400
backgroundColor: tableConfig.tbody.backgroundColor,

src/default_configs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,7 @@
30263026
"fontSize":18,
30273027
"color":"#2D353C",
30283028
"bold":true,
3029-
"textAlign": "left",
3029+
"textAlign": "center",
30303030
"subtitle": {
30313031
"text": "",
30323032
"color":"#2D353C",

0 commit comments

Comments
 (0)