use for-of statements to replace for and for-in

This commit is contained in:
MaysWind
2025-09-14 01:40:53 +08:00
parent 67bc81d3e2
commit 4700446ca0
38 changed files with 389 additions and 597 deletions
@@ -69,9 +69,7 @@ export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTren
let minUnixTimeClosingBalance = 0;
let maxUnixTimeClosingBalance = 0;
for (let i = 0; i < props.items.length; i++) {
const item = props.items[i];
for (const item of props.items) {
if (item.time < minUnixTime) {
minUnixTime = item.time;
minUnixTimeOpeningBalance = item.accountOpeningBalance;
@@ -120,8 +118,7 @@ export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTren
const dayDataItemsMap: Record<number, TransactionReconciliationStatementResponseItem[]> = {};
for (let i = 0; i < props.items.length; i++) {
const dateItem = props.items[i];
for (const dateItem of props.items) {
let dateRangeMinUnixTime = 0;
if (props.dateAggregationType === ChartDateAggregationType.Year.type) {
@@ -149,8 +146,7 @@ export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTren
let lastMedianBalance = lastClosingBalance;
let lastAverageBalance = lastClosingBalance;
for (let i = 0; i < allDateRanges.value.length; i++) {
const dateRange = allDateRanges.value[i];
for (const dateRange of allDateRanges.value) {
const dataItems = dayDataItemsMap[dateRange.minUnixTime];
let displayDate = '';
@@ -176,11 +172,11 @@ export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTren
return data1.time - data2.time;
});
const openingBalance = dataItems[0].accountOpeningBalance;
const closingBalance = dataItems[dataItems.length - 1].accountClosingBalance;
const openingBalance = dataItems[0]!.accountOpeningBalance;
const closingBalance = dataItems[dataItems.length - 1]!.accountClosingBalance;
const minimumBalance = Math.min(...dataItems.map(item => item.accountClosingBalance));
const maximumBalance = Math.max(...dataItems.map(item => item.accountClosingBalance));
const medianBalance = dataItems[Math.floor(dataItems.length / 2)].accountClosingBalance;
const medianBalance = dataItems[Math.floor(dataItems.length / 2)]!.accountClosingBalance;
const averageBalance = Math.trunc(sumAmounts(dataItems.map(item => item.accountClosingBalance)) / dataItems.length);
if (props.account.isAsset) {
@@ -56,11 +56,11 @@ export function useDateRangeSelectionBase(props: CommonDateRangeSelectionProps)
const firstDayOfWeek = computed<WeekDayValue>(() => userStore.currentUserFirstDayOfWeek);
const beginDateTime = computed<string>(() => {
const actualBeginUnixTime = getActualUnixTimeForStore(getUnixTimeFromLocalDatetime(dateRange.value[0]), getTimezoneOffsetMinutes(), getBrowserTimezoneOffsetMinutes());
const actualBeginUnixTime = getActualUnixTimeForStore(getUnixTimeFromLocalDatetime(dateRange.value[0] as Date), getTimezoneOffsetMinutes(), getBrowserTimezoneOffsetMinutes());
return formatUnixTimeToLongDateTime(actualBeginUnixTime);
});
const endDateTime = computed<string>(() => {
const actualEndUnixTime = getActualUnixTimeForStore(getUnixTimeFromLocalDatetime(dateRange.value[1]), getTimezoneOffsetMinutes(), getBrowserTimezoneOffsetMinutes());
const actualEndUnixTime = getActualUnixTimeForStore(getUnixTimeFromLocalDatetime(dateRange.value[1] as Date), getTimezoneOffsetMinutes(), getBrowserTimezoneOffsetMinutes());
return formatUnixTimeToLongDateTime(actualEndUnixTime);
});
const presetRanges = computed<PresetDateRange[]>(() => {
+8 -4
View File
@@ -42,11 +42,13 @@ export function useItemIconBase(props: CommonIconProps) {
iconId = iconId.toString();
}
if (!ALL_ACCOUNT_ICONS[iconId]) {
const iconInfo = ALL_ACCOUNT_ICONS[iconId];
if (!iconInfo) {
return DEFAULT_ACCOUNT_ICON.icon;
}
return ALL_ACCOUNT_ICONS[iconId].icon;
return iconInfo.icon;
}
function getCategoryIcon(iconId: string | number): string {
@@ -54,11 +56,13 @@ export function useItemIconBase(props: CommonIconProps) {
iconId = iconId.toString();
}
if (!ALL_CATEGORY_ICONS[iconId]) {
const iconInfo = ALL_CATEGORY_ICONS[iconId];
if (!iconInfo) {
return DEFAULT_CATEGORY_ICON.icon;
}
return ALL_CATEGORY_ICONS[iconId].icon;
return iconInfo.icon;
}
function getAccountIconStyle(color?: ColorValue, defaultColor?: ColorStyleValue, additionalColorAttr?: string): Record<IconItemStyleName, IconItemStyleValue> {
@@ -57,8 +57,8 @@ export function useMonthRangeSelectionBase(props: CommonMonthRangeSelectionProps
maxDate
]);
const beginDateTime = computed<string>(() => formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthFirstUnixTime(dateRange.value[0])));
const endDateTime = computed<string>(() => formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthLastUnixTime(dateRange.value[1])));
const beginDateTime = computed<string>(() => formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthFirstUnixTime(dateRange.value[0] as Year0BasedMonth)));
const endDateTime = computed<string>(() => formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthLastUnixTime(dateRange.value[1] as Year0BasedMonth)));
function getFinalMonthRange(): { minYearMonth: TextualYearMonth | '', maxYearMonth: TextualYearMonth | '' } | null {
if (!dateRange.value[0] || !dateRange.value[1]) {
@@ -69,8 +69,8 @@ export function useMonthRangeSelectionBase(props: CommonMonthRangeSelectionProps
throw new Error('Date is too early');
}
const minYearMonth = getYearMonthStringFromYear0BasedMonthObject(dateRange.value[0]);
const maxYearMonth = getYearMonthStringFromYear0BasedMonthObject(dateRange.value[1]);
const minYearMonth = getYearMonthStringFromYear0BasedMonthObject(dateRange.value[0] as Year0BasedMonth);
const maxYearMonth = getYearMonthStringFromYear0BasedMonthObject(dateRange.value[1] as Year0BasedMonth);
return {
minYearMonth,
+1 -1
View File
@@ -146,7 +146,7 @@ function getDisplayYear(year: number): string {
function getDisplayMonth(month: number): string {
if (isArray(dateTime.value)) {
return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value[0].getFullYear(), month + 1, 1).getUnixTime(), actualNumeralSystem.value);
return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value[0]!.getFullYear(), month + 1, 1).getUnixTime(), actualNumeralSystem.value);
} else if (dateTime.value) {
return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value.getFullYear(), month + 1, 1).getUnixTime(), actualNumeralSystem.value);
} else {
+1 -1
View File
@@ -102,7 +102,7 @@ function getDisplayYear(year: number): string {
function getDisplayMonth(month: number): string {
if (isArray(dateTime.value)) {
return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value[0].year, month + 1, 1).getUnixTime());
return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value[0]!.year, month + 1, 1).getUnixTime());
} else {
return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value.year, month + 1, 1).getUnixTime());
}
@@ -8,11 +8,15 @@ import { useTheme } from 'vuetify';
import type { CallbackDataParams } from 'echarts/types/dist/shared';
import { useI18n } from '@/locales/helpers.ts';
import { type CommonAccountBalanceTrendsChartProps, useAccountBalanceTrendsChartBase } from '@/components/base/AccountBalanceTrendsChartBase.ts'
import {
type AccountBalanceTrendsChartItem,
type CommonAccountBalanceTrendsChartProps,
useAccountBalanceTrendsChartBase
} from '@/components/base/AccountBalanceTrendsChartBase.ts'
import { useUserStore } from '@/stores/user.ts';
import type { NameValue } from '@/core/base.ts';
import { type NameValue, itemAndIndex } from '@/core/base.ts';
import { TextDirection } from '@/core/text.ts';
import type { ColorStyleValue } from '@/core/color.ts';
import { ThemeType } from '@/core/theme.ts';
@@ -83,9 +87,7 @@ const allSeries = computed<AccountBalanceTrendsChartDataItem[]>(() => {
series.itemStyle.borderColor0 = expenseIncomeAmountColor.expenseAmountColor;
}
for (let i = 0; i < allDataItems.value.length; i++) {
const item = allDataItems.value[i];
for (const item of allDataItems.value) {
if (props.type === AccountBalanceTrendChartType.Candlestick.type) {
series.data.push([
item.openingBalance,
@@ -110,13 +112,12 @@ const yAxisWidth = computed<number>(() => {
return width;
}
for (let i = 0; i < allSeries.value.length; i++) {
for (let j = 0; j < allSeries.value[i].data.length; j++) {
const data = allSeries.value[i].data[j];
for (const series of allSeries.value) {
for (const data of series.data) {
let value: number;
if (isArray(data)) {
value = data[1]; // for candlestick, use closing balance
value = data[1] as number; // for candlestick, use closing balance
} else {
value = data as number; // for line or bar chart
}
@@ -172,8 +173,8 @@ const chartOptions = computed<object>(() => {
},
formatter: (params: CallbackDataParams[]) => {
if (props.type === AccountBalanceTrendChartType.Candlestick.type) {
const dataIndex = params[0].dataIndex;
const dataItem = allDataItems.value[dataIndex];
const dataIndex = params[0]!.dataIndex;
const dataItem = allDataItems.value[dataIndex] as AccountBalanceTrendsChartItem;
const displayItems: NameValue[] = [
{
name: tt('Opening Balance'),
@@ -201,20 +202,20 @@ const chartOptions = computed<object>(() => {
}
];
let tooltip = `${params[0].name} ${props.legendName}<br/>`;
let tooltip = `${params[0]!.name} ${props.legendName}<br/>`;
for (let i = 0; i < displayItems.length; i++) {
tooltip += `<div><span class="chart-pointer" style="background-color: #${DEFAULT_CHART_COLORS[i]}"></span>`
+ `<span>${displayItems[i].name}</span><span class="ms-5" style="float: inline-end">${displayItems[i].value}</span><br/>`
for (const [displayItem, index] of itemAndIndex(displayItems)) {
tooltip += `<div><span class="chart-pointer" style="background-color: #${DEFAULT_CHART_COLORS[index]}"></span>`
+ `<span>${displayItem.name}</span><span class="ms-5" style="float: inline-end">${displayItem.value}</span><br/>`
+ `</div>`;
}
return tooltip;
} else {
const amount = params[0].data as number;
const amount = params[0]!.data as number;
const value = formatAmountToLocalizedNumeralsWithCurrency(amount, props.account.currency);
return `${params[0].name}<br/>`
return `${params[0]!.name}<br/>`
+ '<div><span class="chart-pointer" style="background-color: #' + DEFAULT_CHART_COLORS[0] + '"></span>'
+ `<span>${props.legendName}</span><span class="ms-5" style="float: inline-end">${value}</span><br/>`
+ '</div>';
+27 -33
View File
@@ -14,6 +14,7 @@ import { type CommonMonthlyTrendsChartProps, type MonthlyTrendsBarChartClickEven
import { useUserStore } from '@/stores/user.ts';
import { itemAndIndex } from '@/core/base.ts';
import { TextDirection } from '@/core/text.ts';
import { type Year1BasedMonth, DateRangeScene } from '@/core/datetime.ts';
import type { ColorStyleValue } from '@/core/color.ts';
@@ -100,8 +101,7 @@ const isDarkMode = computed<boolean>(() => theme.global.name.value === ThemeType
const itemsMap = computed<Record<string, Record<string, unknown>>>(() => {
const map: Record<string, Record<string, unknown>> = {};
for (let i = 0; i < props.items.length; i++) {
const item = props.items[i];
for (const item of props.items) {
let id: string = '';
if (props.idField && item[props.idField]) {
@@ -135,9 +135,7 @@ const itemsMap = computed<Record<string, Record<string, unknown>>>(() => {
const allDisplayDateRanges = computed<string[]>(() => {
const allDisplayDateRanges: string[] = [];
for (let i = 0; i < allDateRanges.value.length; i++) {
const dateRange = allDateRanges.value[i];
for (const dateRange of allDateRanges.value) {
if (props.dateAggregationType === ChartDateAggregationType.Year.type) {
allDisplayDateRanges.push(formatUnixTimeToGregorianLikeShortYear(dateRange.minUnixTime));
} else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type && 'year' in dateRange) {
@@ -155,9 +153,7 @@ const allDisplayDateRanges = computed<string[]>(() => {
const allSeries = computed<MonthlyTrendsChartDataItem[]>(() => {
const allSeries: MonthlyTrendsChartDataItem[] = [];
for (let i = 0; i < props.items.length; i++) {
const item = props.items[i];
for (const [item, index] of itemAndIndex(props.items)) {
if (props.hiddenField && item[props.hiddenField]) {
continue;
}
@@ -165,8 +161,7 @@ const allSeries = computed<MonthlyTrendsChartDataItem[]>(() => {
const allAmounts: number[] = [];
const dateRangeAmountMap: Record<string, YearMonthDataItem[]> = {};
for (let j = 0; j < item.items.length; j++) {
const dataItem = item.items[j];
for (const dataItem of item.items) {
let dateRangeKey = '';
if (props.dateAggregationType === ChartDateAggregationType.Year.type) {
@@ -189,8 +184,7 @@ const allSeries = computed<MonthlyTrendsChartDataItem[]>(() => {
dateRangeAmountMap[dateRangeKey] = dataItems;
}
for (let j = 0; j < allDateRanges.value.length; j++) {
const dateRange = allDateRanges.value[j];
for (const dateRange of allDateRanges.value) {
let dateRangeKey = '';
if (props.dateAggregationType === ChartDateAggregationType.Year.type) {
@@ -207,9 +201,7 @@ const allSeries = computed<MonthlyTrendsChartDataItem[]>(() => {
const dataItems = dateRangeAmountMap[dateRangeKey];
if (isArray(dataItems)) {
for (let i = 0; i < dataItems.length; i++) {
const dataItem = dataItems[i];
for (const dataItem of dataItems) {
if (isNumber(dataItem[props.valueField])) {
amount += dataItem[props.valueField] as number;
}
@@ -223,7 +215,7 @@ const allSeries = computed<MonthlyTrendsChartDataItem[]>(() => {
id: (props.idField && item[props.idField]) ? item[props.idField] as string : getItemName(item[props.nameField] as string),
name: (props.idField && item[props.idField]) ? item[props.idField] as string : getItemName(item[props.nameField] as string),
itemStyle: {
color: getDisplayColor(props.colorField && item[props.colorField] ? item[props.colorField] as string : DEFAULT_CHART_COLORS[i % DEFAULT_CHART_COLORS.length]),
color: getDisplayColor(props.colorField && item[props.colorField] ? item[props.colorField] as string : DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length]),
},
selected: true,
type: 'line',
@@ -253,10 +245,9 @@ const yAxisWidth = computed<number>(() => {
return width;
}
for (let i = 0; i < allSeries.value.length; i++) {
for (let j = 0; j < allSeries.value[i].data.length; j++) {
const value = allSeries.value[i].data[j];
for (const series of allSeries.value) {
for (const value of series.data) {
if (value > maxValue) {
maxValue = value;
}
@@ -311,12 +302,12 @@ const chartOptions = computed<object>(() => {
let totalAmount = 0;
const displayItems: MonthlyTrendsChartTooltipItem[] = [];
for (let i = 0; i < params.length; i++) {
const id = params[i].seriesId as string;
for (const param of params) {
const id = param.seriesId as string;
const name = itemsMap.value[id] && props.nameField && itemsMap.value[id][props.nameField] ? getItemName(itemsMap.value[id][props.nameField] as string) : id;
const color = params[i].color;
const color = param.color;
const displayOrders = itemsMap.value[id] && props.displayOrdersField && itemsMap.value[id][props.displayOrdersField] ? itemsMap.value[id][props.displayOrdersField] as number[] : [0];
const amount = params[i].data as number;
const amount = param.data as number;
displayItems.push({
name: name,
@@ -330,9 +321,7 @@ const chartOptions = computed<object>(() => {
sortStatisticsItems(displayItems, props.sortingType);
for (let i = 0; i < displayItems.length; i++) {
const item = displayItems[i];
for (const item of displayItems) {
if (displayItems.length === 1 || item.totalAmount !== 0) {
const value = formatAmountToLocalizedNumeralsWithCurrency(item.totalAmount, props.defaultCurrency);
tooltip += '<div><span class="chart-pointer" style="background-color: ' + item.color + '"></span>';
@@ -349,7 +338,7 @@ const chartOptions = computed<object>(() => {
+ '</div>' + tooltip;
}
if (params.length && params[0].name) {
if (params.length && params[0] && params[0].name) {
tooltip = `${params[0].name}<br/>` + tooltip;
}
@@ -410,9 +399,14 @@ function clickItem(e: ECElementEvent): void {
}
const id = e.seriesId as string;
const item = itemsMap.value[id];
const item = itemsMap.value[id] as Record<string, unknown>;
const itemId = props.idField ? item[props.idField] as string : '';
const dateRange = allDateRanges.value[e.dataIndex];
if (!dateRange) {
return;
}
let minUnixTime = dateRange.minUnixTime;
let maxUnixTime = dateRange.maxUnixTime;
@@ -450,16 +444,16 @@ function exportData(): { headers: string[], data: string[][] } {
headers.push(tt('Date'));
for (let i = 0; i < allSeries.value.length; i++) {
const id = allSeries.value[i].id;
for (const series of allSeries.value) {
const id = series.id;
const name = itemsMap.value[id] && props.nameField && itemsMap.value[id][props.nameField] ? getItemName(itemsMap.value[id][props.nameField] as string) : id;
headers.push(name);
}
for (let i = 0; i < allDisplayDateRanges.value.length; i++) {
for (const [displayDateRange, index] of itemAndIndex(allDisplayDateRanges.value)) {
const row: string[] = [];
row.push(allDisplayDateRanges.value[i]);
row.push(...allSeries.value.map(item => formatAmountToWesternArabicNumeralsWithoutDigitGrouping(item.data[i])));
row.push(displayDateRange);
row.push(...allSeries.value.map(item => formatAmountToWesternArabicNumeralsWithoutDigitGrouping(item.data[index] ?? 0)));
data.push(row);
}
@@ -252,8 +252,8 @@ function getTimerPickerItemStyle(textualValue: string, textualCurrentValue: stri
return '';
}
const minValue = parseInt(values[0].value);
const maxValue = parseInt(values[values.length - 1].value);
const minValue = parseInt(values[0]!.value);
const maxValue = parseInt(values[values.length - 1]!.value);
const value = parseInt(textualValue, 10);
const currentValue = parseInt(textualCurrentValue, 10);
let valueDiff = value - currentValue;
@@ -327,7 +327,7 @@ function scrollToSelectedItem(itemsClass: string, itemClass: string, value: stri
}
for (let i = 0; i < itemElements.length; i++) {
const itemElement = itemElements[i];
const itemElement = itemElements[i] as HTMLElement;
if ('offsetHeight' in itemsElement && 'offsetTop' in itemElement && 'offsetHeight' in itemElement
&& (!itemElement.hasAttribute('data-items-index') || itemElement.getAttribute('data-items-index') === '1')
+15 -20
View File
@@ -95,6 +95,7 @@ import { type CommonMonthlyTrendsChartProps, type MonthlyTrendsBarChartClickEven
import { useUserStore } from '@/stores/user.ts';
import { itemAndIndex } from '@/core/base.ts';
import { type Year1BasedMonth, type UnixTimeRange, DateRangeScene } from '@/core/datetime.ts';
import type { ColorStyleValue } from '@/core/color.ts';
import { ChartDateAggregationType } from '@/core/statistics.ts';
@@ -173,9 +174,7 @@ const allDisplayDataItems = computed<MonthlyTrendsBarChartData>(() => {
const allDateRangeItemsMap: Record<string, MonthlyTrendsBarChartDataAmount[]> = {};
const legends: TrendsBarChartLegend[] = [];
for (let i = 0; i < props.items.length; i++) {
const item = props.items[i];
for (const [item, index] of itemAndIndex(props.items)) {
if (props.hiddenField && item[props.hiddenField]) {
continue;
}
@@ -185,7 +184,7 @@ const allDisplayDataItems = computed<MonthlyTrendsBarChartData>(() => {
const legend: TrendsBarChartLegend = {
id: id,
name: (props.nameField && item[props.nameField]) ? getItemName(item[props.nameField] as string) : id,
color: getDisplayColor(props.colorField && item[props.colorField] ? item[props.colorField] as string : DEFAULT_CHART_COLORS[i % DEFAULT_CHART_COLORS.length]),
color: getDisplayColor(props.colorField && item[props.colorField] ? item[props.colorField] as string : DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length]),
displayOrders: (props.displayOrdersField && item[props.displayOrdersField]) ? item[props.displayOrdersField] as number[] : [0]
};
@@ -197,8 +196,7 @@ const allDisplayDataItems = computed<MonthlyTrendsBarChartData>(() => {
const dateRangeItemMap: Record<string, MonthlyTrendsBarChartDataAmount> = {};
for (let j = 0; j < item.items.length; j++) {
const dataItem = item.items[j];
for (const dataItem of item.items) {
let dateRangeKey = '';
if (props.dateAggregationType === ChartDateAggregationType.Year.type) {
@@ -216,7 +214,7 @@ const allDisplayDataItems = computed<MonthlyTrendsBarChartData>(() => {
}
if (dateRangeItemMap[dateRangeKey]) {
dateRangeItemMap[dateRangeKey].totalAmount += (props.valueField && isNumber(dataItem[props.valueField])) ? dataItem[props.valueField] as number : 0;
dateRangeItemMap[dateRangeKey]!.totalAmount += (props.valueField && isNumber(dataItem[props.valueField])) ? dataItem[props.valueField] as number : 0;
} else {
const allDataItems: MonthlyTrendsBarChartDataAmount[] = allDateRangeItemsMap[dateRangeKey] || [];
const finalDataItem: MonthlyTrendsBarChartDataAmount = Object.assign({}, legend, {
@@ -233,8 +231,7 @@ const allDisplayDataItems = computed<MonthlyTrendsBarChartData>(() => {
const finalDataItems: MonthlyTrendsBarChartDataItem[] = [];
let maxTotalAmount = 0;
for (let i = 0; i < allDateRanges.value.length; i++) {
const dateRange = allDateRanges.value[i];
for (const dateRange of allDateRanges.value) {
let dateRangeKey = '';
if (props.dateAggregationType === ChartDateAggregationType.Year.type) {
@@ -265,12 +262,12 @@ const allDisplayDataItems = computed<MonthlyTrendsBarChartData>(() => {
sortStatisticsItems(dataItems, props.sortingType);
for (let j = 0; j < dataItems.length; j++) {
if (dataItems[j].totalAmount > 0) {
totalPositiveAmount += dataItems[j].totalAmount;
for (const dataItem of dataItems) {
if (dataItem.totalAmount > 0) {
totalPositiveAmount += dataItem.totalAmount;
}
totalAmount += dataItems[j].totalAmount;
totalAmount += dataItem.totalAmount;
}
if (totalAmount > maxTotalAmount) {
@@ -289,11 +286,11 @@ const allDisplayDataItems = computed<MonthlyTrendsBarChartData>(() => {
finalDataItems.push(finalDataItem);
}
for (let i = 0; i < finalDataItems.length; i++) {
if (maxTotalAmount > 0 && finalDataItems[i].totalAmount > 0) {
finalDataItems[i].percent = 100.0 * finalDataItems[i].totalAmount / maxTotalAmount;
for (const finalDataItem of finalDataItems) {
if (maxTotalAmount > 0 && finalDataItem.totalAmount > 0) {
finalDataItem.percent = 100.0 * finalDataItem.totalAmount / maxTotalAmount;
} else {
finalDataItems[i].percent = 0.0;
finalDataItem.percent = 0.0;
}
}
@@ -306,9 +303,7 @@ const allDisplayDataItems = computed<MonthlyTrendsBarChartData>(() => {
function clickItem(item: MonthlyTrendsBarChartDataItem): void {
let itemId = '';
for (let i = 0; i < props.items.length; i++) {
const item = props.items[i];
for (const item of props.items) {
if (!props.hiddenField || item[props.hiddenField]) {
continue;
}
@@ -143,8 +143,8 @@ const allTags = computed<TransactionTag[]>(() => {
const noAvailableTag = computed<boolean>(() => {
if (transactionTagsStore.allTransactionTags) {
for (let i = 0; i < transactionTagsStore.allTransactionTags.length; i++) {
if (!transactionTagsStore.allTransactionTags[i].hidden) {
for (const transactionTag of transactionTagsStore.allTransactionTags) {
if (!transactionTag.hidden) {
return false;
}
}