-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.vue
150 lines (138 loc) · 3.71 KB
/
App.vue
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<template>
<div id="app" ref="app">
<vue-plotly
id="chart"
ref="plotly"
:data="pdata"
:layout="layout"
:options="options"
:autoResize="true"
@hover="layout.title='hovering on plotly'"
/>
<dat-gui closeText="Close controls" openText="Open controls" closePosition="bottom">
<dat-string v-model="layout.title" label="Title" />
<dat-button @click="plot()" label="Trigger alert"/>
<dat-string v-model="url" label="Load CSV" />
<dat-button v-for="item in items" v-bind:key="item" v-bind:label="item" @click="plot(item)"/>
</dat-gui>
<button
id="external-button"
@mouseover="hoverd()"
@click="calculateWidth()"
>Resize Plot</button>
<h3>title: {{layout.title}}</h3>
<h3>y array: {{pdata[0].y}}</h3>
<h3>{{loadURL}}</h3>
<div :testy="testy">gg{{testy}}</div>
<contact-info
:email-address="emailAddress"
:twitter-handle="twitterHandle"
:instagram="instagram"
/>
</div>
</template>
<script>
import VuePlotly from "@statnett/vue-plotly";
import Vue from "vue";
import DatGui from "@cyrilf/vue-dat-gui";
import ContactInfo from "./contact_info";
import CsvManager from "./csv_manager";
var csv = new CsvManager();
window.VuePlotly = VuePlotly;
Vue.use(DatGui);
var hi = "hi";
var exx = {
name: "app",
components: { VuePlotly, ContactInfo },
props: ["testy"],
data: function() {
return {
items: ['first', 'second', 'third'],
pdata: [{ x: ['1', '2', '3', '4'], y: [10, 25, 20, 50], type: 'scatter' }],
layout: {
title: "edit this title"
},
autoResize: true,
options: {},
url:
"https://mapcore-bucket1.s3-us-west-2.amazonaws.com/ISAN/csv-data/stellate/sample_2/cell_1/18525003_channel_1.csv",
emailAddress: "jessekhorasanee@gmail.com",
twitterHandle: "tehsurfer",
instagram: "khorasanee"
};
},
computed: {
loadURL: function() {
csv.loadFile(this.url).then(_ => {
this.pdata[0].x = csv.getColoumnByIndex(0).shift();
this.pdata[0].y = csv.getColoumnByIndex(1).shift();
this.pdata[0].type = csv.getDataType()
this.items = csv.getHeaders();
});
},
initialiseResizeListener: function(resizeObject) {
resizeObject.addEventListener("resize", _ => {
VuePlotly.relayout(chartDiv, {
width: resizeObject.innerWidth,
height: resizeObject.innerHeight + 150
});
});
},
},
methods: {
hoverd: function() {
this.layout.title = "We are hovering!!"
},
plot: function(channel){
this.layout.title = channel
console.log(this.pdata)
window.pdata = this.pdata
this.pdata[0].y = csv.getColoumnByName(channel)
},
calculateWidth: function (){
this.layout.title = this.$refs.app.clientWidth
this.$refs.plotly.relayout({width: this.$refs.app.clientWidth, })
window.reeefs = this.$refs
},
handleResize: function (){
this.layout.title = this.$refs.app.clientWidth
this.$refs.plotly.relayout({width: this.$refs.app.clientWidth, })
window.reeefs = this.$refs
}
},
created() {
window.addEventListener('resize', this.handleResize)
this.handleResize();
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
};
window.exx = exx;
export default exx;
</script>
<style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
h1,
h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>