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

堆叠柱形图在使用 Slider 时,更新数据会导致柱形图渲染比例错误 #6466

Open
lfeng opened this issue Sep 12, 2024 · 1 comment

Comments

@lfeng
Copy link

lfeng commented Sep 12, 2024

问题描述

开启了 Slider 的柱形图,当柱形数量超过当前可是宽度时,更新数据会导致柱形的比例渲染异常

import { Chart } from '@antv/g2';
const data = [
  { name: 'London', 月份: 'Jan.', 月均降雨量: 18.9 },
  { name: 'London', 月份: 'Feb.', 月均降雨量: 28.8 },
  { name: 'London', 月份: 'Mar.', 月均降雨量: 39.3 },
  { name: 'London', 月份: 'Apr.', 月均降雨量: 81.4 },
  { name: 'London', 月份: 'May', 月均降雨量: 47 },
  { name: 'London', 月份: 'Jun.', 月均降雨量: 20.3 },
  { name: 'London', 月份: 'Jul.', 月均降雨量: 24 },
  { name: 'London', 月份: 'Aug.', 月均降雨量: 35.6 },

];

const chart = new Chart({
  container: 'container',
  autoFit: true,
});

chart
  .interval()
  .data(data)
  .encode('x', '月份')
  .encode('y', '月均降雨量')
  //.encode('color', 'name')
  //.transform({ type: 'stackY' })
  .interaction('elementHighlight', { background: true })
  .slider('x', {values: [0, 0.5]});

chart.render();

setTimeout(() => {
  const node =chart.getNodeByType('interval');
  node.data(data);
  chart.render();
}, 3000);
@lfeng lfeng changed the title 堆叠柱形图在使用 Slider 是,更新数据会导致柱形图渲染比例错误 堆叠柱形图在使用 Slider 时,更新数据会导致柱形图渲染比例错误 Sep 12, 2024
@qiukl
Copy link

qiukl commented Sep 25, 2024

加.scrollbar('x', {ratio:[0, 1]})就可以,不知道什么原理

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

2 participants