vue图表ehchart和富文本编辑器的使用

12 篇文章 0 订阅

vue图表用echart
$ npm install echarts --save
在你要用的XX.vue中引用
import echarts from “echarts”

  <div class="charts">
      <div class="className" id="myEchart" style="height:300px;width:400px" ref="myEchart"></div>

      data:<input type="text" v-model="chartData_data">
      nav:<input type="text" v-model="chartData_nav">
      <button @click="chartAdd">增加</button>
    </div>

js

import echarts from "echarts"
export default {
  name: 'Test',
  data () {
    return{
      chartData_data:'',
      chartData_nav:'',
      chartData:{
        data:[23,34,12,6,78,45,90],
        nav:['a','b','c','d','e','f','g']
      }
    }
  },
  mounted: function () {
    this.initChart();
  },
   methods: {
     chartAdd:function () {
       this.chartData.data.push(this.chartData_data);
       this.chartData.nav.push(this.chartData_nav);
       this.initChart();
     },
     initChart() {
       this.chart = echarts.init(document.getElementById('myEchart'));
       // 把配置和数据放这里
       this.chart.setOption({
         color: ['#3398DB'],
         tooltip: {
           trigger: 'axis',
           axisPointer: { // 坐标轴指示器,坐标轴触发有效
             type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
           }
         },
         grid: {
           left: '3%',
           right: '4%',
           bottom: '3%',
           containLabel: true
         },
         xAxis: [{
           type: 'category',
           data: this.chartData.nav,
           axisTick: {
             alignWithLabel: true
           }
         }],
         yAxis: [{
           type: 'value'
         }],
         series: [{
           name: '直接访问',
           type: 'bar',
           barWidth: '60%',
           data:  this.chartData.data
         }]
       })
     }
   }

}

还可以动态添加数据

vue富文本编辑器我们用vue-quill-editor
$ npm install vue-quill-editor --save
在main.js中引入

import vueQuillEditor from "vue-quill-editor"
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(vueQuillEditor);
export default {
  name: 'Test',
  data () {
    return{
    }
  },
   methods: {
     onEditorBlur:function (e) {
       console.log('editor change!', e);
       console.log(e.container.innerHTML);//一大推东西,你也可以输出e,看看里面的结构
   }

}
 <div class
 ="editCOn">
     <quill-editor  @blur="onEditorBlur($event)">

     </quill-editor>
   </div>

颜色,字体大小什么的都能用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

boJIke

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值