Ox.Chart: fix sort regressions
This commit is contained in:
parent
4f37ff8783
commit
e9668823e3
1 changed files with 16 additions and 10 deletions
26
source/Ox.UI/js/List/Chart.js
vendored
26
source/Ox.UI/js/List/Chart.js
vendored
|
@ -92,18 +92,24 @@ Ox.Chart = function(options, self) {
|
|||
}
|
||||
|
||||
self.items = self.keys.map(function(key) {
|
||||
var 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') {
|
||||
sort = Ox.pad(value, 64) + sort;
|
||||
}
|
||||
return {key: key, value: value, sort: sort};
|
||||
return {
|
||||
key: key,
|
||||
keySort: self.sort[key],
|
||||
value: self.options.data[key],
|
||||
valueSort: self.subData ? self.totals[key] : self.options.data[key]
|
||||
};
|
||||
});
|
||||
self.sortBy = self.options.sort.key == 'key'
|
||||
? [
|
||||
{key: 'keySort', operator: self.options.sort.operator}
|
||||
]
|
||||
: [
|
||||
{key: 'valueSort', operator: self.options.sort.operator},
|
||||
{key: 'keySort', operator: '+'}
|
||||
]
|
||||
if (self.options.limit) {
|
||||
self.items = Ox.sortBy(
|
||||
self.items, {key: 'sort', operator: '+'}
|
||||
self.items, self.sortBy
|
||||
).slice(0, self.options.limit);
|
||||
self.max = Ox.max(self.items.map(function(item) {
|
||||
return self.subData ? Ox.sum(item.value) : item.value;
|
||||
|
@ -176,7 +182,7 @@ Ox.Chart = function(options, self) {
|
|||
max: 0,
|
||||
min: 0,
|
||||
pageLength: self.items.length,
|
||||
sort: [{key: 'sort', operator: '+'}],
|
||||
sort: self.sortBy,
|
||||
width: self.options.width,
|
||||
unique: 'key'
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue