博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vue-echarts-v3 使用 tooltip显示内容自定义
阅读量:4647 次
发布时间:2019-06-09

本文共 1352 字,大约阅读时间需要 4 分钟。

<template>
<div class="echarts">
<IEcharts :option="pie" @ready="onReady" @click="onClick"></IEcharts>
<button @click="test">go</button>
</div>
</template>
<script>
import IEcharts from 'vue-echarts-v3/src/lite.js';
import 'echarts/lib/component/title'; //引入标题组件
import 'echarts/lib/component/legend'; //引入图例组件
import 'echarts/lib/component/tooltip'; //引入图例组件
import 'echarts/lib/chart/bar';
// import func from './vue-temp/vue-editor-bridge';
export default {
components: {IEcharts},
data: () => ({
pie: {
color: ['#3398DB'],
tooltip : {
trigger: 'axis',
formatter:function (params){
console.log(params[0].name)
let res ='<p>'+params[0].data.name+'</p>'
return res
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisTick: {
alignWithLabel: true
}
}
],
yAxis : [
{
type : 'value'
}
],
series : [
{
name:'直接访问',
type:'bar',
barWidth: '60%',
data:[{
name:'自定义',value:10}, 52, 200, 334, 390, 330, 220]
}
]
}
}),
methods: {
onReady(instance) {
console.log(instance);
},
onClick(event, instance, echarts) {
console.log(arguments);
},
test () {
this.$router.push('/HelloWorld1')
}
}
};
</script>
<style scoped>
.echarts{
width: 100%;
height: 400px;
margin: auto;
text-align: center;
}
</style>
 

转载于:https://www.cnblogs.com/cs122/p/9782701.html

你可能感兴趣的文章
Redis 入门知识
查看>>
夏天过去了, 姥爷推荐几套来自smashingmagzine的超棒秋天主题壁纸
查看>>
转--Android如何在java代码中设置margin
查看>>
反射的所有api
查看>>
css 定位及遮罩层小技巧
查看>>
项目中非常有用并且常见的ES6语法
查看>>
[2017.02.23] Java8 函数式编程
查看>>
Knowledge Point 20180305 数据在计算机中的表示
查看>>
谈谈对web标准的理解
查看>>
58前端内推笔试2017(含答案)
查看>>
sprintf 和strcpy 的差别
查看>>
MPEG4与.mp4
查看>>
实验5
查看>>
git 下载 安装
查看>>
录制终端信息并回放
查看>>
JS中window.event事件使用详解
查看>>
ES6深入学习记录(一)class方法相关
查看>>
《BI项目笔记》用Excel2013连接和浏览OLAP多维数据集
查看>>
C语言对mysql数据库的操作
查看>>
SQL Server 数据库备份
查看>>