首页 > 其他分享 >横向柱状图图

横向柱状图图

时间:2023-02-13 20:13:19浏览次数:36  
标签:color 0.2 横向 柱状图 rgba type echarts 255


<!--横向柱状图图-->
<template>
<div class="chartBox">
<!--echart图标-->
<div id="crosswiseBarChart" ref="crosswiseBarChart"></div>
</div>
</template>

<script>
// 引入基本模板
// const echarts = require('echarts');
import * as echarts from 'echarts' // 注意此处echarts高版本中需要使用此方式才可引入
export default {
name: "crosswiseBarChart",
data() {
return {
myChart: null,
}
},
props:{
yTxtType:{
type:Number,
default:1//1类似[2.李老师],0记为[李老师]
}
},
mounted() {
this.initEchart();

},
methods: {
initEchart() {
// 基于准备好的dom,初始化echarts实例
this.myChart = echarts.init(this.$refs.crosswiseBarChart);
// y轴文字提示1类似[2.李老师],0记为[李老师]
let yAxisTxt=this.yTxtType==1?function(value,index) {
let className = index == 0 ? 'one' : ([1,2].includes(index) ? 'twoThree' : 'rests');
return '{' + className +'|' + `${index+1}、${value}` +'}'
}:function(value) {
return '{' + 'rests' +'|' + `${value}` +'}'
}
//y轴柱状体颜色
let yLineColor=this.yTxtType==1?[
['#FFE984', '#F8B404'],
['#53CEFD', '#1890FF'],
['#53CEFD', '#1890FF'],
['rgba(255,255,255,0.5)', 'rgba(255,255,255,1)'],
]:[
['rgba(255,255,255,0.5)', 'rgba(255,255,255,1)'],
['rgba(255,255,255,0.5)', 'rgba(255,255,255,1)'],
['rgba(255,255,255,0.5)', 'rgba(255,255,255,1)'],
['rgba(255,255,255,0.5)', 'rgba(255,255,255,1)'],
]
let option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},

grid: {
left: '0',
bottom: '18',
top: '20',
right: '20',
containLabel: true
},
xAxis: {
type: 'value',
splitLine: {
show:true,
lineStyle: {
color: 'rgba(255,255,255,0.2)'
}
},

axisLabel:{
textStyle: {
color: '#FFF',
fontSize: 12
}
},
boundaryGap: [0, 0.01]
},
yAxis: {
inverse:true,
type: 'category',
// 坐标刻度线
axisTick: {
show: false,
lineStyle: {
type: 'solid', //y轴分割线类型
color: 'rgba(102,102,102,0.9)',
width: 2.5,
},
},
splitLine: {
show:true,
interval:0,
lineStyle: {

width:2,
color:['transparent','rgba(255,255,255,0.2)','rgba(255,255,255,0.2)','rgba(255,255,255,0.2)','rgba(255,255,255,0.2)','rgba(255,255,255,0.2)','rgba(255,255,255,0.2)','rgba(255,255,255,0.2)','transparent']
}
},
data: ['程老师', '李老师', '王老师', '张老师', '刘老师', '陈老师','冯老师','陆老师'],
axisLabel: {
formatter:yAxisTxt ,
textStyle: {
color: '#FFF',
fontSize: 12,
rich: {
one:{
color:'#F8D800',
width: 24,
height: 16,
background:'rgba(255,255,255,0.1)'
},
twoThree:{
color:'#1890FF',
width: 24,
height: 16,
background:'rgba(255,255,255,0.1)'
},
rests:{
color:'#FFFFFF',
width: 24,
height: 16,
background:'rgba(255,255,255,0.1)'
}
},
}
}
},
series: [
{
type: 'bar',
data: [41,36,22,20,12,8,6,2],
barWidth: 4, //柱状宽度
markPoint: {
label: {
color: '#FFF', // 文字颜色
padding: [0, 0, 5, 0], // 可用padding调整图片内文字距离
show: false,
formatter: '000' // 自定义文字内容
},
data: [
{
type: "max", name: "最大值"
},
{
type: "min", name: "最小值"
},
{
type: "average", name: "平均值"
}],
symbol: 'roundRect',
// symbol: 'image://' + require('../assets/images/logo.png'), // 自定义图片作为标注展示
symbolSize: [4, 12], // 调整图片的长宽
symbolOffset: [0, 0], // 调整标注图片的位移方向 大小
itemStyle: {
color: '#fff'
}
},

itemStyle: { //柱状颜色和圆角
normal:{
//柱体的颜色
//右,下,左,上(1,0,0,0)表示从正右开始向左渐变
color: function (params) {
var colorList = yLineColor
let index = params.dataIndex > 3 ? 3 : params.dataIndex;
var colorItem = colorList[index];
return new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
offset: 0,
color: colorItem[0]
},
{
offset: 1,
color: colorItem[1]
}
], false);
},
borderRadius: [4,4,4,4], // (顺时针左上,右上,右下,左下)
}
},
}
]
};
// 使用刚指定的配置项和数据显示图表。
this.myChart.setOption(option);
}
}
}
</script>

<style lang="scss" scoped>
.chartBox {
width: 100%;
box-sizing: border-box;
padding: 1.6rem 1.6rem 0;
flex: 1;

#crosswiseBarChart {

height: 100%;

}
}
</style>

标签:color,0.2,横向,柱状图,rgba,type,echarts,255
From: https://www.cnblogs.com/connie256/p/17117656.html

相关文章

  • 分组柱状图
    <!--分组柱状图--><template><divclass="chartBox"><!--echart图标--><divid="histogram"ref="histogram"></div></div></template><script>//引入基本模......
  • 纵向扩容和横向扩容
    1.在学习分布式文件系统时了解到的:冗余备份:纵向扩展线性扩容:横向扩展可以看下这篇文章:什么是横向扩展和纵向扩展?-腾讯云开发者社区-腾讯云(tencent.com) 2.......
  • echarts动态排序柱状图
    链接:https://juejin.cn/post/7149089840850534407<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"/><metahttp-equiv="X-UA-Comp......
  • 视频直播app源码,纯css实现横向滚动
    视频直播app源码,纯css实现横向滚动<!DOCTYPEhtml><html> <head>  <title>横向滑动</title>  <metaname="viewport"content="width=device-width,initial-sca......
  • 下拉加载瀑布流(横向)
    图文以瀑布流(横向)的方式进行渲染绘制样式部分:.img_item_li{position:absolute;width:calc(16.5%-8px);margin:5px4px04px;padding:0;......
  • vue+echarts实现疫情柱状图(全国确诊省市TOP10)
    效果:代码:<template><div><divid="right1"style="height:800px;width:100%"></div></div></template><script>exportdefault{data(){return{......
  • Python修改柱状图边缘柱子与图边界的距离
      本文介绍基于Python中matplotlib.pyplot模块,修改柱状图、条形图最两侧的柱子与图像边缘之间距离的方法。  最近,绘制了一个水平的柱状图,但是发现图的上、下边距(不是......
  • 09Bar柱状图
    importmatplotlib.pyplotaspltimportnumpyasnpn=12X=np.arange(n)Y1=(1-X/float(n))*np.random.uniform(0.5,1.0,n)Y2=(1-X/float(n))*np.random.uniform(0.5,......
  • echarts柱状图柱体圆角
    init_chuangkou_top_list_chart:function(ckmc_list,value_list){letmyChart=this.$echarts.init(document.getElementById('chuangkou_top_list'));......
  • Echarts柱状图属性设置大全,怎么不要等高线
    https://blog.csdn.net/sleepwalker_1992/article/details/126467654......