Skip to content

Commit e3718ac

Browse files
committed
Improvement - VueUiTableHeatmap added optional datapoint object attributes color and shape & config attribute shapeSize
1 parent 4d9a846 commit e3718ac

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import img from "../img";
1717
import mainConfig from "../default_configs.json";
1818
import { useNestedProp } from "../useNestedProp";
1919
import UserOptions from "../atoms/UserOptions.vue";
20+
import Shape from "../atoms/Shape.vue";
2021
2122
const props = defineProps({
2223
config: {
@@ -239,8 +240,23 @@ defineExpose({
239240
v-for="(cell, j) in row.displayValues"
240241
:data-cell="tableConfig.table.head.values[j]"
241242
>
242-
<slot v-if="j === 0" name="rowTitle" v-bind="{ value: cell, rowIndex: i, colIndex: j, type: typeof cell, isResponsive}"></slot>
243-
<slot v-if="j > 0" name="cell" v-bind="{ value: cell, rowIndex: i, colIndex: j, type: typeof cell, isResponsive, color: row.colors[j], textColor: adaptColorToBackground(row.colors[j]) }"></slot>
243+
<template v-if="row.color && j === 0">
244+
<div style="display:flex; flex-direction: row; gap:2px; align-items:center;">
245+
<svg :height="tableConfig.style.shapeSize" :width="tableConfig.style.shapeSize" v-if="row.color" viewBox="0 0 20 20" style="background: none;overflow: visible">
246+
<Shape
247+
:plot="{ x: 10, y: 10 }"
248+
:color="row.color"
249+
:radius="9"
250+
:shape="row.shape || 'circle'"
251+
/>
252+
</svg>
253+
<slot name="rowTitle" v-bind="{ value: cell, rowIndex: i, colIndex: j, type: typeof cell, isResponsive}"></slot>
254+
</div>
255+
</template>
256+
<template v-else>
257+
<slot v-if="j === 0" name="rowTitle" v-bind="{ value: cell, rowIndex: i, colIndex: j, type: typeof cell, isResponsive}"></slot>
258+
<slot v-if="j > 0" name="cell" v-bind="{ value: cell, rowIndex: i, colIndex: j, type: typeof cell, isResponsive, color: row.colors[j], textColor: adaptColorToBackground(row.colors[j]) }"></slot>
259+
</template>
244260
</td>
245261
<td role="cell" data-cell="sum" v-if="tableConfig.table.showSum">
246262
<slot name="sum" v-bind="{ value: row.sum, rowIndex: i, isResponsive }"></slot>

src/default_configs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3651,6 +3651,7 @@
36513651
"backgroundColor": "#FFFFFF",
36523652
"color":"#2D353C",
36533653
"fontFamily": "inherit",
3654+
"shapeSize": 14,
36543655
"heatmapColors": {
36553656
"useIndividualScale": false,
36563657
"min": "#FFFFFF",

types/vue-data-ui.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4652,14 +4652,17 @@ declare module 'vue-data-ui' {
46524652

46534653
export type VueUiTableHeatmapDatasetItem = {
46544654
name: string;
4655-
values: Array<number | string>
4655+
values: Array<number | string>;
4656+
color?: string;
4657+
shape?: "circle" | "triangle" | "square" | "diamond" | "pentagon" | "hexagon" | "star";
46564658
};
46574659

46584660
export type VueUiTableHeatmapConfig = {
46594661
style?: {
46604662
backgroundColor?: string;
46614663
color?: string;
46624664
fontFamily?: string;
4665+
shapeSize?: number;
46634666
heatmapColors?: {
46644667
useIndividualScale?: boolean;
46654668
min?: string;

0 commit comments

Comments
 (0)