api_axis_range.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <html>
  2. <head>
  3. <link href="../css/c3.css" rel="stylesheet" type="text/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. axes: {
  17. data1: 'y',
  18. data2: 'y2',
  19. }
  20. },
  21. axis: {
  22. x: {
  23. label: 'X Label'
  24. },
  25. y: {
  26. label: {
  27. text: 'Y Axis Label',
  28. position: 'outer-middle'
  29. }
  30. },
  31. y2: {
  32. show: true,
  33. label: {
  34. text: 'Y2 Axis Label',
  35. position: 'outer-middle'
  36. }
  37. }
  38. },
  39. tooltip: {
  40. // enabled: false
  41. },
  42. zoom: {
  43. // enabled: true
  44. },
  45. subchart: {
  46. // show: true
  47. }
  48. });
  49. setTimeout(function () {
  50. chart.axis.max(500);
  51. }, 1000);
  52. setTimeout(function () {
  53. chart.axis.min(-500);
  54. }, 2000);
  55. setTimeout(function () {
  56. chart.axis.max({y: 600, y2: 100});
  57. }, 3000);
  58. setTimeout(function () {
  59. chart.axis.min({y: -600, y2: -100});
  60. }, 4000);
  61. setTimeout(function () {
  62. chart.axis.range({max: 1000, min: -1000});
  63. }, 5000);
  64. setTimeout(function () {
  65. chart.axis.range({min: {y: 1000}, max: {y: 2000}});
  66. }, 6000);
  67. setTimeout(function () {
  68. chart.axis.range({max: {y: 600, y2: 100}, min: {y: -100, y2: 0}});
  69. }, 7000);
  70. </script>
  71. </body>
  72. </html>