angenstern

enmnm...一般会使用npm下载echarts这个包,但是不知道是我自己的配置问题还是别的原因,一直出不来图线,

于是,把Hello uni-app模板里的那个组件抱过来,然后,成了!

首先,

1、页面引入

 <template>
         <view class="container">
               <view>
                   <view class="canvasView">
                    <mpvue-echarts class="ec-canvas" @onInit="lineInit" canvasId="line" ref="lineChart" />
                </view>
               </view>
           </view>
</template>

2、逻辑层

<script>
    import * as echarts from \'@/components/echarts/echarts.simple.min.js\';
    import mpvueEcharts from \'@/components/mpvue-echarts/src/echarts.vue\';
    export default {
        data() {
            return {
                updateStatus: false,
                line: {
                    legend: {
                        data: [\'邮件营销\']
                    },
                    xAxis: {
                        type: \'category\',
                        data: [\'Mon\', \'Tue\', \'Wed\', \'Thu\', \'Fri\', \'Sat\', \'Sun\']
                    },
                    yAxis: {
                        type: \'value\',
                        data: []
                    },
                    dataZoom: [{
                        type: \'slider\',
                        start: 30,
                        end: 100,
                        zoomLock: false,
                    }],
                    grid: {
                        left: 40,
                        right: 40,
                        bottom: 20,
                        top: 40,
                        containLabel: true
                    },
                    series: [{
                        data: [],
                        data: [820, 932, 901, 934, 1290, 1330, 1320],
                        type: \'line\',
                        color: [\'#5eb4e2\'], //折线条的颜色
                    }]
                }
            }
        },
        methods: {
            lineInit(e) {
                let {
                    width,
                    height
                } = e;
                let canvas = this.$refs.lineChart.canvas
                echarts.setCanvasCreator(() => canvas);
                let lineChart = echarts.init(canvas, null, {
                    width: width,
                    height: height
                })
                canvas.setChart(lineChart)
                lineChart.setOption(this.line)
                this.$refs.lineChart.setChart(lineChart)
            },
        },
        components: {
            mpvueEcharts
        }
    }
</script>

3、样式设定

<style>

    .ec-canvas {
        display: flex;
        height: 100%;
        flex: 1;
    }

    .canvasView {
        width: 700upx;
        height: 500upx;
    }
    
</style>

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-12
  • 2021-08-29
  • 2021-04-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-03-06
  • 2021-07-26
  • 2022-12-23
  • 2022-01-26
  • 2021-11-19
  • 2021-05-23
  • 2022-01-13
相关资源
相似解决方案