let app = new Vue({ el: '#app', data () { return {} }, created () { }, beforeDestroy () { }, mounted () { // setTimeout(() => { // this.moChart() // }) this.moChart() }, methods: { moChart () { //获取dom元素 let myChart = echarts.init(this.$refs['echart1']) option = { animationDuration: 2000, xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, series: [ { data: [ 120, { value: 200, itemStyle: { color: '#a90000' } }, 150, 80, 70, 110, 130 ], type: 'bar' } ] }; //轮播 // tools.loopShowTooltip(myChart, option, { // nterval: 2000, // loopSeries: true, // }); //注册 myChart.setOption(option) }, yuanChange (value) { return Number((value / 100000000).toFixed(2)) }, // 逢三折断 numFormat (value) { if (!value) return '0' // var intPart = Number(value).toFixed(0) // 获取整数部分 var intPart = parseInt(value)// 获取整数部分 var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') // 将整数部分逢三一断 var floatPart = '.00' // 预定义小数部分 var value2Array = value.toString().split('.') // =2表示数据有小数位 if (value2Array.length === 2) { floatPart = value2Array[1].toString() // 拿到小数部分 if (floatPart.length === 1) { // 补0 return intPartFormat + '.' + floatPart + '0' } else { floatPart = floatPart.slice(0, 2) return intPartFormat + '.' + floatPart } } else { return intPartFormat } }, })