Skip to content

Commit f02222f

Browse files
committed
VueUiXy optional display of data table with sparlines
1 parent 64a6928 commit f02222f

File tree

6 files changed

+69
-7
lines changed

6 files changed

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

src/atoms/Tooltip.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ const position = computed(() => {
6161
box-shadow: 0 6px 12px -6px rgba(0,0,0,0.2);
6262
position: fixed;
6363
padding:12px;
64-
z-index:1;
64+
z-index:2;
6565
}
6666
</style>

src/components/vue-ui-xy.vue

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,15 @@
651651

652652
<!-- DATA TABLE -->
653653
<div :style="`${isPrinting ? '' : 'max-height:400px'};overflow:auto;width:100%;margin-top:48px`" v-if="mutableConfig.showTable">
654+
<div style="display: flex; flex-direction:row; gap: 6px; align-items:center; padding-left: 6px" data-html2canvas-ignore>
655+
<input type="checkbox" v-model="showSparklineTable">
656+
<div @click="showSparklineTable = !showSparklineTable" style="cursor: pointer">
657+
<BaseIcon name="chartLine" :size="20" :stroke="chartConfig.chart.color"/>
658+
</div>
659+
</div>
660+
<TableSparkline v-if="showSparklineTable" :dataset="tableSparklineDataset" :config="tableSparklineConfig"/>
654661
<DataTable
662+
v-else
655663
:colNames="dataTable.colNames"
656664
:head="dataTable.head"
657665
:body="dataTable.body"
@@ -701,6 +709,7 @@ import Tooltip from "../atoms/Tooltip.vue";
701709
import UserOptions from "../atoms/UserOptions.vue";
702710
import Shape from "../atoms/Shape.vue";
703711
import BaseIcon from '../atoms/BaseIcon.vue';
712+
import TableSparkline from "./vue-ui-table-sparkline.vue";
704713
705714
const uid = createUid();
706715
@@ -726,7 +735,8 @@ export default {
726735
Title,
727736
Tooltip,
728737
UserOptions,
729-
BaseIcon
738+
BaseIcon,
739+
TableSparkline
730740
},
731741
data(){
732742
const uniqueId = uid;
@@ -735,6 +745,8 @@ export default {
735745
start: 0,
736746
end: maxX,
737747
}
748+
const showSparklineTable = this.config.table.sparkline || true;
749+
738750
return {
739751
CTX: null,
740752
CANVAS: null,
@@ -775,7 +787,8 @@ export default {
775787
step: 0,
776788
slicer,
777789
__to__: null,
778-
maxX
790+
maxX,
791+
showSparklineTable
779792
}
780793
},
781794
computed: {
@@ -837,6 +850,53 @@ export default {
837850
}
838851
}).filter(s => !this.segregatedSeries.includes(s.id));
839852
},
853+
tableSparklineDataset() {
854+
return this.relativeDataset.map(ds => {
855+
return {
856+
id: ds.id,
857+
name: ds.name,
858+
color: ds.color,
859+
values: ds.absoluteValues.slice(this.slicer.start, this.slicer.end),
860+
}
861+
})
862+
},
863+
tableSparklineConfig() {
864+
return {
865+
responsiveBreakpoint: this.chartConfig.table.responsiveBreakpoint,
866+
roundingAverage: this.chartConfig.table.rounding,
867+
roundingMedian: this.chartConfig.table.rounding,
868+
roundingValues: this.chartConfig.table.rounding,
869+
roundingTotal: this.chartConfig.table.rounding,
870+
fontFamily: this.chartConfig.chart.fontFamily,
871+
colNames: this.chartConfig.chart.grid.labels.xAxisLabels.values,
872+
title: {
873+
backgroundColor: this.chartConfig.chart.backgroundColor,
874+
text: this.chartConfig.chart.title.text,
875+
fontSize: this.chartConfig.chart.title.fontSize,
876+
color: this.chartConfig.chart.title.color,
877+
bold: this.chartConfig.chart.title.bold,
878+
subtitle: {
879+
text: this.chartConfig.chart.title.subtitle.text,
880+
color: this.chartConfig.chart.title.subtitle.color ?? '#CCCCCC',
881+
fontSize: this.chartConfig.chart.title.fontSize,
882+
bold: this.chartConfig.chart.title.bold,
883+
}
884+
},
885+
thead: {
886+
backgroundColor: this.chartConfig.table.th.backgroundColor,
887+
color: this.chartConfig.table.th.color,
888+
outline: this.chartConfig.table.th.outline
889+
},
890+
tbody: {
891+
backgroundColor: this.chartConfig.table.td.backgroundColor,
892+
color: this.chartConfig.table.td.color,
893+
outline: this.chartConfig.table.td.outline
894+
},
895+
userOptions: {
896+
show: false
897+
}
898+
}
899+
},
840900
absoluteDataset() {
841901
return this.safeDataset.map((datapoint, i) => {
842902
return {

src/default_configs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
"offsetY": 0,
248248
"subtitle": {
249249
"fontSize": 16,
250-
"color": "grey",
250+
"color": "#CCCCCC",
251251
"text": ""
252252
}
253253
},
@@ -309,6 +309,7 @@
309309
"table": {
310310
"rounding": 0,
311311
"responsiveBreakpoint": 400,
312+
"sparkline": true,
312313
"columnNames": {
313314
"period": "Period",
314315
"total": "Total"

types/vue-data-ui.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,7 @@ declare module 'vue-data-ui' {
18791879
table?: {
18801880
rounding?: number;
18811881
responsiveBreakpoint?: number;
1882+
sparkline?: boolean;
18821883
columnNames?: {
18831884
period?: string;
18841885
total?: string;

0 commit comments

Comments
 (0)