feat: add colored diff % on table

Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
This commit is contained in:
Ameya Shenoy 2021-02-13 03:48:10 +05:30
parent 2b9bfd1ddb
commit d921cf521f
Signed by: codingcoffee
GPG key ID: F7D58AAC5DACF8D3
2 changed files with 14 additions and 1 deletions

View file

@ -1,6 +1,5 @@
import axios from 'axios'
// TODO: fix baseurl as per builds
const getAPI = axios.create({
baseURL: 'http://localhost:8000',
timeout: 60000,

View file

@ -99,6 +99,14 @@
>
<template v-slot:top>
</template>
<template v-slot:item.diff_percent="{ item }">
<v-chip
:color="getColor(item)"
outlined
>
{{ +parseFloat(( item.close_price - item.open_price ) * 100 / item.open_price).toFixed(2) }}
</v-chip>
</template>
</v-data-table>
</div>
</template>
@ -108,6 +116,11 @@
export default {
name: 'BhavStock',
methods: {
getColor (stock) {
if (stock.close_price > stock.open_price) return 'green'
else if (stock.close_price == stock.open_price) return 'black'
else return 'red'
},
downloadcsv() {
var table_data = this.$refs["bhavCopyTable"];
var searchField = this.$refs["searchField"];
@ -203,6 +216,7 @@
{text: 'High', value: 'high_price'},
{text: 'Low', value: 'low_price'},
{text: 'Close', value: 'close_price'},
{ text: 'Diff (%)', value: 'diff_percent' },
{text: 'Last', value: 'last_price'},
{text: 'Previous Close', value: 'prevclose_price'},
{text: 'No. of Trades', value: 'no_trades'},