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

[Bug] sequence chart左侧的坐标轴内容过长时,不会自动调整区域宽度,或者隐藏内容,而会直接伸入表格内部(如官方文档案例中的NBA球员上场时间表) #3703

Open
Black-Zhong opened this issue Feb 5, 2025 · 2 comments
Assignees

Comments

@Black-Zhong
Copy link

Image

如上图所示,sequence chart左侧的坐标轴内容过长时,不会自动调整区域宽度,或者隐藏内容,而会直接伸入表格内部。
(link:https://www.visactor.io/vchart/demo/sequence-chart/NBA-player-event?keyword=axis

希望可以像下图这样,自动调整坐标轴区域宽度,或者隐藏过长的文本内容

Image

(link:https://www.visactor.io/vchart/demo/axis/style

尝试自行添加一个orient: 'left'的坐标轴(如下图),只会造成格式混乱,但其实是可以看到成功添加上了一个坐标轴

Image

axes: [
{
orient: 'top',
type: 'time',
range: {
min: -2209017943000,
max: -2209015063000
},
layers: [
{
tickStep: 28800,
timeFormat: '%Y%m%d'
},
{
tickStep: 28800,
timeFormat: '%H:%M'
}
]
},
{ // 以下新增一个左侧的坐标轴
orient: 'left',
type: 'band',
},
],

@Black-Zhong Black-Zhong changed the title sequence chart左侧的坐标轴内容过长时,不会自动调整区域宽度,或者隐藏内容,而会直接伸入表格内部(如官方文档案例中的NBA球员上场时间表) [bug]sequence chart左侧的坐标轴内容过长时,不会自动调整区域宽度,或者隐藏内容,而会直接伸入表格内部(如官方文档案例中的NBA球员上场时间表) Feb 5, 2025
@Black-Zhong Black-Zhong changed the title [bug]sequence chart左侧的坐标轴内容过长时,不会自动调整区域宽度,或者隐藏内容,而会直接伸入表格内部(如官方文档案例中的NBA球员上场时间表) [bug] sequence chart左侧的坐标轴内容过长时,不会自动调整区域宽度,或者隐藏内容,而会直接伸入表格内部(如官方文档案例中的NBA球员上场时间表) Feb 5, 2025
@Black-Zhong Black-Zhong changed the title [bug] sequence chart左侧的坐标轴内容过长时,不会自动调整区域宽度,或者隐藏内容,而会直接伸入表格内部(如官方文档案例中的NBA球员上场时间表) [Bug] sequence chart左侧的坐标轴内容过长时,不会自动调整区域宽度,或者隐藏内容,而会直接伸入表格内部(如官方文档案例中的NBA球员上场时间表) Feb 5, 2025
@xile611
Copy link
Contributor

xile611 commented Feb 6, 2025

左侧的标题不参与布局过程,所以不能自动撑开区域

@skie1997 看看有其他方案实现类似的效果吗?

@skie1997
Copy link
Contributor

@Black-Zhong ”dot series左侧的文字“并非坐标轴实现的,如果要预留足够的空间 / 实现省略可以采取下面的方案:

  1. 遍历数据,得到最长的左侧文字,并计算占位,赋给spec.appendPadding

Image

  const maxYDataLens = dotData.reduce((acc, cur) => {
    return Math.max(acc, cur['player_name'].length);
  }, 0);

  const yTitleFontSize = 14;

  const spec = {
    type: 'sequence',
    color: ['#64b5fc', '#ff8f62'],
    appendPadding: {
      left: maxYDataLens * yTitleFontSize,
      right: 80
    }
   // 省略其他内容
   }
  1. 直接处理文字,超出长度,显示省略内容

Image

  const spec = {
    type: 'sequence',
    color: ['#64b5fc', '#ff8f62'],
    appendPadding: {
      left: 80,
      right: 80
    },
    series: [
      {
        type: 'link',
        // 省略内容
      },
      {
        type: 'dot',
        // 省略内容
        title: {
          style: {
            fill: 'rgba(46, 47, 50)',
            fontSize: yTitleFontSize,
            text: datum => {
              return datum['player_name'].length > 8 ? datum['player_name'].slice(0, 8) + '...' : datum['player_name'];
            }
          }
        },
        // 省略内容
    ],
    

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

3 participants