mounted() {
var bar = echarts.init(document.getElementById("barchart_container"));
var option = {
// title: {
// text: "某地区蒸发量和降水量",
// subtext: "纯属虚构",
// },
tooltip: {
// trigger: "axis",
},
grid: {
left: "3%",
right: "4%",
bottom: 100,
// height: 200
show: false
// containLabel: true,
},
//图例部分
legend: {
left: "25%",
bottom: 41,
data: ["自我评分", "师兄评分"],
textStyle: {
fontSize: 18,
fontFamily: "Source Han Sans CN",
fontWeight: "bold",
color: "#333333",
},
itemGap: 185,
itemWidth: 19,
itemHeight: 7,
inactiveColor: "#f60", //图例关闭时的颜色
},
// toolbox: {
// show: true,
// feature: {
// dataView: { show: true, readOnly: false },
// magicType: { show: true, type: ["line", "bar"] },
// restore: { show: true },
// saveAsImage: { show: true },
// },
// },
calculable: true,
xAxis: {
// show: false,
type: "category",
data: ["html", "css", "javascript", "框架", "jquery"],
// data: [8, 5, 6, 9, 10],
// nameTextStyle: {
// fontSize: 16,
// fontFamily: "Source Han Sans CN",
// fontWeight: 500,
// color: "#333333",
// },
axisLine: {
show: false,
},
axisTick: {
show: false,
},
axisLabel: {
show: true,
margin: 12,
fontSize: 15,
fontFamily: "Source Han Sans CN",
fontWeight: 500,
color: "#333333",
},
},
yAxis: [
{
show: false,
type: "value",
},
],
series: [
{
name: "自我评分",
type: "bar",
data: [2.0, 3.0, 4.0, 5.0, 10.0],
itemStyle: {
color: "#FC9708",
background: "#FC9708",
// shadowColor: "3px 8px 17px 1px rgba(252, 151, 8, 0.6)",
shadowColor: "#FC9708",
shadowOffsetX: 4,
shadowOffsetY: 5,
shadowBlur: 10,
borderRadius: "4 4 0 0",
// opacity: 0.6
},
// lineStyle: {
// color: "red"
// },
markPoint: {
symbol: "pin",
symbolSize: "65",
symbolOffset: [0, -1],
//是否标注的值
label: {
show: true,
fontFamily: "wgsFont",
fontSize: 44,
},
data: [
{ type: "max", name: "最大值" },
{ type: "min", name: "最小值" },
{ type: "average", name: "平均值" },
],
},
// markLine: {
// data: [{ type: "average", name: "平均值" }],
// },
},
{
name: "师兄评分",
// label: {
// show: true
// },
// labelLine: {
// show: true
// },
type: "bar",
data: [3.0, 4.0, 6.0, 8.0, 11.0],
itemStyle: {
color: "#2E5AFB",
// color: "#FC9708",
background: "#2E5AFB",
// shadowColor: "3px 8px 17px 1px rgba(252, 151, 8, 0.6)",
shadowColor: "#2E5AFB",
shadowOffsetX: 4,
shadowOffsetY: 5,
shadowBlur: 10,
borderRadius: "4 4 0 0",
// opacity: 0.6
},
markPoint: {
symbol: "pin",
symbolSize: "65",
symbolOffset: [0, -1],
//是否标注的值
label: {
show: true,
fontFamily: "wgsFont",
fontSize: 44,
},
data: [
{ type: "max", name: "最大值" },
{ type: "min", name: "最小值" },
{ type: "average", name: "平均值" },
],
},
// markLine: {
// data: [{ type: "average", name: "平均值" }],
// },
},
],
};
bar.setOption(option);
window.addEventListener('resize',()=>{
bar.resize();
})
},
vue项目中让echarts自适应
原创wx6375cd1abf2fb 博主文章分类:vue2 ©著作权
©著作权归作者所有:来自51CTO博客作者wx6375cd1abf2fb的原创作品,请联系作者获取转载授权,否则将追究法律责任

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
echarts 自适应宽度
一个页面只有一个echarts图形时,可以写为myChart.setOption(option);window.onresize = myChart.resize; 一个页面
echarts 自适应宽度 myChart options resize -
【echarts】echarts图表自适应屏幕
echarts图表自适应屏幕 echarts如何自适应屏幕?只要加上两句话就可以
echarts 自适应屏幕 初始化 自适应 -
Vue项目中引入Echarts
在Vue项目中引入Echarts并使用,本文以一个柱状图演示了如何在vue中使用Echarts绘制图表。
Echarts vue 配置项 柱状图 数据 -
Vue中 实现 Echarts 图表宽高自适应
1. 安装并引入 2. 定义防抖函数 传送门:Vue中 实现函数的防抖、节流及应用场景 3. 绘制图表代码 init 方法
前端 ECharts 显式 初始化 标签页