let barData = [{name:'name1',age:'18',sex:'0'}];
var barOption = {
title: {
text: 'echarts图标title',
},
legend: {
show: false, // 是否显示图例
},
grid: {
x: "3.5%", ;//左侧 y轴内容距离边框的距离(类似padding-left)
},
color: ["#35D2FF"], // 条形颜色
tooltip: { // 鼠标经过 tip提示
trigger: "item", // 当trigger为’item’时只会显示该点的数据,为’axis’时显示该列下所有坐标轴所对应的数据。 默认为 'item'
backgroundColor: "rgba(43,43,43,1)",
borderRadius: 4,
borderWidth: 1,
padding: 10,
// hideDelay:100, // 延迟消失
extraCssText: // tip样式
"width:199px!important;height:114px;background:rgba(255,255,255,0.94);box-shadow:0px 10px 35px 0px rgba(9,26,66,0.2);border:none;border-radius:20px;display:flex;flex-direction: column;justify-content: space-between;padding:0;margin:0",
formatter: function(params) { // tip显示的具体内容
let name = name,
age = age,
sex = sex;
return `
<div><em> ${name}</em> </div>
<div><em>${num}岁</em> </div>
<div>性别<em>${sex}</em></div> `;
},
textStyle: {
color: "rgba(0,0,0,0.45)",
},
},
dataset: {
dimensions: ["dept_name", "num", "percentage", "dept"],
source: [...barData], // 绑定数据源
},
xAxis: { // x轴
type: "category",
axisLine: {
lineStyle: { // x轴 线条颜色
color: "#F3F3F3",
},
},
axisLabel: {
textStyle: { // x轴 lable样式
color: "#3B4042",
fontSize: 14,
fontWeight: 400,
},
rotate: 300, // 旋转角度
interval: 0, // 间隔
},
offset: 5, // 偏移 (标题距离x轴的距离)
},
grid:{
y2:100
},
yAxis: {
min: 0,
// max: 100,
minInterval: 1,
axisLine: {
lineStyle: {
color: "#FFF", // y轴颜色
},
},
axisLabel: {
textStyle: {
color: "#3B4042", // y轴 刻度
},
},
splitLine: {
// 辅助线
show: true,
lineStyle: {
color: "#F3F3F3",
width: 1,
},
},
},
series: [
{
type: "bar",
barMaxWidth: 10, // 最大宽度
itemStyle: {
normal: { barBorderRadius: [15] },
},
},
],
};
myBarChart.setOption(barOption, true);
Echarts参数配置
最新推荐文章于 2025-03-13 09:56:19 发布