mchart.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view class="content">
  3. <qiun-data-charts type="line" :chartData="chartData" echartsApp/>
  4. </view>
  5. </template>
  6. <script module="test" lang="renderjs">
  7. // import * as echarts from '@/plugin/echarts.js';
  8. import {
  9. lalaprice
  10. } from '@/api/wallet.js'
  11. export default {
  12. data() {
  13. return {
  14. chartData: {
  15. categories: [],
  16. series: [
  17. {
  18. name: 'Lala走势',
  19. data: []
  20. }
  21. ]
  22. }
  23. }
  24. },
  25. mounted() {
  26. this.createChart()
  27. },
  28. methods: {
  29. createChart() {
  30. lalaprice().then(e => {
  31. console.log(e.data, "123456")
  32. // this.chart_data = e.data
  33. let time = e.data.map(item => {
  34. return item.date
  35. })
  36. console.log(time)
  37. this.$set(this.chartData,'categories',time)
  38. let val = e.data.map(item => {
  39. return +item.lala_price
  40. })
  41. console.log(val)
  42. this.$set(this.chartData.series[0],'data',val)
  43. // option = {
  44. // xAxis: {
  45. // type: 'category',
  46. // data: time
  47. // },
  48. // yAxis: {
  49. // type: 'value'
  50. // },
  51. // series: [{
  52. // data: val,
  53. // type: 'line'
  54. // }],
  55. // grid: {
  56. // left: '15%',
  57. // right: '2%'
  58. // }
  59. // };
  60. // option && myChart.setOption(option);
  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>