echarts官网:https://echarts.apache.org/zh/index.html
    下载echarts
    npm install echarts

    1. //html部分
    2. <template>
    3. <div>
    4. <div class="bar" ref="bar"></div>
    5. </div>
    6. </template>
    7. <script>
    8. import * as echarts from "echarts";
    9. export default {
    10. data(){
    11. return{
    12. chart: null,
    13. }
    14. }
    15. methods: {
    16. initChart() { //初始化图表
    17. this.chart = echarts.init(this.$refs.bar);
    18. this.chart.resize({
    19. width: 1435, //设置宽高
    20. height: 770,
    21. });
    22. },
    23. startChart() { //设置图表option
    24. this.chart.setOption(option)
    25. }
    26. },
    27. mounted() {
    28. this.initChart();
    29. this.startChart();
    30. },
    31. beforeDestroy() { //释放echarts图表
    32. this.chart.dispose();
    33. },
    34. }
    35. </script>
    36. <style>
    37. //自己写
    38. </style>

    option配置项见下文