説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

LineChart.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import { Line } from "react-chartjs-2";
  2. function LineChart({lineData}) {
  3. const data = {
  4. labels: [
  5. "Jan",
  6. "Feb",
  7. "Mar",
  8. "Apr",
  9. "May",
  10. "Jun",
  11. "Jul",
  12. "Aug",
  13. "Sep",
  14. "Oct",
  15. "Nov",
  16. "Dec",
  17. ],
  18. datasets: [
  19. {
  20. label: "Water",
  21. backgroundColor: "rgba(22, 82, 240, 0.75)",
  22. borderColor: "transparent",
  23. data: lineData.facebook,
  24. lineTension: 0,
  25. pointRadius: 0,
  26. borderWidth: 2,
  27. },
  28. {
  29. label: "Water",
  30. backgroundColor: "rgba(22, 82, 240, 0.5)",
  31. borderColor: "transparent",
  32. data: lineData.youtube,
  33. lineTension: 0,
  34. // borderDash: [10, 5],
  35. borderWidth: 1,
  36. pointRadius: 0,
  37. },
  38. ],
  39. };
  40. const options = {
  41. responsive: true,
  42. maintainAspectRatio: false,
  43. legend: {
  44. display: false,
  45. },
  46. scales: {
  47. xAxes: [
  48. {
  49. stacked: true,
  50. barPercentage: 0.45,
  51. gridLines: {
  52. display: false,
  53. drawBorder: false,
  54. },
  55. ticks: {
  56. // fontColor: "#8a909d",
  57. },
  58. },
  59. ],
  60. yAxes: [
  61. {
  62. stacked: true,
  63. gridLines: {
  64. display: false,
  65. color: "#eee",
  66. },
  67. ticks: {
  68. stepSize: 50,
  69. // fontColor: "#8a909d",
  70. },
  71. },
  72. ],
  73. },
  74. tooltips: {
  75. mode: "index",
  76. intersect: false,
  77. titleFontColor: "#888",
  78. bodyFontColor: "#555",
  79. titleFontSize: 12,
  80. bodyFontSize: 15,
  81. backgroundColor: "rgba(256,256,256,0.95)",
  82. displayColors: true,
  83. xPadding: 10,
  84. yPadding: 7,
  85. borderColor: "rgba(220, 220, 220, 0.9)",
  86. borderWidth: 2,
  87. caretSize: 6,
  88. caretPadding: 5,
  89. },
  90. };
  91. return (
  92. <>
  93. <Line data={data} height={150} options={options} id="activity" />
  94. </>
  95. );
  96. }
  97. export default LineChart;