Skip to content

Commit 3b6ae2c

Browse files
committed
VueUiTableSparkline added component
1 parent ff722a0 commit 3b6ae2c

File tree

11 files changed

+679
-12
lines changed

11 files changed

+679
-12
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
![GitHub issues](https://img.shields.io/github/issues/graphieros/vue-data-ui)
1515
![NPM](https://img.shields.io/npm/l/vue-data-ui)
1616
![npm](https://img.shields.io/npm/dt/vue-data-ui)
17-
![Static Badge](https://img.shields.io/badge/components-35-green)
17+
![Static Badge](https://img.shields.io/badge/components-36-green)
1818

1919
[Interactive documentation](https://vue-data-ui.graphieros.com/)
2020

@@ -56,6 +56,7 @@ Available components:
5656
- [VueUi3dBar](https://vue-data-ui.graphieros.com/docs#vue-ui-3d-bar)
5757

5858
## Tables
59+
- [VueUiTableSparkline](https://vue-data-ui.graphieros.com/docs#vue-ui-table-sparkline)
5960
- [VueUiTable](https://vue-data-ui.graphieros.com/docs#vue-ui-table)
6061

6162
## Rating

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

src/App.vue

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import Bar3dTest from "./components/vue-ui-3d-bar.vue";
4747
import DigitsTest from "./components/vue-ui-digits.vue";
4848
import MoleculeTest from './components/vue-ui-molecule.vue';
4949
import DonutEvolutionTest from "./components/vue-ui-donut-evolution.vue";
50+
import TableSparklineTest from "./components/vue-ui-table-sparkline.vue";
5051
5152
const dataset = ref([
5253
{
@@ -3791,6 +3792,21 @@ const moodRadarConfig = ref({
37913792
}
37923793
])
37933794
3795+
const tableSparklineDataset = ref([
3796+
{
3797+
name: "Serie 1",
3798+
values: [1, 2, 3, 8, 13, 21]
3799+
},
3800+
{
3801+
name: "Serie 2",
3802+
values: [12, 1, 6, 7, 5, 12]
3803+
},
3804+
{
3805+
name: "Serie 3",
3806+
values: [18, 12, 21, 12, 6, 7]
3807+
},
3808+
])
3809+
37943810
</script>
37953811

37963812
<template>
@@ -3891,6 +3907,24 @@ const moodRadarConfig = ref({
38913907
</template>
38923908
</Box>
38933909

3910+
<Box open @copy="copyConfig(PROD_CONFIG.vue_ui_table_sparkline)">
3911+
<template #title>
3912+
<BaseIcon name="chartTable"/>
3913+
VueUiTableSparkline
3914+
</template>
3915+
<template #info>
3916+
</template>
3917+
<template #dev>
3918+
<TableSparklineTest :dataset="tableSparklineDataset"/>
3919+
</template>
3920+
<template #prod>
3921+
<VueUiTableSparkline :dataset="tableSparklineDataset"/>
3922+
</template>
3923+
<template #config>
3924+
{{ PROD_CONFIG.vue_ui_table_sparkline }}
3925+
</template>
3926+
</Box>
3927+
38943928
<Box @copy="copyConfig(PROD_CONFIG.vue_ui_molecule)">
38953929
<template #title>
38963930
<BaseIcon name="chartCluster"/>

src/atoms/BaseIcon.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const icons = computed(() => {
7575
skeleton: `<path fill="none" stroke="${props.stroke}" stroke-width="${props.strokeWidth}" stroke-linecap="round" d="M3 14A1 1 0 003 18L7 18A1 1 0 007 14L3 14M3 8A1 1 0 003 12L7 12A1 1 0 007 8L3 8M3 2A1 1 0 003 6L4 6A1 1 0 004 2L3 2M12 10 12 16C12 17 13 18 14 18L17 18C18 18 19 17 19 16L19 10C19 9 18 8 17 8L14 8C13 8 12 9 12 10" stroke-dasharray="2" />`,
7676
smiley: `<path fill="none" stroke="${props.stroke}" stroke-width="${props.strokeWidth}" stroke-linecap="round" d="M1 10A1 1 0 0019 10 1 1 0 001 10M5 12C8 14 12 14 15 12M5 7A1 1 0 008 7 1 1 0 005 7M12 7A1 1 0 0015 7 1 1 0 0012 7" />`,
7777
sort: `<path stroke-width="${props.strokeWidth}" fill="none" stroke="${props.stroke}" stroke-linecap="round" d="M1 15 5 18 9 15M5 5 5 18M15 15 15 2M11 5 15 2 19 5" />`,
78+
sortReverse: `<path stroke-width="${props.strokeWidth}" fill="none" stroke="${props.stroke}" stroke-linecap="round" d="M 1 8 L 5 5 L 9 8 M 5 5 L 5 18 M 15 15 L 15 2 M 11 12 L 15 15 L 19 12" />`,
7879
spin: `<path stroke-width="${props.strokeWidth}" fill="none" stroke="${props.stroke}" stroke-linecap="round" d="M1 10A1 1 0 0019 10 1 1 0 004 10 1 1 0 0016 10 1 1 0 007 10 1 1 0 0013 10 1 1 0 0010 10M1 10Q1 5 5 2" />`,
7980
star: `<path fill="none" stroke="${props.stroke}" stroke-width="${props.strokeWidth}" stroke-linecap="round" stroke-linejoin="round" d="M3 19 10 15 17 19 14 12 19 8 13 8 10 2 7 8 1 8 6 12 3 19" />`,
8081
tableClose: `<path stroke-width="${props.strokeWidth}" stroke-linecap="round" fill="none" stroke="${props.stroke}" d="M4 1 4 1C2 1 1 2 1 4L1 16C1 18 2 19 4 19L7 19M4 1 16 1C18 1 19 2 19 4L19 14M18 19 14 16 10 19"/><line stroke-width="${props.strokeWidth}" stroke="${props.stroke}" x1="8" y1="1" x2="8" y2="19" stroke-linecap="round" /><line stroke-width="${props.strokeWidth}" stroke="${props.stroke}" x1="1" y1="8" x2="19" y2="8" />`,

src/components/vue-ui-sparkline.vue

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const props = defineProps({
2121
default() {
2222
return []
2323
}
24+
},
25+
showInfo : {
26+
type: Boolean,
27+
default: true
2428
}
2529
});
2630
@@ -39,15 +43,17 @@ const svg = ref({
3943
width: 500,
4044
});
4145
46+
const emits = defineEmits(['hoverIndex'])
47+
4248
const drawingArea = computed(() => {
4349
const topPadding = 12;
4450
return {
4551
top: topPadding,
4652
left: 0,
4753
right: svg.value.width,
4854
bottom: svg.value.height - 3,
49-
start: sparklineConfig.value.style.dataLabel.position === 'left' ? 210 : 0,
50-
width: 290,
55+
start: props.showInfo && sparklineConfig.value.style.dataLabel.position === 'left' ? 210 : 0,
56+
width: props.showInfo ? 290 : svg.value.width,
5157
height: svg.value.height - topPadding
5258
}
5359
});
@@ -110,8 +116,14 @@ const area = computed(() => {
110116
111117
const selectedPlot = ref(undefined);
112118
113-
function selectPlot(plot) {
119+
function selectPlot(plot, index) {
114120
selectedPlot.value = plot;
121+
emits('hoverIndex', {index})
122+
}
123+
124+
function unselectPlot() {
125+
selectedPlot.value = undefined
126+
emits('hoverIndex', {index:undefined})
115127
}
116128
117129
const dataLabel = computed(() => {
@@ -135,7 +147,7 @@ const isBar = computed(() => {
135147
<template>
136148
<div class="vue-ui-sparkline" :id="uid" :style="`width:100%;font-family:${sparklineConfig.style.fontFamily}`">
137149
<!-- TITLE -->
138-
<div v-if="sparklineConfig.style.title.show" class="vue-ui-sparkline-title" :style="`display:flex;align-items:center;width:100%;color:${sparklineConfig.style.title.color};background:${sparklineConfig.style.backgroundColor};justify-content:${sparklineConfig.style.title.textAlign === 'left' ? 'flex-start' : sparklineConfig.style.title.textAlign === 'right' ? 'flex-end' : 'center'};height:${sparklineConfig.style.title.fontSize * 2}px;font-size:${sparklineConfig.style.title.fontSize}px;font-weight:${sparklineConfig.style.title.bold ? 'bold' : 'normal'};`">
150+
<div v-if="sparklineConfig.style.title.show && showInfo" class="vue-ui-sparkline-title" :style="`display:flex;align-items:center;width:100%;color:${sparklineConfig.style.title.color};background:${sparklineConfig.style.backgroundColor};justify-content:${sparklineConfig.style.title.textAlign === 'left' ? 'flex-start' : sparklineConfig.style.title.textAlign === 'right' ? 'flex-end' : 'center'};height:${sparklineConfig.style.title.fontSize * 2}px;font-size:${sparklineConfig.style.title.fontSize}px;font-weight:${sparklineConfig.style.title.bold ? 'bold' : 'normal'};`">
139151
<span data-cy="sparkline-period-label" :style="`padding:${sparklineConfig.style.title.textAlign === 'left' ? '0 0 0 12px' : sparklineConfig.style.title.textAlign === 'right' ? '0 12px 0 0' : '0'}`">
140152
{{ selectedPlot ? selectedPlot.period : sparklineConfig.style.title.text }}
141153
</span>
@@ -247,6 +259,7 @@ const isBar = computed(() => {
247259

248260
<!-- DATALABEL -->
249261
<text
262+
v-if="showInfo"
250263
data-cy="sparkline-datalabel"
251264
:x="sparklineConfig.style.dataLabel.position === 'left' ? 12 : drawingArea.width + 12"
252265
:y="svg.height / 2 + sparklineConfig.style.dataLabel.fontSize / 2.5"
@@ -266,8 +279,8 @@ const isBar = computed(() => {
266279
:height="drawingArea.height + 6"
267280
:width="(drawingArea.width / len)"
268281
fill="transparent"
269-
@mouseenter="selectPlot(plot)"
270-
@mouseleave="selectedPlot = undefined"
282+
@mouseenter="selectPlot(plot, i)"
283+
@mouseleave="unselectPlot"
271284
/>
272285
<slot name="svg" :svg="svg"/>
273286
</svg>

0 commit comments

Comments
 (0)