tangled
alpha
login
or
join now
dunkirk.sh
/
cachet
0
fork
atom
a cache for slack profile pictures and emojis
0
fork
atom
overview
issues
pulls
pipelines
feat: use adaptive log scale
dunkirk.sh
5 months ago
4b28cf19
4cf997bf
verified
This commit was signed with the committer's
known signature
.
dunkirk.sh
SSH Key Fingerprint:
SHA256:DqcG0RXYExE26KiWo3VxJnsxswN1QNfTBvB+bdSpk80=
+24
-3
1 changed file
expand all
collapse all
unified
split
src
dashboard.html
+24
-3
src/dashboard.html
···
676
676
}
677
677
});
678
678
679
679
+
// Calculate dynamic max for logarithmic scale
680
680
+
const responseTimes = data.map((d) => d.averageResponseTime);
681
681
+
const maxResponseTime = Math.max(...responseTimes);
682
682
+
683
683
+
// Calculate appropriate max for log scale (next power of 10)
684
684
+
const logMax = Math.pow(10, Math.ceil(Math.log10(maxResponseTime)));
685
685
+
686
686
+
// Generate dynamic tick values based on the data range
687
687
+
const generateLogTicks = (min, max) => {
688
688
+
const ticks = [];
689
689
+
let current = 1;
690
690
+
while (current <= max) {
691
691
+
ticks.push(current);
692
692
+
current *= 10;
693
693
+
}
694
694
+
return ticks;
695
695
+
};
696
696
+
697
697
+
const dynamicTicks = generateLogTicks(1, logMax);
698
698
+
679
699
charts.latency = new Chart(ctx, {
680
700
type: "line",
681
701
data: {
682
702
labels: labels,
683
703
datasets: [{
684
704
label: "Average Response Time",
685
685
-
data: data.map((d) => d.averageResponseTime),
705
705
+
data: responseTimes,
686
706
borderColor: "#10b981",
687
707
backgroundColor: "rgba(16, 185, 129, 0.1)",
688
708
tension: 0.4,
···
732
752
type: 'logarithmic',
733
753
title: { display: true, text: 'Response Time (ms, log scale)' },
734
754
min: 1,
755
755
+
max: logMax,
735
756
grid: { color: 'rgba(0, 0, 0, 0.05)' },
736
757
ticks: {
737
758
callback: function(value) {
738
738
-
// Show clean numbers: 1, 10, 100, 1000, etc.
739
739
-
if (value === 1 || value === 10 || value === 100 || value === 1000 || value === 10000) {
759
759
+
// Show clean numbers based on dynamic range
760
760
+
if (dynamicTicks.includes(value)) {
740
761
return value + 'ms';
741
762
}
742
763
return '';