Skip to content

Commit 0db55ef

Browse files
authored
Merge pull request #4789 from Countly/SER-1031
basechart: sort values by index in tooltip
2 parents 109ca75 + 9ad9567 commit 0db55ef

File tree

1 file changed

+20
-8
lines changed
  • frontend/express/public/javascripts/countly/vue/components

1 file changed

+20
-8
lines changed

frontend/express/public/javascripts/countly/vue/components/vis.js

+20-8
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,11 @@
539539
noEmpty: {
540540
type: Boolean,
541541
default: false
542+
},
543+
sortBy: {
544+
type: String,
545+
default: "value",
546+
required: false
542547
}
543548
},
544549
data: function() {
@@ -638,14 +643,21 @@
638643
template += "<span class='chart-tooltip__header text-smaller font-weight-bold'>" + params[0].axisValueLabel + "</span></br>";
639644
}
640645

641-
params.sort(function(a, b) {
642-
if (typeof a.value === 'object') {
643-
return b.value[1] - a.value[1];
644-
}
645-
else {
646-
return b.value - a.value;
647-
}
648-
});
646+
if (self.sortBy === "index") {
647+
params.sort(function(a, b) {
648+
return a.seriesIndex - b.seriesIndex;
649+
});
650+
}
651+
else {
652+
params.sort(function(a, b) {
653+
if (typeof a.value === 'object') {
654+
return b.value[1] - a.value[1];
655+
}
656+
else {
657+
return b.value - a.value;
658+
}
659+
});
660+
}
649661

650662
for (var i = 0; i < params.length; i++) {
651663
if (params[i].seriesName.toLowerCase() === 'duration' || params[i].seriesName.toLowerCase() === 'avg. duration') {

0 commit comments

Comments
 (0)