mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
hide percent for outflows/inflows by account categorical chart
This commit is contained in:
@@ -33,6 +33,7 @@ export interface CommonPieChartProps {
|
|||||||
minValidPercent?: number;
|
minValidPercent?: number;
|
||||||
defaultCurrency?: string;
|
defaultCurrency?: string;
|
||||||
showValue?: boolean;
|
showValue?: boolean;
|
||||||
|
showPercent?: boolean;
|
||||||
enableClickItem?: boolean;
|
enableClickItem?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,9 +142,11 @@ const chartOptions = computed<object>(() => {
|
|||||||
tooltip += `<div class="d-inline-flex">${name}</div><br/>`;
|
tooltip += `<div class="d-inline-flex">${name}</div><br/>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.showValue) {
|
if (props.showValue && props.showPercent) {
|
||||||
tooltip += `<div class="d-inline-flex"><span>${value}</span><span class="ms-1">(${percent})</span></div>`;
|
tooltip += `<div class="d-inline-flex"><span>${value}</span><span class="ms-1">(${percent})</span></div>`;
|
||||||
} else {
|
} else if (props.showValue && !props.showPercent) {
|
||||||
|
tooltip += `<div class="d-inline-flex">${value}</div>`;
|
||||||
|
} else if (!props.showValue && props.showPercent) {
|
||||||
tooltip += `<div class="d-inline-flex">${percent}</div>`;
|
tooltip += `<div class="d-inline-flex">${percent}</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ const props = defineProps<{
|
|||||||
minValidPercent?: number;
|
minValidPercent?: number;
|
||||||
defaultCurrency?: string;
|
defaultCurrency?: string;
|
||||||
showValue?: boolean;
|
showValue?: boolean;
|
||||||
|
showPercent?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -92,11 +93,15 @@ const radarData = computed<RadarChartData>(() => {
|
|||||||
|
|
||||||
tooltip += '<div><span class="chart-pointer" style="background-color: ' + color + '"></span>';
|
tooltip += '<div><span class="chart-pointer" style="background-color: ' + color + '"></span>';
|
||||||
tooltip += `<span>${name}</span>`;
|
tooltip += `<span>${name}</span>`;
|
||||||
if (props.showValue) {
|
|
||||||
|
if (props.showValue && props.showPercent) {
|
||||||
tooltip += `<span class="ms-1" style="float: inline-end">(${displayPercent})</span><span class="ms-5" style="float: inline-end">${displayValue}</span>`;
|
tooltip += `<span class="ms-1" style="float: inline-end">(${displayPercent})</span><span class="ms-5" style="float: inline-end">${displayValue}</span>`;
|
||||||
} else {
|
} else if (props.showValue && !props.showPercent) {
|
||||||
|
tooltip += `<span class="ms-5" style="float: inline-end">${displayValue}</span>`;
|
||||||
|
} else if (!props.showValue && props.showPercent) {
|
||||||
tooltip += `<span class="ms-5" style="float: inline-end">${displayPercent}</span>`;
|
tooltip += `<span class="ms-5" style="float: inline-end">${displayPercent}</span>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
tooltip += '</div>';
|
tooltip += '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
</f7-link>
|
</f7-link>
|
||||||
|
|
||||||
<div class="pie-chart-toolbox-info">
|
<div class="pie-chart-toolbox-info">
|
||||||
<p v-if="selectedItem">
|
<p v-if="showPercent && selectedItem">
|
||||||
<f7-chip class="chip-placeholder" outline v-if="skeleton">
|
<f7-chip class="chip-placeholder" outline v-if="skeleton">
|
||||||
<span class="skeleton-text">Percent</span>
|
<span class="skeleton-text">Percent</span>
|
||||||
</f7-chip>
|
</f7-chip>
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
:style="getColorStyle(selectedItem?.color, '--f7-chip-outline-border-color')"
|
:style="getColorStyle(selectedItem?.color, '--f7-chip-outline-border-color')"
|
||||||
v-else-if="!skeleton"></f7-chip>
|
v-else-if="!skeleton"></f7-chip>
|
||||||
</p>
|
</p>
|
||||||
<p v-else-if="!validItems || !validItems.length">
|
<p v-else-if="showPercent && (!validItems || !validItems.length)">
|
||||||
<f7-chip outline text="---"></f7-chip>
|
<f7-chip outline text="---"></f7-chip>
|
||||||
</p>
|
</p>
|
||||||
<f7-link class="pie-chart-selected-item-info" :no-link-class="!enableClickItem" v-if="selectedItem" @click="clickItem(selectedItem)">
|
<f7-link class="pie-chart-selected-item-info" :no-link-class="!enableClickItem" v-if="selectedItem" @click="clickItem(selectedItem)">
|
||||||
|
|||||||
@@ -326,17 +326,38 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
|||||||
const allStatisticsItems: TransactionCategoricalAnalysisDataItem[] = [];
|
const allStatisticsItems: TransactionCategoricalAnalysisDataItem[] = [];
|
||||||
|
|
||||||
if (combinedData && combinedData.items) {
|
if (combinedData && combinedData.items) {
|
||||||
|
let maxTotalAmount = 0;
|
||||||
|
|
||||||
|
for (const dataItem of values(combinedData.items)) {
|
||||||
|
if (dataItem.totalAmount > maxTotalAmount) {
|
||||||
|
maxTotalAmount = dataItem.totalAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const dataItem of values(combinedData.items)) {
|
for (const dataItem of values(combinedData.items)) {
|
||||||
let percent = 0;
|
let percent = 0;
|
||||||
|
|
||||||
if (dataItem.totalAmount > 0) {
|
if (transactionStatisticsFilter.value.chartDataType === ChartDataType.OutflowsByAccount.type ||
|
||||||
percent = dataItem.totalAmount * 100 / combinedData.totalNonNegativeAmount;
|
transactionStatisticsFilter.value.chartDataType === ChartDataType.InflowsByAccount.type) {
|
||||||
} else {
|
if (maxTotalAmount > 0) {
|
||||||
percent = 0;
|
percent = dataItem.totalAmount * 100 / maxTotalAmount;
|
||||||
}
|
} else {
|
||||||
|
percent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (percent < 0) {
|
if (percent < 0) {
|
||||||
percent = 0;
|
percent = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dataItem.totalAmount > 0) {
|
||||||
|
percent = dataItem.totalAmount * 100 / combinedData.totalNonNegativeAmount;
|
||||||
|
} else {
|
||||||
|
percent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (percent < 0) {
|
||||||
|
percent = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const statisticDataItem: TransactionCategoricalAnalysisDataItem = {
|
const statisticDataItem: TransactionCategoricalAnalysisDataItem = {
|
||||||
|
|||||||
@@ -212,6 +212,11 @@ export function useStatisticsTransactionPageBase() {
|
|||||||
return tt('Total Amount');
|
return tt('Total Amount');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const showPercentInCategoricalChart = computed<boolean>(() => {
|
||||||
|
return query.value.chartDataType !== ChartDataType.OutflowsByAccount.type &&
|
||||||
|
query.value.chartDataType !== ChartDataType.InflowsByAccount.type;
|
||||||
|
});
|
||||||
|
|
||||||
const showTotalAmountInTrendsChart = computed<boolean>(() => {
|
const showTotalAmountInTrendsChart = computed<boolean>(() => {
|
||||||
return query.value.chartDataType !== ChartDataType.TotalOutflows.type &&
|
return query.value.chartDataType !== ChartDataType.TotalOutflows.type &&
|
||||||
query.value.chartDataType !== ChartDataType.TotalExpense.type &&
|
query.value.chartDataType !== ChartDataType.TotalExpense.type &&
|
||||||
@@ -300,6 +305,7 @@ export function useStatisticsTransactionPageBase() {
|
|||||||
canUseKeywordFilter,
|
canUseKeywordFilter,
|
||||||
showAmountInChart,
|
showAmountInChart,
|
||||||
totalAmountName,
|
totalAmountName,
|
||||||
|
showPercentInCategoricalChart,
|
||||||
showTotalAmountInTrendsChart,
|
showTotalAmountInTrendsChart,
|
||||||
translateNameInTrendsChart,
|
translateNameInTrendsChart,
|
||||||
categoricalAnalysisData,
|
categoricalAnalysisData,
|
||||||
|
|||||||
@@ -224,6 +224,7 @@
|
|||||||
:items="categoricalAnalysisData && categoricalAnalysisData.items && categoricalAnalysisData.items.length ? categoricalAnalysisData.items : []"
|
:items="categoricalAnalysisData && categoricalAnalysisData.items && categoricalAnalysisData.items.length ? categoricalAnalysisData.items : []"
|
||||||
:min-valid-percent="0.0001"
|
:min-valid-percent="0.0001"
|
||||||
:show-value="showAmountInChart"
|
:show-value="showAmountInChart"
|
||||||
|
:show-percent="showPercentInCategoricalChart"
|
||||||
:enable-click-item="true"
|
:enable-click-item="true"
|
||||||
:default-currency="defaultCurrency"
|
:default-currency="defaultCurrency"
|
||||||
id-field="id"
|
id-field="id"
|
||||||
@@ -273,7 +274,7 @@
|
|||||||
<div class="d-flex flex-column ms-2">
|
<div class="d-flex flex-column ms-2">
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<span>{{ item.name }}</span>
|
<span>{{ item.name }}</span>
|
||||||
<small class="statistics-percent" v-if="item.percent >= 0">{{ formatPercentToLocalizedNumerals(item.percent, 2, '<0.01') }}</small>
|
<small class="statistics-percent" v-if="showPercentInCategoricalChart && item.percent >= 0">{{ formatPercentToLocalizedNumerals(item.percent, 2, '<0.01') }}</small>
|
||||||
<v-spacer/>
|
<v-spacer/>
|
||||||
<span class="statistics-amount">{{ getDisplayAmount(item.totalAmount, defaultCurrency) }}</span>
|
<span class="statistics-amount">{{ getDisplayAmount(item.totalAmount, defaultCurrency) }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -310,6 +311,7 @@
|
|||||||
:items="categoricalAnalysisData && categoricalAnalysisData.items && categoricalAnalysisData.items.length ? categoricalAnalysisData.items : []"
|
:items="categoricalAnalysisData && categoricalAnalysisData.items && categoricalAnalysisData.items.length ? categoricalAnalysisData.items : []"
|
||||||
:min-valid-percent="0.0001"
|
:min-valid-percent="0.0001"
|
||||||
:show-value="showAmountInChart"
|
:show-value="showAmountInChart"
|
||||||
|
:show-percent="showPercentInCategoricalChart"
|
||||||
:default-currency="defaultCurrency"
|
:default-currency="defaultCurrency"
|
||||||
name-field="name"
|
name-field="name"
|
||||||
value-field="totalAmount"
|
value-field="totalAmount"
|
||||||
@@ -518,6 +520,7 @@ const {
|
|||||||
canUseKeywordFilter,
|
canUseKeywordFilter,
|
||||||
showAmountInChart,
|
showAmountInChart,
|
||||||
totalAmountName,
|
totalAmountName,
|
||||||
|
showPercentInCategoricalChart,
|
||||||
showTotalAmountInTrendsChart,
|
showTotalAmountInTrendsChart,
|
||||||
translateNameInTrendsChart,
|
translateNameInTrendsChart,
|
||||||
categoricalAnalysisData,
|
categoricalAnalysisData,
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
:items="categoricalAnalysisData.items"
|
:items="categoricalAnalysisData.items"
|
||||||
:min-valid-percent="0.0001"
|
:min-valid-percent="0.0001"
|
||||||
:show-value="showAmountInChart"
|
:show-value="showAmountInChart"
|
||||||
|
:show-percent="showPercentInCategoricalChart"
|
||||||
:show-center-text="true"
|
:show-center-text="true"
|
||||||
:show-selected-item-info="true"
|
:show-selected-item-info="true"
|
||||||
:enable-click-item="true"
|
:enable-click-item="true"
|
||||||
@@ -171,7 +172,7 @@
|
|||||||
<template #title>
|
<template #title>
|
||||||
<div class="statistics-list-item-text">
|
<div class="statistics-list-item-text">
|
||||||
<span>{{ item.name }}</span>
|
<span>{{ item.name }}</span>
|
||||||
<small class="statistics-percent" v-if="item.percent >= 0">{{ formatPercentToLocalizedNumerals(item.percent, 2, '<0.01') }}</small>
|
<small class="statistics-percent" v-if="showPercentInCategoricalChart && item.percent >= 0">{{ formatPercentToLocalizedNumerals(item.percent, 2, '<0.01') }}</small>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -403,6 +404,7 @@ const {
|
|||||||
canUseKeywordFilter,
|
canUseKeywordFilter,
|
||||||
showAmountInChart,
|
showAmountInChart,
|
||||||
totalAmountName,
|
totalAmountName,
|
||||||
|
showPercentInCategoricalChart,
|
||||||
translateNameInTrendsChart,
|
translateNameInTrendsChart,
|
||||||
categoricalAnalysisData,
|
categoricalAnalysisData,
|
||||||
trendsAnalysisData,
|
trendsAnalysisData,
|
||||||
|
|||||||
Reference in New Issue
Block a user