rank-list.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <el-drawer size='480px' title="排行榜" :visible.sync="show" direction="rtl">
  3. <view id="chart-bar" :style="{height:height}" class="">
  4. </view>
  5. </el-drawer>
  6. </template>
  7. <script>
  8. import * as echarts from "echarts";
  9. import {
  10. chartBar
  11. } from './chart.js'
  12. export default {
  13. data() {
  14. return {
  15. show: false,
  16. height : 0,
  17. }
  18. },
  19. props: {
  20. chooseClassId: {
  21. type: Number | String,
  22. default: ""
  23. },
  24. },
  25. computed: {},
  26. methods: {
  27. open() {
  28. this.show = true;
  29. this.$api.sendRequest({
  30. url: '/mobile/studentTab/getStudentMonthRank',
  31. method: "post",
  32. data: {
  33. class_id: this.chooseClassId,
  34. },
  35. success: res => {
  36. let dom = document.getElementById('chart-bar')
  37. this.height = `${res.data.length * 60}px`
  38. this.$nextTick(() => {
  39. this.chart = echarts.init(dom);
  40. const myChart = this.chart;
  41. myChart.clear();
  42. // res.data.forEach((item, index) => {
  43. // // option.yAxis.axisLabel.rich[index] = {
  44. // // height: 40, // 图片高度
  45. // // width: 40, // 图片宽度
  46. // // backgroundColor: {
  47. // // image: item.student.student_cartoon_photo, // 图片路径
  48. // // }
  49. // // }
  50. // if (item.score_total < 0) {
  51. // option.yAxis.splitArea.areaStyle.color.push('rgba(231,79,176,0.2)')
  52. // } else {
  53. // option.yAxis.splitArea.areaStyle.color.push('rgba(0,0,0,0)')
  54. // }
  55. // })
  56. myChart.setOption(chartBar(res.data));
  57. })
  58. }
  59. })
  60. }
  61. }
  62. }
  63. </script>
  64. <style>
  65. </style>