Skip to content

Commit 1e20b96

Browse files
committed
fixed reload problem
1 parent 4699b7b commit 1e20b96

File tree

3 files changed

+45
-47
lines changed

3 files changed

+45
-47
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
timetracker.yaml
1010
timetrackerconf.yaml
1111
*.syso
12-
log.txt
12+
log.txt
13+
timetracker

internal/components/plots.templ

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,53 @@ templ debugImport() {
66
<div></div>
77
}
88

9-
var chartHandle = templ.NewOnceHandle()
109

1110
templ pieChart(projects []database.ProjectHours) {
1211
@templ.JSONScript("projectData", projects)
13-
@chartHandle.Once() {
14-
<script type="text/javascript">
15-
var chartDom = document.getElementById('piechart');
16-
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
17-
// dark mode
18-
var myChart = echarts.init(chartDom, 'dark');
19-
} else {
20-
var myChart = echarts.init(chartDom);
21-
}
22-
var option;
23-
const importData = JSON.parse(document.getElementById('projectData').textContent);
24-
const dataArray = importData.slice(0,-1).map((project) => ({'value': parseFloat(project.workhours), 'name': project.name}))
25-
option = {
26-
backgroundColor: "transparent",
27-
title: {
28-
text: 'Projects',
29-
left: 'center'
30-
},
31-
tooltip: {
32-
trigger: 'item'
33-
},
34-
dataset: [{source: dataArray}],
35-
series: [
36-
{
37-
type: 'pie',
38-
radius: '60%'
39-
},
40-
{
41-
name: 'Project Hours',
12+
<script type="text/javascript">
13+
var chartDom = document.getElementById('piechart');
14+
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
15+
// dark mode
16+
var myChart = echarts.init(chartDom, 'dark');
17+
} else {
18+
var myChart = echarts.init(chartDom);
19+
}
20+
var option;
21+
var importData = JSON.parse(document.getElementById('projectData').textContent);
22+
var dataArray = importData.slice(0,-1).map((project) => ({'value': parseFloat(project.workhours), 'name': project.name}))
23+
option = {
24+
backgroundColor: "transparent",
25+
title: {
26+
text: 'Projects',
27+
left: 'center'
28+
},
29+
tooltip: {
30+
trigger: 'item'
31+
},
32+
dataset: [{source: dataArray}],
33+
series: [
34+
{
4235
type: 'pie',
43-
radius: '60%',
44-
label: {position: 'inside', formatter: '{d}%', color:'black', fontSize:18},
45-
percentPrecision: 0,
46-
emphasis: {
47-
label: {show: true},
48-
itemStyle: {
49-
shadowBlur: 10,
50-
shadowOffsetX: 0,
51-
shadowColor: 'rgba(0, 0, 0, 0.5)'
52-
}
53-
}
36+
radius: '60%'
37+
},
38+
{
39+
name: 'Project Hours',
40+
type: 'pie',
41+
radius: '60%',
42+
label: {position: 'inside', formatter: '{d}%', color:'black', fontSize:18},
43+
percentPrecision: 0,
44+
emphasis: {
45+
label: {show: true},
46+
itemStyle: {
47+
shadowBlur: 10,
48+
shadowOffsetX: 0,
49+
shadowColor: 'rgba(0, 0, 0, 0.5)'
5450
}
55-
]
56-
};
51+
}
52+
}
53+
]
54+
};
5755

58-
option && myChart.setOption(option);
59-
</script>
60-
}
56+
option && myChart.setOption(option);
57+
</script>
6158
}

timetracker

-15.2 MB
Binary file not shown.

0 commit comments

Comments
 (0)