syntagmatic / parallel-coordinates

A d3-based parallel coordinates plot in canvas. This library is no longer actively developed.
http://syntagmatic.github.com/parallel-coordinates/
Other
511 stars 212 forks source link

Example slickgrid: sorting doesn't work properly #324

Open ibayer opened 7 years ago

ibayer commented 7 years ago

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

jeffhussmann commented 7 years ago

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));
}