parallel-coordinates icon indicating copy to clipboard operation
parallel-coordinates copied to clipboard

Example slickgrid: sorting doesn't work properly

Open ibayer opened this issue 9 years ago • 1 comments

Hi, thanks for this awesome library! I just started playing around with the examples and have the impression that column sorting doesn't work properly for the slickgrid example.

Sort the fiber(g) column in increasing order works. bildschirmfoto vom 2016-09-07 10 26 37

Sort the fiber(g) column in decreasing order doesn't work. The selected top data point is clearly not the highes fiber(g) value in the plot. bildschirmfoto vom 2016-09-07 10 28 27

Any idea what goes wrong? I would really like to use this example. Any help to fix this would be very welcome.

Thanks

ibayer avatar Sep 07 '16 08:09 ibayer

The results are being sorted as strings, not as numbers. To fix, you could replace the comparer function in the example with

function convert_to_float(x) {
    var converted = parseFloat(x);
    return isNaN(converted) ? x : converted
}

function comparer(a, b) {
    var x = convert_to_float(a[sortcol]), y = convert_to_float(b[sortcol]);
    return (x == y ? 0 : (x > y ? 1 : -1));
}

jeffhussmann avatar Apr 25 '17 19:04 jeffhussmann