parent
d68baeae61
commit
88dd8b7936
@ -1,15 +1,15 @@
|
||||
<h1> Data </h1>
|
||||
<div id="app">
|
||||
<div style="height: 100px; width: 100%">
|
||||
<svg viewBox="0 0 100 100" style="height: 100%; width: 100%">
|
||||
<polygon
|
||||
v-bind:points="temperatureData">
|
||||
</polygon>
|
||||
</svg>
|
||||
<div class="panelContainer">
|
||||
<div class="panel" style="width: 50%">
|
||||
<span class="title">
|
||||
Title
|
||||
</span>
|
||||
<canvas class="graph">
|
||||
|
||||
</canvas>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/data.js" type="text/javascript">
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
setTitle('Data')
|
||||
</script>
|
||||
<script src="/data.js" type="text/javascript">
|
||||
</script>
|
@ -1,28 +1,4 @@
|
||||
function getFormattedData(dataArray) {
|
||||
let arrData = ["0,100"];
|
||||
for (let d of dataArray) {
|
||||
arrData.push(d[0]+","+(100-d[1]));
|
||||
}
|
||||
arrData.push("100,100");
|
||||
return arrData.join(" ");
|
||||
}
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
temperatureData: [1,2,3,4],
|
||||
percentData: [2,3,4,5],
|
||||
labels: ["1", "2", "3", "4", "5"],
|
||||
chartOptions: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let self = this;
|
||||
$.getJSON('cpu.json', d => {
|
||||
self.temperatureData = getFormattedData(d['100temp']),
|
||||
self.percentData = getFormattedData(d['100perc'])
|
||||
})
|
||||
}
|
||||
})
|
||||
$.getJSON('cpu.json', data =>{
|
||||
let c = document.querySelector('.graph');
|
||||
drawGraph(c, data['100temp'], {yMax: 50, yMin: "0"});
|
||||
});
|
Loading…
Reference in New Issue