Ox.Chart: when sorting by value, descending, make sure sort order of tied items, by key, is ascending
This commit is contained in:
parent
2968d7b79a
commit
f7c531c5df
1 changed files with 7 additions and 5 deletions
12
source/Ox.UI/js/List/Chart.js
vendored
12
source/Ox.UI/js/List/Chart.js
vendored
|
@ -92,16 +92,18 @@ Ox.Chart = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.items = self.keys.map(function(key) {
|
self.items = self.keys.map(function(key) {
|
||||||
var sort = self.sort[key],
|
var value = self.options.data[key],
|
||||||
value = self.options.data[key];
|
sort = self.options.sort.operator == '+'
|
||||||
|
? (self.subData ? self.totals[key] : value)
|
||||||
|
? (self.subData ? self.max - self.totals[key] : self.max - value);
|
||||||
if (self.options.sort.key == 'value') {
|
if (self.options.sort.key == 'value') {
|
||||||
sort = Ox.pad(self.subData ? self.totals[key] : value, 64) + sort;
|
sort = Ox.pad(value, 64) + sort;
|
||||||
}
|
}
|
||||||
return {key: key, value: value, sort: sort};
|
return {key: key, value: value, sort: sort};
|
||||||
});
|
});
|
||||||
if (self.options.limit) {
|
if (self.options.limit) {
|
||||||
self.items = Ox.sortBy(
|
self.items = Ox.sortBy(
|
||||||
self.items, {key: 'sort', operator: self.options.sort.operator}
|
self.items, {key: 'sort', operator: '+'}
|
||||||
).slice(0, self.options.limit);
|
).slice(0, self.options.limit);
|
||||||
self.max = Ox.max(self.items.map(function(item) {
|
self.max = Ox.max(self.items.map(function(item) {
|
||||||
return self.subData ? Ox.sum(item.value) : item.value;
|
return self.subData ? Ox.sum(item.value) : item.value;
|
||||||
|
@ -174,7 +176,7 @@ Ox.Chart = function(options, self) {
|
||||||
max: 0,
|
max: 0,
|
||||||
min: 0,
|
min: 0,
|
||||||
pageLength: self.items.length,
|
pageLength: self.items.length,
|
||||||
sort: [{key: 'sort', operator: self.options.sort.operator}],
|
sort: [{key: 'sort', operator: '+'}],
|
||||||
width: self.options.width,
|
width: self.options.width,
|
||||||
unique: 'key'
|
unique: 'key'
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue