diff --git a/src/components/charts/BalanceChart.vue b/src/components/charts/BalanceChart.vue index 68c9b20e..c4e0df74 100644 --- a/src/components/charts/BalanceChart.vue +++ b/src/components/charts/BalanceChart.vue @@ -22,7 +22,7 @@ import { TooltipComponent, } from 'echarts/components'; -import { BalanceRecords } from '@/types'; +import { BalanceValues } from '@/types'; import { formatPriceCurrency } from '@/shared/formatters'; import { computed } from 'vue'; import { useSettingsStore } from '@/stores/settings'; @@ -38,7 +38,7 @@ use([ ]); const props = defineProps({ - currencies: { required: true, type: Array as () => BalanceRecords[] }, + currencies: { required: true, type: Array as () => BalanceValues[] }, showTitle: { required: false, type: Boolean }, }); const settingsStore = useSettingsStore(); @@ -53,16 +53,7 @@ const balanceChartOptions = computed((): EChartsOption => { backgroundColor: 'rgba(0, 0, 0, 0)', dataset: { dimensions: ['balance', 'currency', 'est_stake', 'free', 'used', 'stake'], - source: props.currencies.map((currency) => { - return { - balance: currency.balance, - currency: currency.currency, - est_stake: currency.est_stake, - free: currency.free, - used: currency.used, - stake: currency.stake, - }; - }), + source: props.currencies, }, tooltip: { trigger: 'item', diff --git a/src/components/ftbot/BotBalance.vue b/src/components/ftbot/BotBalance.vue index 8c0c9924..f0e41622 100644 --- a/src/components/ftbot/BotBalance.vue +++ b/src/components/ftbot/BotBalance.vue @@ -26,7 +26,7 @@ > - +

{{ botStore.activeBot.balance.note }} @@ -67,6 +67,7 @@ import { formatPercent, formatPrice } from '@/shared/formatters'; import { computed, ref } from 'vue'; import { useBotStore } from '@/stores/ftbotwrapper'; import { TableField } from 'bootstrap-vue-next'; +import { BalanceValues } from '@/types'; const botStore = useBotStore(); const hideSmallBalances = ref(true); @@ -92,6 +93,20 @@ const formatCurrency = (value) => { return value ? formatPrice(value, botStore.activeBot.stakeCurrencyDecimals) : ''; }; +const chartValues = computed(() => { + return balanceCurrencies.value?.map((v) => { + return { + balance: v.balance, + currency: v.currency, + est_stake: + showBotOnly.value && canUseBotBalance.value ? v.est_stake_bot ?? v.est_stake : v.est_stake, + free: showBotOnly.value && canUseBotBalance.value ? v.bot_owned ?? v.free : v.free, + used: v.used, + stake: v.stake, + }; + }); +}); + const tableFields = computed(() => { return [ { key: 'currency', label: 'Currency' }, diff --git a/src/types/balance.ts b/src/types/balance.ts index 8679744f..38164366 100644 --- a/src/types/balance.ts +++ b/src/types/balance.ts @@ -41,3 +41,13 @@ export interface BalanceInterface { starting_capital_fiat_ratio: number; starting_capital_fiat_pct: number; } + +export interface BalanceValues { + [key: string]: number | string; + balance: number; + currency: string; + est_stake: number; + free: number; + used: number; + stake: string; +}