api_tooltip_show.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <html>
  2. <head>
  3. <link rel="stylesheet" type="text/css" href="../css/c3.css">
  4. </head>
  5. <body>
  6. <div id="chart"></div>
  7. <script src="https://d3js.org/d3.v5.min.js" charset="utf-8"></script>
  8. <script src="../js/c3.js"></script>
  9. <script>
  10. var chart = c3.generate({
  11. data: {
  12. columns: [
  13. ['data1', 30, 200, 100, 400, 150, 250],
  14. ['data2', 50, 20, 10, 40, 15, 25]
  15. ],
  16. },
  17. zoom: {
  18. enabled: true,
  19. initialRange: [0.8,3.2],
  20. }
  21. });
  22. setTimeout(function () {
  23. chart.tooltip.show({ x: 2 });
  24. }, 1000);
  25. setTimeout(function () {
  26. chart.tooltip.show({ x: 1 });
  27. }, 2000);
  28. setTimeout(function () {
  29. chart.tooltip.show({ data: {x: 3, id: 'data1', value: 400} });
  30. }, 3000);
  31. setTimeout(function () {
  32. chart.tooltip.hide();
  33. }, 4000);
  34. setTimeout(function () {
  35. chart.internal.config.tooltip_grouped = false;
  36. chart.tooltip.show({ x: 2 });
  37. }, 5000);
  38. setTimeout(function () {
  39. // chart.internal.config.tooltip_grouped = false;
  40. chart.tooltip.show({ x: 1, id: 'data2' });
  41. }, 6000);
  42. setTimeout(function () {
  43. // chart.internal.config.tooltip_grouped = false;
  44. chart.tooltip.show({ data: {x: 3, id: 'data1', value: 400} });
  45. }, 7000);
  46. setTimeout(function () {
  47. chart.tooltip.hide();
  48. }, 8000);
  49. </script>
  50. </body>
  51. </html>