assets/js/app.js
// function used for updating circles group with new tooltip for yAxis change
function used for updating circles group with new tooltip for yAxis change
function used for updating circles group with new tooltip for yAxis change
function updateYToolTip(chosenYAxis, circlesGroup, abbrGroup) {
    var ylabel;
    var xlabel = chosenXAxis;
    if (chosenYAxis === "healthcare") {
      ylabel = "Lacks Healthcare:";
    }
    else if (chosenYAxis === "obesity") {
      ylabel = "Obesity:";
    }
    else {
        ylabel = "Smokes:";
    }
    var toolTip = d3.tip()
      .attr("class", "d3-tip")
      .offset([50, -80])
      .html(function(d) {
        return (`${d.state}<br>${xlabel} ${d[chosenXAxis]}<br>${ylabel} ${d[chosenYAxis]}`);
      });
    circlesGroup.call(toolTip);
    abbrGroup.call(toolTip);
    circlesGroup.on("mouseover", function(data) {
      toolTip.show(data);
    })
      .on("mouseout", function(data, index) {
        toolTip.hide(data);
      });
    abbrGroup.on("mouseover", function(data) {
        toolTip.show(data);
    })
      .on("mouseout", function(data, index) {
         toolTip.hide(data);
      });
    return circlesGroup;
  }
function updateYToolTip ( chosenYAxis , circlesGroup , abbrGroup ) { var ylabel ; var xlabel = chosenXAxis ; if ( chosenYAxis === "healthcare" ) { ylabel = "Lacks Healthcare:" ; } else if ( chosenYAxis === "obesity" ) { ylabel = "Obesity:" ; } else { ylabel = "Smokes:" ; } var toolTip = d3 . tip ( ) . attr ( "class" , "d3-tip" ) . offset ( [ 50 , - 80 ] ) . html ( function ( d ) { return ( ` ${ d . state } ${ xlabel } ${ d [ chosenXAxis ] } ${ ylabel } ${ d [ chosenYAxis ] } ` ) ; } ) ; circlesGroup . call ( toolTip ) ; abbrGroup . call ( toolTip ) ; circlesGroup . on ( "mouseover" , function ( data ) { toolTip . show ( data ) ; } ) . on ( "mouseout" , function ( data , index ) { toolTip . hide ( data ) ; } ) ; abbrGroup . on ( "mouseover" , function ( data ) { toolTip . show ( data ) ; } ) . on ( "mouseout" , function ( data , index ) { toolTip . hide ( data ) ; } ) ; return circlesGroup ; }
function used for updating circles group with new tooltip for yAxis change
function used for updating circles group with new tooltip for yAxis change
// onmouseout event // onmouseout event