line-chart.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="chart-container">
  3. <view class="chart-name">
  4. <text class="chart-name-text">总成绩对比</text>
  5. </view>
  6. <view class="charts-box">
  7. <qiun-data-charts type="line" :chartData="chartData" :loadingType="4"/>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. data() {
  14. return {
  15. chartData: {
  16. categories: [
  17. "测验1",
  18. "测验2",
  19. "测验3",
  20. "测验4",
  21. "测验5",
  22. ],
  23. series: [{
  24. "name": "孩子总分",
  25. "data": [
  26. 400,
  27. 390,
  28. 380,
  29. 399,
  30. 366,
  31. ]
  32. },
  33. {
  34. "name": "班级平均分",
  35. "data": [
  36. 360,
  37. 377,
  38. 355,
  39. 322,
  40. 338,
  41. ]
  42. },
  43. {
  44. "name": "年级平均分",
  45. "data": [
  46. 333,
  47. 346,
  48. 364,
  49. 347,
  50. 355,
  51. ]
  52. }
  53. ],
  54. },
  55. };
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. .chart-container {
  61. margin: 20px 10px;
  62. padding: 4px 4px 4px 2px;
  63. border-radius: 15px;
  64. display: flex;
  65. align-items: center;
  66. justify-content: center;
  67. flex-direction: column;
  68. background-color: #FFFFFF;
  69. box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  70. .chart-name {
  71. width: 100%;
  72. text-align: left;
  73. margin-left: 30px;
  74. margin-top: 8px;
  75. font-weight: bold;
  76. color: #3B4144;
  77. .chart-name-text {
  78. font-size: 13px;
  79. }
  80. }
  81. /* 请根据需求修改图表容器尺寸,如果父容器没有高度图表则会显示异常 */
  82. .charts-box {
  83. width: 100%;
  84. height: 190px;
  85. }
  86. }
  87. </style>