Skip to content

Commit

Permalink
GChart
Browse files Browse the repository at this point in the history
  • Loading branch information
RaBa64 committed May 21, 2023
1 parent 7133a4b commit de9d471
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js">
google.charts.load('current', { packages: ['corechart', 'bar'] });
</script>
<title>OpenDTU</title>
</head>
<body>
Expand Down
14 changes: 7 additions & 7 deletions webapp/src/components/DatabaseChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ export default defineComponent({
fetch("/api/database", { headers: authHeader() })
.then((response) => handleResponse(response, this.$emitter, this.$router))
.then((energy) => {
var end = new Date()
var start = new Date()
var interval = 1
start.setDate(end.getDate() - interval)
start.setHours(start.getHours() - 1)
google.charts.setOnLoadCallback(drawBasic());
function drawBasic() {
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Time');
Expand Down Expand Up @@ -67,6 +60,13 @@ export default defineComponent({
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
var end = new Date()
var start = new Date()
var interval = 1 // number of days to show in the chart
start.setDate(end.getDate() - interval)
start.setHours(start.getHours() - 1)
google.charts.setOnLoadCallback(drawBasic());
});
}
}
Expand Down

0 comments on commit de9d471

Please sign in to comment.