frequi_origin/src/components/ftbot/DailyStats.vue

98 lines
2.2 KiB
Vue
Raw Normal View History

2020-05-17 18:43:19 +00:00
<template>
2020-05-22 18:04:27 +00:00
<div>
<div class="mb-2">
<label class="mr-auto h3">Daily Stats</label>
2020-07-02 18:05:20 +00:00
<b-button class="float-right" size="sm" @click="getDaily">&#x21bb;</b-button>
</div>
2020-05-22 18:04:27 +00:00
<div>
2020-06-04 18:06:58 +00:00
<b-table class="table-sm" :items="dailyStats.data" :fields="dailyFields"> </b-table>
</div>
2020-06-11 18:24:17 +00:00
<div>
<v-chart :options="dailyChart" />
</div>
2020-05-17 18:43:19 +00:00
</div>
</template>
<script>
import { mapActions, mapState } from 'vuex';
2020-06-11 18:24:17 +00:00
import ECharts from 'vue-echarts';
import 'echarts/lib/chart/bar';
import 'echarts/lib/chart/line';
2020-05-17 18:43:19 +00:00
export default {
name: 'DailyStats',
2020-06-11 18:24:17 +00:00
components: {
'v-chart': ECharts,
},
2020-05-17 18:43:19 +00:00
computed: {
...mapState('ftbot', ['dailyStats']),
2020-06-04 18:06:58 +00:00
dailyFields() {
2020-05-17 18:43:19 +00:00
return [
{ key: 'date', label: 'Day' },
{ key: 'abs_profit', label: 'Profit' },
{ key: 'fiat_value', label: `In ${this.dailyStats.fiat_display_currency}` },
{ key: 'trade_count', label: 'Trades' },
];
},
2020-06-11 18:24:17 +00:00
dailyChart() {
return {
title: {
text: 'Hello world',
},
dataset: {
dimensions: ['date', 'abs_profit', 'trade_count'],
source: this.dailyStats.data,
},
xAxis: {
type: 'category',
inverse: true,
},
yAxis: [
{
type: 'value',
name: 'Absolute Profit',
splitLine: {
show: false,
},
nameRotate: 90,
nameLocation: 'middle',
nameGap: 30,
},
{
type: 'value',
name: 'Trade count',
nameRotate: 90,
nameLocation: 'middle',
nameGap: 30,
},
],
series: [
{
type: 'line',
name: 'Absolute profit',
},
{
type: 'bar',
name: 'trade_count',
yAxisIndex: 1,
},
],
};
},
2020-05-17 18:43:19 +00:00
},
methods: {
...mapActions('ftbot', ['getDaily']),
2020-06-11 18:24:17 +00:00
dailyChartData() {
const arr = this.dailyStats.data.map((itm) => {
return { name: itm.date, value: Number(itm.abs_profit) + 2 };
});
console.log(arr);
return arr;
},
2020-05-17 18:43:19 +00:00
},
mounted() {
this.getDaily();
},
};
</script>