请问,在 echarts 3.x 中,grid.containLabel=true 是否将 yAxis.nameLocation=middle 考虑在内?
问题简述 (One-line summary)
在 echarts 3.x 中,grid.containLabel=true 可以保证坐标轴的刻度标签溢出可视区域,那么当设置 yAxis.nameLocation=middle 将坐标轴名称显示在轴线中间位置时,除了设置 yAxis.nameGap 自定义名称与轴线的距离以外,能不能让 grid 自动计算 "nameGap" 来将名称放在最外面?
版本及环境 (Version & Environment)
- ECharts 版本 (ECharts version): 3.1.9
- 浏览器类型和版本 (Browser version): Google Chrome 50.0.2661.86 (64-bit)
- 操作系统类型和版本 (OS Version): OS X EI Capitan 10.11.4
重现步骤 (Steps to reproduce)
- 右键,在新标签页打开官网的实例页:http://echarts.baidu.com/demo.html#area-stack
- 将下方贴出的 ECharts 配置项替换官网原来的 options,然后 运行;
- 查看 Y 轴的名称:”Values-Y“ 显示的位置;
期望结果 (Expected behaviour)
Y 轴的名称 ”Values-Y“,自动计算显示在最外面,而不是手动去设置 nameGap=40,因为所有的刻度标签位置都是被自动计算的;
可能哪里有问题 (What went wrong)
算不算一个新的功能优化点?还是我的使用上有问题?
ECharts配置项 (ECharts option)
option = {
title: {
text: '堆叠区域图'
},
tooltip : {
trigger: 'axis'
},
legend: {
data:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
},
toolbox: {
feature: {
saveAsImage: {}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
boundaryGap : false,
data : ['周一','周二','周三','周四','周五','周六','周日']
}
],
yAxis : [
{
type : 'value',
name: 'Values-Y',
nameLocation: 'middle',
nameGap: 40,
nameTextStyle: {
color: 'red',
fontWeight: 'bolder',
fontSize: 18
}
}
],
series : [
{
name:'邮件营销',
type:'line',
stack: '总量',
areaStyle: {normal: {}},
data:[120, 132, 101, 134, 90, 230, 210]
},
{
name:'联盟广告',
type:'line',
stack: '总量',
areaStyle: {normal: {}},
data:[220, 182, 191, 234, 290, 330, 310]
},
{
name:'视频广告',
type:'line',
stack: '总量',
areaStyle: {normal: {}},
data:[150, 232, 201, 154, 190, 330, 410]
},
{
name:'直接访问',
type:'line',
stack: '总量',
areaStyle: {normal: {}},
data:[320, 332, 301, 334, 390, 330, 320]
},
{
name:'搜索引擎',
type:'line',
stack: '总量',
label: {
normal: {
show: true,
position: 'top'
}
},
areaStyle: {normal: {}},
data:[820, 932, 901, 934, 1290, 1330, 1320]
}
]
};
其他信息 (Other comments)
可以,谢谢建议
这个功能没实现么
nameGap 支持自适应的,现在实现了吗?
This issue is closed due to not being active. Please feel free to open it again (for the author) or create a new one and reference this (for others) if you have further questions.
问题提出3年了,实现了吗?
有相同的需求 @pissang 请问解决了吗?3.1.11这个版本没看到啊。
在最新版4.5.0中,貌似依然没有相关的设置和自适应,个人感觉架构时可以类似zlevel或者z配置一样,对yAxis-name进行分层绘制,从而从层级上与axisLabel相对定位,进而避免与axisLabel重叠;
@chaserstrong 建议你可以通过手动设置 nameGap 解决该问题,因为绘制 yAxis 时,在series的data中最大的value是可以提前知道的,因此 axisLabel 能占用的最大宽度也基本可以确定,该最大宽度加上少许margin 就是 nameGap 的值
八年了