Skip to content

Commit 3911aa3

Browse files
committed
added trendline, error when no data found
1 parent 2a8fda7 commit 3911aa3

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

public/js/account.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ var resultHistoryChart = new Chart($(".pageAccount #resultHistoryChart"), {
142142
// lineStyle: "solid",
143143
// width: 1
144144
// }
145+
trendlineLinear: {
146+
style: "rgba(255,105,180, .8)",
147+
lineStyle: "dotted",
148+
width: 2
149+
}
145150
},
146151
],
147152
},
@@ -237,7 +242,7 @@ var resultHistoryChart = new Chart($(".pageAccount #resultHistoryChart"), {
237242
labelString: 'Words per Minute'
238243
}
239244
}]
240-
}
245+
},
241246
}
242247
});
243248

@@ -465,9 +470,24 @@ function refreshAccountPage() {
465470
resultHistoryChart.options.scales.yAxes[0].ticks.minor.fontColor = subColor;
466471
resultHistoryChart.data.datasets[0].borderColor = mainColor;
467472
resultHistoryChart.options.legend.labels.fontColor = subColor;
473+
resultHistoryChart.data.datasets[0].trendlineLinear.style = subColor;
468474

469475
resultHistoryChart.data.datasets[0].data = chartData;
470476

477+
if(chartData == [] || chartData.length == 0){
478+
$(".pageAccount .group.noDataError").removeClass('hidden');
479+
$(".pageAccount .group.chart").addClass('hidden');
480+
$(".pageAccount .group.history").addClass('hidden');
481+
$(".pageAccount .triplegroup.stats").addClass('hidden');
482+
}else{
483+
$(".pageAccount .group.noDataError").addClass('hidden');
484+
$(".pageAccount .group.chart").removeClass('hidden');
485+
$(".pageAccount .group.history").removeClass('hidden');
486+
$(".pageAccount .triplegroup.stats").removeClass('hidden');
487+
}
488+
489+
490+
471491
$(".pageAccount .highestWpm .val").text(topWpm);
472492
$(".pageAccount .averageWpm .val").text(Math.round(totalWpm/testCount));
473493
$(".pageAccount .averageWpm10 .val").text(Math.round(wpmLast10total/wpmLast10count));
@@ -511,6 +531,11 @@ function refreshAccountPage() {
511531
// $(".pageAccount .favouriteTest .val").text(`${favModeName} (${Math.floor((favMode.length/testCount) * 100)}%)`);
512532
// }
513533

534+
if(resultHistoryChart.data.datasets[0].length > 0){
535+
resultHistoryChart.options.plugins.trendlineLinear = true;
536+
}else{
537+
resultHistoryChart.options.plugins.trendlineLinear = false;
538+
}
514539

515540
resultHistoryChart.update({duration: 0});
516541

0 commit comments

Comments
 (0)