Replies: 1 comment 1 reply
-
在 G2 V5 中,实现 slider 拖动 X 轴后自动调整 Y 轴到最佳值范围的功能可以通过以下步骤来实现:
关于 以下是一个简单的代码示例: chart.on('sliderX:filter', (ev) => {
const filteredData = getFilteredData(ev); // 获取当前可见的数据
const yValues = filteredData.map(d => d.y);
const yMin = Math.min(...yValues);
const yMax = Math.max(...yValues);
chart.scale('y', {
min: yMin,
max: yMax,
});
chart.render();
}); 请确保在 如果你在实现过程中遇到问题或有其他疑问,请随时告诉我! 🪧 TipsFor further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
尝试过监听
sliderX:filter
设置设置y
的domain
,执行chart.render()
会复位slider
的交互。加上监听slider
的valuechange
最后一次值在render
前重新赋值也不行。如何实现才是正确的方法?
看到v4里是有
chart.render(update: boolean)
,v5 迁移文档也提及替代方案。Beta Was this translation helpful? Give feedback.
All reactions