mchart.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="content">
  3. <qiun-data-charts type="line" :chart-data="chartData" echartsApp />
  4. </view>
  5. </template>
  6. <script>
  7. import {
  8. lalaprice
  9. } from '@/api/wallet.js'
  10. export default {
  11. data() {
  12. return {
  13. chartData: {
  14. categories: [],
  15. series: [{
  16. name: 'Lala走势',
  17. data: []
  18. }]
  19. }
  20. }
  21. },
  22. mounted() {
  23. console.log(this.chartData, '渲染完毕');
  24. this.createChart()
  25. },
  26. methods: {
  27. createChart() {
  28. lalaprice().then(e => {
  29. console.log(e.data, "123456")
  30. // this.chart_data = e.data
  31. let time = e.data.map(item => {
  32. return item.date
  33. })
  34. console.log(time)
  35. this.$set(this.chartData, 'categories', time.reverse())
  36. let val = e.data.map(item => {
  37. return +item.lala_price
  38. })
  39. console.log(val)
  40. this.$set(this.chartData.series[0], 'data', val.reverse())
  41. // option = {
  42. // xAxis: {
  43. // type: 'category',
  44. // data: time
  45. // },
  46. // yAxis: {
  47. // type: 'value'
  48. // },
  49. // series: [{
  50. // data: val,
  51. // type: 'line'
  52. // }],
  53. // grid: {
  54. // left: '15%',
  55. // right: '2%'
  56. // }
  57. // };
  58. // option && myChart.setOption(option);
  59. }).catch((E) => {
  60. console.log(E);
  61. })
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .content {
  68. width: 750rpx;
  69. height: 500rpx;
  70. }
  71. .line-chart {
  72. height: 500rpx;
  73. width: 730rpx;
  74. margin: auto;
  75. background-color: #eee;
  76. }
  77. </style>