Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subtextStyle使用rich后属性后,样式没有变化 #8192

Closed
zacard-orc opened this issue Apr 18, 2018 · 8 comments
Closed

subtextStyle使用rich后属性后,样式没有变化 #8192

zacard-orc opened this issue Apr 18, 2018 · 8 comments

Comments

@zacard-orc
Copy link

One-line summary [问题简述]

subtextStyle使用rich后属性后,样式没有变化

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]: 4.0.2
  • Browser version [浏览器类型和版本]: Chrome 51
  • OS Version [操作系统类型和版本]: OSX 10.12

Expected behaviour [期望结果]

subtext文本过长,想通过设置subtextStyle的width来限制换行,看文档,必须开启rich,开启rich后,依旧没有变化

ECharts option [ECharts配置项]

option = {
title: {
          text: o_prov['prov'],
          subtext: o_other['sub_text'],
          sublink: o_other['sub_link'],
          subtextStyle:{
            color:'#666666',
            normal:{
              formatter: '{a}',
              rich: {
                a: {
                  color: 'red',
                  width: '30%',
                  height: '50%',
                  lineHeight: 30
                }
              }
            }
          },
          left: 'left',
          textStyle: {
            color: '#666666'
          }
        },
}

Other comments [其他信息]

望求助~

@pissang
Copy link
Contributor

pissang commented Apr 18, 2018

去掉 normal

@pissang pissang closed this as completed Apr 18, 2018
@arashdalir
Copy link

I also have the same problem. the formatter function actually is never called. normal is omitted as mentioned by @pissang .

var chart = echarts.init(document.getElementById('chart'), null, {
	"devicePixelRatio": null,
	"renderer": "svg",
	"width": null,
	"height": "600px"
});
chart.setOption({
	"title": {
		"text": "Main Title",
		"subtext": "Sub Title",
		"show": true,
		"width": "100%",
		"top": "top",
		"left": "center",
		"textStyle": {"color": "#306fb6"},
		"subtextStyle": {
			"color": "#306fb6",
			//"formatter": '{a}\n{hr|}',
			"formatter": function(params){
				return params + "\n{hr|}";
			},
			"rich": {
				"hr": {
					"borderColor": "#999999",
					"width": "100%",
					"borderWidth": 2,
					"height": 2,
					"lineHeight": 10
				}
			}
		}
	}
});

@100pah
Copy link
Member

100pah commented Oct 31, 2018

There is no subtextStyle.formatter.

Just put the formatter string into subtext: 'xxxx'

@arashdalir
Copy link

arashdalir commented Oct 31, 2018 via email

@arashdalir
Copy link

chart_15409992085bd9c8289fdca.setOption({
	"title": {
		"text": "Main Title",
		"subtext": "Sub Title\n{hr|}",
		"show": true,
		"width": "100%",
		"top": "top",
		"left": "center",
		"textStyle": {"color": "#306fb6"},
		"subtextStyle": {
			"color": "#306fb6",
			"rich": {
				hr: {
					"borderColor": "#999999",
					"width": "100%",
					"borderWidth": 2,
					"height": 2,
					"lineHeight": 10
				}
			}
		}
	}
});

image

@arashdalir
Copy link

@100pah any ideas? your help would be really appreciated...

@madreamis
Copy link

titleArr.push({
text: item.type,
subtext: ${item.name}{hr|},
left: index * 30 + 20 + '%',
top: '15%',
textAlign: 'center',
textStyle: {
fontWeight: 'normal',
fontSize: '20',
color: colors[index][0],
textAlign: 'center',
},
subtextStyle: {
fontWeight: 'normal',
fontSize: '18',
color: colors[index][0],
textAlign: 'center',
rich: {
hr: {
lineHeight: 350
}
}
},
});

@953155109
Copy link

chart_15409992085bd9c8289fdca.setOption({
    "title": {
        "text": "Main Title",
        "subtext": "Sub Title\n{hr|}",
        "show": true,
        "width": "100%",
        "top": "top",
        "left": "center",
        "textStyle": {"color": "#306fb6"},
            "subtextStyle": {
            "color": "#306fb6",
            "formatter": '{hr}',
            "rich": {
                hr: {
                "borderColor": "#999999",
                "width": "100%",
                "borderWidth": 2,
                "height": 2,
                "lineHeight": 10
                }
            }
        }
    }
});

@arashdalir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants