Skip to content
Snippets Groups Projects
Commit d3aaecf3 authored by Philipp Hochkamp's avatar Philipp Hochkamp
Browse files

Merge branch 'make-chart-tooltips-nicer' into 'master'

made chart tooltips nicer

See merge request !19
parents 7d7d3bca f79e06ce
No related branches found
No related tags found
1 merge request!19made chart tooltips nicer
Pipeline #1829 passed with warnings
......@@ -11,7 +11,8 @@ var chart;
type: "time",
time: {
unit: "minute",
max: Date.now()
max: Date.now(),
tooltipFormat: "dd HH:mm:ss"
}
}
],
......@@ -32,6 +33,19 @@ var chart;
legend: {
display: false
},
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
console.log(tooltipItem.datasetIndex);
dataset = data.datasets[tooltipItem.datasetIndex];
datapoint = dataset.data[tooltipItem.index];
challName = datapoint.tooltipLabel;
userName = dataset.label;
points = datapoint.y;
return userName + ': ' + challName + ' ('+points+')';
}
}
},
mantainAspectRatio: false,
responsive: true,
showScale: false
......
......@@ -91,7 +91,7 @@ func generateTableData() (tableData, error) {
func updateScoreboard() error {
type chartDataPoint struct {
T string `json:"t"`
// Label string `json:"label"`
Label string `json:"tooltipLabel"`
Y int `json:"y"`
}
type chartData struct {
......@@ -120,7 +120,7 @@ func updateScoreboard() error {
return err
}
sum += chall.Points
data[i+1] = chartDataPoint{T: s.Created.Format(time.RFC3339), Y: sum} //, Label: s.ChallengeName}
data[i+1] = chartDataPoint{T: s.Created.Format(time.RFC3339), Y: sum, Label: s.ChallengeName}
}
a := fmt.Sprintf("#%X", crc32.ChecksumIEEE([]byte(u.DisplayName)))[0:7]
datas = append(datas, chartData{Pcolor: a, Color: a, Label: u.DisplayName, Data: data})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment