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

X轴标签自动倾斜角度不合理 #185

Open
prettydoll opened this issue Jan 30, 2018 · 0 comments
Open

X轴标签自动倾斜角度不合理 #185

prettydoll opened this issue Jan 30, 2018 · 0 comments

Comments

@prettydoll
Copy link

prettydoll commented Jan 30, 2018

我的需求/我的问题

当X轴标签的长度不均匀,个别标签长度非常长时,自动倾斜角度不合理,导致X轴标签全部重叠在一起。
应该是因为倾斜角度目前的算法是:360/标签长度的最大值 来计算的
如果最大值特别大时,就会导致倾斜角度很小,数据都叠在一起
所有的图都有这个问题

数据以及出现问题的源代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height">
    <title>基础柱状图</title>
    <style>::-webkit-scrollbar{display:none;}html,body{overflow:hidden;height:100%;}</style>
</head>
<body>
<div id="mountNode"></div>
<script>/*Fixing iframe window.innerHeight 0 issue in Safari*/document.body.clientHeight;</script>
<script src="https://gw.alipayobjects.com/os/antv/assets/g2/3.0.4/g2.min.js"></script>
<script src="https://gw.alipayobjects.com/os/antv/assets/data-set/0.8.5/data-set.min.js"></script>
<script>
  const data = [
    { year: '1951111111111111111111111111 年', sales: 38 },
    { year: '19521111111aaaaa 年', sales: 52 },
    { year: '1956 年', sales: 61 },
    { year: '1957 年', sales: 145 },
    { year: '1958 年', sales: 48 },
    { year: '1959 年', sales: 38 },
    { year: '1960 年', sales: 38 },
    { year: '1962 年', sales: 38 },
  ];
  const chart = new G2.Chart({
    container: 'mountNode',
    forceFit: true,
    height: window.innerHeight
  });
  chart.source(data);
  chart.scale('sales', {
    tickInterval: 20
  });
  chart.interval().position('year*sales');
  chart.render();
</script>
</body>
</html>

G2 or G2-mobile or G6 的版本以及使用环境

  • G2 3.0.4
  • 使用环境: windows 7, Chrome 4 (目测与使用环境无关)
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

1 participant