【问题标题】:Highcharts nodes are not rendered wide enoughHighcharts 节点的渲染宽度不够
【发布时间】:2021-02-03 17:55:42
【问题描述】:

我有一个高角的组织结构图,当图表中有很多节点时,框会变小并且它们的文本会被隐藏。如何使图表根据需要展开(并显示水平滚动条),以便所有内容都完全可见?

你可以看到一个例子here。

我的图表选项是这些

chartOptions: Highcharts.Options = {
    chart: { inverted: true },
    title: {  text: null },
    tooltip: {
      useHTML: true,
      padding: 10,
      style: { fontStyle: 'normal' },
      outside: true,
      distance: 30
    },
    series: [
      {
        type: 'organization',
        name: null,
        keys: ['from', 'to'],
        data: [],
        nodes: [],
        colorByPoint: false,
        color: 'white',
        borderColor: '#c1c1c1',
      }
    ]
  };

和html

<highcharts-chart 
  [Highcharts]="Highcharts"
  [options]="chartOptions" 
  style="width: 100%; height: 100%; display: block;"
></highcharts-chart>

【问题讨论】:

    标签: highcharts angular2-highcharts


    【解决方案1】:

    将chart.width 属性设置为适合您的值,并更改图表容器的默认overflow 样式。

    JS:

    chart: {
        width: 2000,
        ...
    },
    

    CSS:

    #container {
        overflow: scroll !important;
    }
    

    现场示例: https://jsfiddle.net/BlackLabel/t3b9fren/

    API 参考: https://api.highcharts.com/highcharts/chart.width

    【讨论】:

    • 我认为我的问题没有解决方案。如果我将宽度设置为 2000,那么节点的长度也会增加。我无法设置节点宽度,因为我事先不知道它们的内容,它是动态的。我必须尝试另一个库。
    • 嗨@Konstantinos Papakonstantinou,您还可以动态计算和设置图表宽度,例如:jsfiddle.net/BlackLabel/xcbfg1e4
    猜你喜欢
    • 2013-03-18
    • 1970-01-01
    • 2012-01-23
    • 2014-11-03
    • 1970-01-01
    • 2020-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多