Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. function selectDataset(d) {
  2. let value = this.value;
  3. if (value == "total") {
  4. change(datasetTotal);
  5. } else if (value == "option1") {
  6. change(datasetOption1);
  7. } else if (value == "option2") {
  8. change(datasetOption2);
  9. }
  10. }
  11.  
  12. function changeColor(d) {
  13. let value = this.value;
  14. if (value == "total") {
  15. d3.selectAll("rect")
  16. .transition()
  17. .duration(2000)
  18. .style("fill", 'blue')
  19. } else if (value == "option1") {
  20. d3.selectAll("rect")
  21. .transition()
  22. .duration(2000)
  23. .style("fill", 'red')
  24. } else if (value == "option2") {
  25. d3.selectAll("rect")
  26. .transition()
  27. .duration(2000)
  28. .style("fill", 'yellow')
  29. }
  30.  
  31. }
  32.  
  33. d3.selectAll("input").on("change", function(d) {
  34. selectDataset.call(this, d);
  35. changeColor.call(this, d);
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement