Skip to content

Commit

Permalink
feat: split key value table in 3 columns (key, value, percent)
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Sep 23, 2024
1 parent 7019956 commit f1880f5
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions packages/core/src/components/utility/kv-table/DKVTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,52 @@ export default defineComponent({
setup(props) {
const items = computed<{
key: string,
value: number | string
value: number | string,
percent: number | string
}[]>(() => props.data.map((item) => {
let key : string;
if (typeof item.value === 'number') {
key = `${generateChartLabelsForKeyValueRecord(item)}`;
} else if (isConceptCount(item)) {
key = `${generateChartLabelsForKeyValueRecord(item, {
codingVerbose: props.codingVerboseLabel,
})} (${item.value.percent.toFixed(1)}%)`;
} else {
key = 'unknown';
}
let value : number | string;
let percent : number | string;
if (typeof item.value === 'number') {
key = `${generateChartLabelsForKeyValueRecord(item)}`;
value = item.value.toFixed(2);
percent = '?%';
} else if (isConceptCount(item)) {
key = generateChartLabelsForKeyValueRecord(item, {
codingVerbose: props.codingVerboseLabel,
});
value = item.value.count.toFixed(2);
percent = `${item.value.percent.toFixed(1)}%`;
} else {
key = 'unknown';
value = Number(item.value);
percent = '?%';
}
return {
key,
value,
percent,
};
}));
const fields : TableFieldRaw[] = [
{
key: 'key',
label: 'Key',
label: 'Element',
thClass: 'text-left',
tdClass: 'text-left',
},
{
key: 'value',
label: 'Value',
label: 'Häufigkeit',
thClass: 'text-center',
tdClass: 'text-center',
},
{
key: 'percent',
label: 'Prozent (%)',
thClass: 'text-center',
tdClass: 'text-center',
},
Expand Down

0 comments on commit f1880f5

Please sign in to comment.