echarts并列柱状图绘制、且动态渲染数据

1、效果图

2、代码

2.1、布局

2.2、mounted挂载方法

2.3、methons使用

2.3.1、获取接口数据【接口数据为数组包裹对象,将需要渲染的字段,取出来】

2.3.2、echarts绘制代码

const chart = this.$refs.chart;

const myChart = this.$echarts.init(chart);

if (chart) {

// option && myChart.setOption(option);

const option = {

legend: {

data: ["总量", "结构化数据", "非结构化数据"],

textStyle: {

//图例字体大小

fontSize: 16,

color: "#fff",

},

//图例大小

itemHeight: 16,

//图例位置

right: 150,

// bottom:350

},

tooltip: {},

xAxis: [{ data: name }, { axisLabel: { interval: 0 } }],

yAxis: {},

textStyle: {

fontSize: 20,

color: "#fff",

fontWeight: "lighter",

},

series: [

{

type: "bar",

data: grossData,

barWidth: 25,

name: "总量",

barGap: 0,

label: {

// 柱状图上方文本标签,默认展示数值信息

show: true,

position: "top",

color: "#fff",

fontWeight: "bolder",

fontSize: 12,

},

},

{

type: "bar",

data: structure,

name: "结构化数据",

barWidth: 25,

barGap: 0,

label: {

// 柱状图上方文本标签,默认展示数值信息

show: true,

position: "top",

color: "#fff",

fontWeight: "bolder",

fontSize: 12,

},

},

{

type: "bar",

data: notStructure,

name: "非结构化数据",

barWidth: 25,

barGap: 0,

label: {

// 柱状图上方文本标签,默认展示数值信息

show: true,

position: "top",

color: "#fff",

fontWeight: "bolder",

fontSize: 12,

},

},

],

};

option && myChart.setOption(option);

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值