<script>

$(".visible").click(function() {
  var klass = $(this).attr("id");

  if ($(this).prop("checked")) {
    $(document.getElementsByClassName(klass)).show();
  }
  else {
    $(document.getElementsByClassName(klass)).hide();
  }
});

$("#check-all").click(function() {
  if($(this).prop("checked")) {
    $(".visible").each(function() {
      $(this).prop("checked", false);
      $(this).click();
    });
  } else {
    $(".visible").each(function() {
      $(this).prop("checked", true);
      $(this).click();
    });
  }
});

function rotate() {
  if (svg.classed("rotated")) {
    simulation.alphaTarget(0);
    svg.classed("rotated", false);
  }
  else {
    simulation.alphaTarget(0.4).restart();
    svg.classed("rotated", true);
  }
};

</script>