function brush() {
    const actives = [];
    // filter brushed extents
    svg.selectAll('.brush')
        .filter(function (d) {
            return d3.brushSelection(this);
        })
        .each(function (d) {
            actives.push({
                dimension: d,
                extent: d3.brushSelection(this)
            });
        });


    let isSelected = [];
    actives.forEach(function (active) {
        const dim = active.dimension;
        currentExtents[dim] = [y[dim].invert(active.extent[0]), y[dim].invert(active.extent[1])]
    });

    // set un-brushed foreground line disappear and update array of selected data
    foreground.style('display', function (d) {
        selected = actives.every(function (active) {
            const dim = active.dimension;
            return active.extent[0] <= y[dim](d[dim]) && y[dim](d[dim]) <= active.extent[1];
        });
        isSelected.push(selected);
        return selected ? null : 'none';
    });


    let checkbox = document.getElementById('checkboxScaling');
    console.log(checkbox.checked)

    if (checkbox.checked) {
        rescale(currentExtents, 0);
    }

    svg.selectAll("circle").classed("hidden", function (d) {
        selected = actives.every(function (active) {
            const dim = active.dimension;
            return active.extent[0] <= y[dim](d[dim]) && y[dim](d[dim]) <= active.extent[1];
        });
        return selected ? null : 'none';
    });

    // recompute distributions
    // filter selected data
    selectedData = allData.filter((d, ind) => isSelected[ind])

    //update densityValues
    updateDensityValues(selectedData)
    let areaGraph = svg.selectAll("g.density");
    areaGraph.selectAll("path").remove();
    areaGraph
        .selectAll("path")
        .data(densityValues)
        .enter().append("path")
        .attr("d", density_path)
}
// Handles a brush event, toggling the display of foreground lines.
Handles a brush event, toggling the display of foreground lines.
Handles a brush event toggling the display of foreground lines .
function brush() {
    const actives = [];
    svg.selectAll('.brush')
        .filter(function (d) {
            return d3.brushSelection(this);
        })
        .each(function (d) {
            actives.push({
                dimension: d,
                extent: d3.brushSelection(this)
            });
        });
    let isSelected = [];
    actives.forEach(function (active) {
        const dim = active.dimension;
        currentExtents[dim] = [y[dim].invert(active.extent[0]), y[dim].invert(active.extent[1])]
    });
    foreground.style('display', function (d) {
        selected = actives.every(function (active) {
            const dim = active.dimension;
            return active.extent[0] <= y[dim](d[dim]) && y[dim](d[dim]) <= active.extent[1];
        });
        isSelected.push(selected);
        return selected ? null : 'none';
    });
    let checkbox = document.getElementById('checkboxScaling');
    console.log(checkbox.checked)
    if (checkbox.checked) {
        rescale(currentExtents, 0);
    }
    svg.selectAll("circle").classed("hidden", function (d) {
        selected = actives.every(function (active) {
            const dim = active.dimension;
            return active.extent[0] <= y[dim](d[dim]) && y[dim](d[dim]) <= active.extent[1];
        });
        return selected ? null : 'none';
    });
    selectedData = allData.filter((d, ind) => isSelected[ind])
    updateDensityValues(selectedData)
    let areaGraph = svg.selectAll("g.density");
    areaGraph.selectAll("path").remove();
    areaGraph
        .selectAll("path")
        .data(densityValues)
        .enter().append("path")
        .attr("d", density_path)
}
function brush ( ) { const actives = [ ] ; svg . selectAll ( '.brush' ) . filter ( function ( d ) { return d3 . brushSelection ( this ) ; } ) . each ( function ( d ) { actives . push ( { dimension : d , extent : d3 . brushSelection ( this ) } ) ; } ) ; let isSelected = [ ] ; actives . forEach ( function ( active ) { const dim = active . dimension ; currentExtents [ dim ] = [ y [ dim ] . invert ( active . extent [ 0 ] ) , y [ dim ] . invert ( active . extent [ 1 ] ) ] } ) ; foreground . style ( 'display' , function ( d ) { selected = actives . every ( function ( active ) { const dim = active . dimension ; return active . extent [ 0 ] <= y [ dim ] ( d [ dim ] ) && y [ dim ] ( d [ dim ] ) <= active . extent [ 1 ] ; } ) ; isSelected . push ( selected ) ; return selected ? null : 'none' ; } ) ; let checkbox = document . getElementById ( 'checkboxScaling' ) ; console . log ( checkbox . checked ) if ( checkbox . checked ) { rescale ( currentExtents , 0 ) ; } svg . selectAll ( "circle" ) . classed ( "hidden" , function ( d ) { selected = actives . every ( function ( active ) { const dim = active . dimension ; return active . extent [ 0 ] <= y [ dim ] ( d [ dim ] ) && y [ dim ] ( d [ dim ] ) <= active . extent [ 1 ] ; } ) ; return selected ? null : 'none' ; } ) ; selectedData = allData . filter ( ( d , ind ) => isSelected [ ind ] ) updateDensityValues ( selectedData ) let areaGraph = svg . selectAll ( "g.density" ) ; areaGraph . selectAll ( "path" ) . remove ( ) ; areaGraph . selectAll ( "path" ) . data ( densityValues ) . enter ( ) . append ( "path" ) . attr ( "d" , density_path ) }
Handles a brush event, toggling the display of foreground lines.
Handles a brush event toggling the display of foreground lines .
// filter brushed extents // set un-brushed foreground line disappear and update array of selected data // recompute distributions // filter selected data //update densityValues