bestsamsg commented on issue #18967:
URL: https://github.com/apache/echarts/issues/18967#issuecomment-2581662739
可以通过脚本替换实现itemGap分别在水平与垂直方向进行独立控制,我这里在`npm start`的 脚本前,添加了命令,比如:
`node ./patchEcharts.js&&set PORT=8004&&set RUN_ENV=START&&set
BUILD_ENV=PROD&&set BASE_PATH=%npm_config_basePath%&&max dev --progress`
后续在打包脚本中也需要同样的处理,需要注意的是,为了避免重复替换,替换后的字符串内容要做一个差异处理,比如减少一个空格。
patchEcharts.js
```
const replace = require("replace");
replace({
// regex: 'warning\\([^\n\r]*\\);',
regex:'var currentLineMaxSize = 0;',
//减少一个空格避免重复匹配替换, 其他replace保持一致
replacement: `
var currentLineMaxSize= 0;
//add-begin
let gapList = [];
if(typeof gap === 'string' || typeof gap === 'number'){
gapList = [gap, gap];
}else if(gap instanceof Array){
gapList = [gap[0], gap[1]];
}
//add-end
`,
paths: ['node_modules/echarts/lib/util/layout.js'],
recursive: true,
limit:1000,
silent: false,
multiline:true,
});
replace({
// regex: 'warning\\([^\n\r]*\\);',
regex:'y \\+= currentLineMaxSize \\+ gap;',
replacement: `
y+= currentLineMaxSize + gapList[1];
`,
paths: ['node_modules/echarts/lib/util/layout.js'],
recursive: true,
multiline:true,
});
replace({
// regex: 'warning\\([^\n\r]*\\);',
regex:'x \\+= currentLineMaxSize \\+ gap;',
replacement: `
//replace-begin
x+= currentLineMaxSize + gapList[0];
//replace-end
`,
paths: ['node_modules/echarts/lib/util/layout.js'],
recursive: true,
multiline:true,
});
replace({
// regex: 'warning\\([^\n\r]*\\);',
regex:"orient === 'horizontal' \\? x = nextX \\+ gap : y = nextY \\+
gap;",
replacement: `
//replace-begin
orient=== 'horizontal' ? x = nextX + gapList[0] : y = nextY + gapList[1];
//replace-end
`,
paths: ['node_modules/echarts/lib/util/layout.js'],
recursive: true,
multiline:true,
});
```
我看这个feature 23年已经提交了,但为何demo上还是没能实现对应功能
--
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]