marmelo commented on issue #14506: URL: https://github.com/apache/echarts/issues/14506#issuecomment-1157964030
After a couple hours debugging the code I found a workaround. ECharts uses the ZRender library, which supports the `lineOverflow` config: https://github.com/ecomfe/zrender/blob/master/src/graphic/Text.ts#L176 What is happening is that **ECharts is not passing that config to ZRender**. This can be (quick and dirty) fixed by patching `echarts/lib/label/labelStyle.js` (v5.3.2) as follows. ```diff diff --git a/node_modules/echarts/lib/label/labelStyle.js b/node_modules/echarts/lib/label/labelStyle.js index a486107..6ff4e84 100644 --- a/node_modules/echarts/lib/label/labelStyle.js +++ b/node_modules/echarts/lib/label/labelStyle.js @@ -310,6 +310,12 @@ function setTextStyleCommon(textStyle, textStyleModel, opt, isNotNormal, isAttac textStyle.overflow = overflow; } + var lineOverflow = textStyleModel.get('lineOverflow'); + + if (lineOverflow) { + textStyle.lineOverflow = lineOverflow; + } + var margin = textStyleModel.get('minMargin'); if (margin != null) { ``` Sample working config (you need to set both `width` and `height`): ```js { ... xAxis: { ... axisLabel: { ... width: 20, height: 25, overflow: 'break', lineOverflow: 'truncate' // this currently requires an echarts patch } } } ``` **Before:**  **After:**  You may use https://www.npmjs.com/package/patch-package to automatically patch that file when installing you project dependencies. I will try to make contribute to ECharts with a proper PR when I find some free time. In the mean time, if anyone is eager to make this improvement, please go ahead! Feel free to let me know if this works for you. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
