assets/js/app.js
// function used for updating circles group with new tooltip
function used for updating circles group with new tooltip
function used for updating circles group with new tooltip
function updateToolTip(chosenXAxis, circlesGroup) {
    var label;
    if (chosenXAxis === "poverty") {
      label = "Poverty(%):";
    }
    else if (chosenXAxis === "age") {
        label = "Age(Median):";
    }
    else {
      label = "Income(Median):";
    }
    var toolTip = d3.tip()
      .attr("class", "tooltip")
      .offset([0,0])
      .html(function(d) {
        return (`${d.state}<br>${label} ${d[chosenXAxis]}`);
      });
    circlesGroup.call(toolTip);
    circlesGroup.on("mouseover", function(data) {
      toolTip.show(data);
    })
      .on("mouseout", function(data, index) {
        toolTip.hide(data);
      });
    return circlesGroup;
  }
function updateToolTip ( chosenXAxis , circlesGroup ) { var label ; if ( chosenXAxis === "poverty" ) { label = "Poverty(%):" ; } else if ( chosenXAxis === "age" ) { label = "Age(Median):" ; } else { label = "Income(Median):" ; } var toolTip = d3 . tip ( ) . attr ( "class" , "tooltip" ) . offset ( [ 0 , 0 ] ) . html ( function ( d ) { return ( ` ${ d . state } ${ label } ${ d [ chosenXAxis ] } ` ) ; } ) ; circlesGroup . call ( toolTip ) ; circlesGroup . 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
function used for updating circles group with new tooltip
// onmouseout event