叠堆柱状图(带折线版+2y轴)
2024-10-21 13:30:49
叠堆柱状图(带折线+2y轴)
代码
var chartDom=document.getElementById("stackBarAddLine");
var myChart=echarts.init(chartDom);
var option;
option = {
tooltip: {
trigger: 'axis' //轴触发
},
title: {
text: '这是主标题',
left: 'center',
top: 'top',
textStyle: {
fontSize: 18,
fontStyle: 'oblique', //斜体
color: 'red'
},
subtext: '这是副标题'
//subtextStyle:{//副标题样式
//}
},
legend: {
//图例
data: ['直销', '分销', '分销比率'],
left: '10%'
},
xAxis: {
type: 'category', //类目轴
name: '酒店',
nameLocation: 'center',
nameTextStyle: {
padding: [30, 0, 0, 200] //[下,左,上无效,右]
},
data: ['酒店1', '酒店2', '酒店3', '酒店4', '酒店5', '酒店6', '酒店7']
},
yAxis: [
{
type: 'value',
name: '销售数量',
nameLocation: 'center',
nameTextStyle: {
padding: [0, 0, 30, 200] //[右无效,下,左,上]
}
},
{
type: 'value',
name: '分销比率',
nameLocation: 'center',
nameTextStyle: {
padding: [30, 0, 0, 200] //[右,下,左无效,上]
}
}
],
series: [
{
barWidth: 50,
name: '直销',
type: 'bar',
stack: 'a',
data: [80, 50, 40, 60, 40, 20, 40],
itemStyle: {
normal: {
label: {
position: ['50%', '10%'],
color: 'white',
show: true
}
}
}
},
{
name: '分销',
type: 'bar',
stack: 'a',
data: [20, 50, 40, 90, 50, 40, 60],
itemStyle: {
normal: {
label: {
position: ['50%', '10%'],
color: 'white',
show: true
}
}
}
},
{
name: '分销比率',
type: 'line',
yAxisIndex: 1, //默认为0
data: [0.2, 0.5, 0.5, 0.5, 0.63, 0.63, 0.63]
}
]
};
option & myChart.setOption(option);
效果图:
总结:
1.nameTextStyle属性中的padding:[1,2,3,4] 的使用规律:
对于y轴:[右,下,左无效,上] ,其中y轴在左边,则左无效,y轴在右边,则向右无效
对于x轴:[下,左,上,右] 其中x轴在下方,则向上无效,x轴在上方,则向下无效
2.多轴问题总结:选择第一个y轴则在series中对应的{}中使用yAxisIndex(从0开始),如果是多指标雷达图,则是使用radarIndex等等...
最新文章
- rsync同步
- jQuery AJAX 网页无刷新上传示例
- SharePoint 2013 User Profile Services之跨场设置
- C# 正则表达式
- Abundant Resources
- linux 学习8 权限管理
- 排序陷阱 List.Sort Linq.OrderBy
- native app
- 转发:在开发机上绕过Chrome同源策略的办法
- oracle 内存结构 share pool sql解析的过程
- Google Map API学习1
- Linux常用命令--网络管理篇(三)
- QT学习 之 事件与事件过滤器(分为五个层次)
- 利用Adapter对象将数据填充到DataTable(或DataSet)的例子
- 在linux下如何编译C++程序
- 如是使用JS实现页面内容随机显示
- jQuery serializeArray()方法改写多维对象以及自定义
- LinkedHashMap源码分析及实现LRU
- 利用Sklearn实现加州房产价格预测,学习运用机器学习的整个流程(包含很多细节注解)
- 【sping揭秘】11、Java 平台上的AOP实现机制
热门文章
- Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hosts.
- day11 枚举类enum &; 单例模式 &; 异常以及抛出
- linux常用指令记录
- 【Shell案例】【awk、grep、sort、uniq】10、第二列是否有重复
- Qt VideoMeeting_Intercom师生对讲开发中实际上遇到的一些问题,终于结项了,也照例写一下总结吧。
- 实施 GitOps 的三个关键步骤
- 【机器学习】李宏毅——Recurrent Neural Network(循环神经网络)
- 【FAQ】申请Health Kit权限的常见问题及解答
- 从面试题入手,畅谈 Vue 3 性能优化
- cs231n__4.1 Backpropagation and Neural Network