-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathstock-market.mjs
77 lines (76 loc) · 2.24 KB
/
stock-market.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import VueChartist from 'https://cdn.skypack.dev/v-chartist'
import { Grid } from '../../dist/main.esm.js'
export default {
name: 'StockMarket',
components: {
Grid
},
data() {
return {
sort: true,
columns: [
'Symbol',
'Last price',
{
name: 'Difference',
formatter: cell => {
return this.$gridjs.helper({
data() {
return {
content: cell
}
},
computed: {
status() {
return `color: ${this.content > 0 ? 'green' : 'red'};`
}
},
template: `<strong :style="status">{{ content }}</strong>`
})
}
},
{
name: 'Trend',
sort: false,
width: '100px',
formatter: cell => {
const chart = {
components: {
VueChartist
},
data() {
return {
data: { series: [cell] },
options: {
height: '30px',
showPoint: false,
fullWidth: true,
chartPadding: { top: 0, right: 0, bottom: 0, left: 0 },
axisX: { showGrid: false, showLabel: false, offset: 0 },
axisY: { showGrid: false, showLabel: false, offset: 0 }
}
}
},
template: `
<div>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/chartist.min.css"/>
<vue-chartist :data="data" :options="options" type="Line"></vue-chartist>
</div>
`
}
return this.$gridjs.helper(chart)
}
}
],
rows: [
['AAPL', 360.2, 20.19, [360, 363, 366, 361, 366, 350, 370]],
['ETSY', 102.1, 8.22, [90, 91, 92, 90, 94, 95, 99, 102]],
['AMZN', 2734.8, -30.01, [2779, 2786, 2792, 2780, 2750, 2765, 2740, 2734]],
['TSLA', 960.85, -40.91, [993, 990, 985, 983, 970, 985, 988, 960]]
]
}
},
template: `
<div><grid :columns="columns" :rows="rows" :sort="sort"></grid></div>
`
}