Truncated axis labels even with cotainLabel = true
See original GitHub issueOne-line summary [问题简述]
Sometimes setting grid.containLabel = true does not correctly account for the length of all labels.
Version & Environment [版本及环境]
- ECharts version [ECharts 版本]: 3.8.5
- Browser version [浏览器类型和版本]: Chrome 62
- OS Version [操作系统类型和版本]: OS X High Sierra
Expected behaviour [期望结果]
The x Axis labels should fit in the grid without getting truncated. When testing it out, you may need to resize your browser window to get all of the labels to show for each bar. I’m guessing that there’s probably some kind of optimization in ECharts that only calculates the label rectangle width for some of the values and not all of the ones passed.
ECharts option [ECharts配置项]
option = {
"color": [
"#c23531",
"#2f4554",
"#61a0a8",
"#d48265",
"#91c7ae",
"#749f83",
"#ca8622",
"#bda29a",
"#6e7074",
"#546570",
"#c4ccd3"
],
"textStyle": {
"fontFamily": "sans-serif",
"fontSize": 12,
"fontStyle": "normal",
"fontWeight": "normal"
},
"animation": "auto",
"animationDuration": 1000,
"animationDurationUpdate": 300,
"animationEasing": "exponentialOut",
"animationEasingUpdate": "cubicOut",
"animationThreshold": 2000,
"progressiveThreshold": 3000,
"progressive": 400,
"hoverLayerThreshold": 3000,
"useUTC": false,
"yAxis": [
{
"type": "value",
"boundaryGap": [
0,
0
],
"splitNumber": 5,
"show": true,
"zlevel": 0,
"z": 0,
"inverse": false,
"name": "",
"nameLocation": "end",
"nameRotate": null,
"nameTruncate": {
"maxWidth": null,
"ellipsis": "...",
"placeholder": "."
},
"nameTextStyle": {},
"nameGap": 15,
"silent": false,
"triggerEvent": false,
"tooltip": {
"show": false
},
"axisPointer": {},
"axisLine": {
"show": true,
"onZero": true,
"onZeroAxisIndex": null,
"lineStyle": {
"color": "#333",
"width": 1,
"type": "solid"
},
"symbol": [
"none",
"none"
],
"symbolSize": [
10,
15
]
},
"axisTick": {
"show": true,
"inside": false,
"length": 5,
"lineStyle": {
"width": 1
}
},
"axisLabel": {
"show": true,
"inside": false,
"rotate": 0,
"showMinLabel": null,
"showMaxLabel": null,
"margin": 8,
"fontSize": 12
},
"splitLine": {
"show": true,
"lineStyle": {
"color": [
"#ccc"
],
"width": 1,
"type": "solid"
}
},
"splitArea": {
"show": false,
"areaStyle": {
"color": [
"rgba(250,250,250,0.3)",
"rgba(200,200,200,0.3)"
]
}
},
"offset": 0,
"rangeEnd": null,
"rangeStart": null
}
],
"xAxis": [
{
"type": "category",
"axisLabel": {
"rotate": 90,
"interval": "auto",
"show": true,
"inside": false,
"showMinLabel": null,
"showMaxLabel": null,
"margin": 8,
"fontSize": 12
},
"data": [
"England",
"CA",
"NY",
"TX",
"FL",
"Ontario",
"VA",
"British Columbia",
"Dublin",
"GA",
"CO",
"Alberta",
"IL",
"WA",
"Zuid-Holland",
"MD",
"NJ",
"New South Wales",
"PA",
"TN",
"Vaud",
"MN",
"MA",
"AZ",
"Zurich",
"Ile-de-France",
"Sicilia",
"MI",
"Scotland",
"Queensland",
"Cork",
"HI",
null,
"Victoria",
"Rhone-Alpes",
"Stockholm",
"UT",
"Western Australia",
"MS",
"Meath",
"Geneve",
"Noord-Holland",
"Dubayy",
"CT",
"AR",
"Brussels (Bruxelles)",
"Quebec",
"Bayern",
"Oslo",
"Brittany"
],
"boundaryGap": true,
"splitLine": {
"show": false,
"lineStyle": {
"color": [
"#ccc"
],
"width": 1,
"type": "solid"
}
},
"axisTick": {
"alignWithLabel": false,
"interval": "auto",
"show": true,
"inside": false,
"length": 5,
"lineStyle": {
"width": 1
}
},
"show": true,
"zlevel": 0,
"z": 0,
"inverse": false,
"name": "",
"nameLocation": "end",
"nameRotate": null,
"nameTruncate": {
"maxWidth": null,
"ellipsis": "...",
"placeholder": "."
},
"nameTextStyle": {},
"nameGap": 15,
"silent": false,
"triggerEvent": false,
"tooltip": {
"show": false
},
"axisPointer": {},
"axisLine": {
"show": true,
"onZero": true,
"onZeroAxisIndex": null,
"lineStyle": {
"color": "#333",
"width": 1,
"type": "solid"
},
"symbol": [
"none",
"none"
],
"symbolSize": [
10,
15
]
},
"splitArea": {
"show": false,
"areaStyle": {
"color": [
"rgba(250,250,250,0.3)",
"rgba(200,200,200,0.3)"
]
}
},
"offset": 0,
"rangeEnd": null,
"rangeStart": null
}
],
"grid": [
{
"left": 10,
"top": 10,
"bottom": 10,
"right": 10,
"containLabel": true,
"show": false,
"zlevel": 0,
"z": 0,
"backgroundColor": "rgba(0,0,0,0)",
"borderWidth": 1,
"borderColor": "#ccc"
}
],
"series": [
{
"type": "bar",
"data": [
{
"value": 120000
},
{
"value": 113350
},
{
"value": 61200
},
{
"value": 55500
},
{
"value": 51600
},
{
"value": 46800
},
{
"value": 40400
},
{
"value": 28800
},
{
"value": 28800
},
{
"value": 28200
},
{
"value": 27400
},
{
"value": 26400
},
{
"value": 24000
},
{
"value": 24000
},
{
"value": 23100
},
{
"value": 22800
},
{
"value": 22800
},
{
"value": 20400
},
{
"value": 20400
},
{
"value": 19500
},
{
"value": 19200
},
{
"value": 19200
},
{
"value": 18000
},
{
"value": 16850
},
{
"value": 16800
},
{
"value": 16800
},
{
"value": 16200
},
{
"value": 15600
},
{
"value": 15600
},
{
"value": 14400
},
{
"value": 14400
},
{
"value": 13200
},
{
"value": 13200
},
{
"value": 13200
},
{
"value": 13200
},
{
"value": 13200
},
{
"value": 12300
},
{
"value": 12000
},
{
"value": 11100
},
{
"value": 11100
},
{
"value": 10800
},
{
"value": 10800
},
{
"value": 10800
},
{
"value": 10800
},
{
"value": 9900
},
{
"value": 9600
},
{
"value": 9600
},
{
"value": 9600
},
{
"value": 9600
},
{
"value": 8700
}
],
"zlevel": 0,
"z": 2,
"coordinateSystem": "cartesian2d",
"legendHoverLink": true,
"barMinHeight": 0,
"barMinAngle": 0,
"itemStyle": {}
}
]
}
Other comments [其他信息]
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Truncated axis labels even with cotainLabel = true #7171
One-line summary [问题简述] Sometimes setting grid.containLabel = true does not correctly account for the length of all labels.
Read more >Wrapping, truncating, and auto-rotating axis labels
Wrapping, truncating, and auto-rotating axis labels. This tutorial will explain how you can deal with very long axis labels, by wrapping and/or truncating...
Read more >Bar Chart Y-Axis Labels Truncated?
Hi – I'm using the delivered bar chart widget, and my y-axis labels are truncated, i.e., the whole label doesn't show? Any way...
Read more >Truncated "y" axis label in chart
I have a problem with Excel, the label on the “Y” axis appears truncated even though I have resized the chart. Then, I...
Read more >Google chart x-axis labels truncated
Problem is that when I set my x-axis labels vertical they gets truncated, tried to set more height -> then chart changes size...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Data in the application is dynamic so I can’t have a fixed grid.bottom.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.