bar-chart.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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="bar" :chartData="chartData" :loadingType="4" background="none" />
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. name: "bar-chart",
  14. data() {
  15. return {
  16. chartData: {
  17. categories: [
  18. "数学",
  19. "语文",
  20. "英语",
  21. "体育",
  22. "科学",
  23. "思品"
  24. ],
  25. series: [{
  26. "name": "目标成绩",
  27. "data": [
  28. 97,
  29. 90,
  30. 100,
  31. 95,
  32. 97,
  33. 91
  34. ]
  35. },
  36. {
  37. "name": "近期成绩",
  38. "data": [
  39. 91,
  40. 92,
  41. 94,
  42. 88,
  43. 82,
  44. 89
  45. ]
  46. }
  47. ],
  48. },
  49. };
  50. },
  51. methods:{
  52. }
  53. }
  54. </script>
  55. <style lang="scss">
  56. .chart-container {
  57. margin: 10px;
  58. padding: 5px 5px 5px 3px;
  59. border-radius: 10px;
  60. display: flex;
  61. align-items: center;
  62. justify-content: center;
  63. flex-direction: column;
  64. background-color: #FFFFFF;
  65. box-shadow: 3px 3px 5px 1px rgba(0, 0, 0, 0.05);
  66. .chart-name {
  67. width: 100%;
  68. text-align: left;
  69. margin-left: 18px;
  70. margin-top: 8px;
  71. .chart-name-text {
  72. font-size: 13px;
  73. }
  74. }
  75. /* 请根据需求修改图表容器尺寸,如果父容器没有高度图表则会显示异常 */
  76. .charts-box {
  77. width: 100%;
  78. height: 280px;
  79. }
  80. }
  81. </style>