js/table.js
/* Redraws the table when it has been sorted by name. */
Redraws the table when it has been sorted by name.
Redraws the table when it has been sorted by name .
redrawNames(that) {
        that.deleteTable();
        let sortedByNames = that.latestWeights.sort(function (a, b) {
            let returnValue = 0;
            if (that.nameSortDown) {
                if (a[1] > b[1]) {
                    returnValue = 1;
                }
                else {
                    returnValue = -1;
                }
            }
            else {
                if (b[1] > a[1]) {
                    returnValue = 1;
                }
                else {
                    returnValue = -1;
                }
            }
            return returnValue;
        });
        let countryRow = d3.select("#tableBody")
            .selectAll("tr")
            .data(sortedByNames)
            .enter()
            .append("tr")
            .classed("tableRow", true);
        countryRow.append("td")
            .text(function (d, i) {
                return d[1];
            })
            .on("click", d => that.selectCountryFromTuple(d, that))
            .classed("countryNameTd", true);
        countryRow.append("td").text(function (d, i) {
            return d[0]
        });
    }
redrawNames ( that ) { that . deleteTable ( ) ; let sortedByNames = that . latestWeights . sort ( function ( a , b ) { let returnValue = 0 ; if ( that . nameSortDown ) { if ( a [ 1 ] > b [ 1 ] ) { returnValue = 1 ; } else { returnValue = - 1 ; } } else { if ( b [ 1 ] > a [ 1 ] ) { returnValue = 1 ; } else { returnValue = - 1 ; } } return returnValue ; } ) ; let countryRow = d3 . select ( "#tableBody" ) . selectAll ( "tr" ) . data ( sortedByNames ) . enter ( ) . append ( "tr" ) . classed ( "tableRow" , true ) ; countryRow . append ( "td" ) . text ( function ( d , i ) { return d [ 1 ] ; } ) . on ( "click" , d => that . selectCountryFromTuple ( d , that ) ) . classed ( "countryNameTd" , true ) ; countryRow . append ( "td" ) . text ( function ( d , i ) { return d [ 0 ] } ) ; }
Redraws the table when it has been sorted by name.
Redraws the table when it has been sorted by name .