首页 > 解决方案 > 适合长 Y 轴标签的 HighCharts

问题描述

我有一些大的垂直(Y)轴标签名称。当它们显示时,它们会缩小实际图表的大小,阅读它们会变得混乱。这是图像:

在此处输入图像描述

如图所示,标签未对齐。如何使它们正确对齐?

以下是我正在使用的图表选项:

{
  "plotOptions": {
    "series": {
      "pointPadding": 0,
      "borderWidth": 0
    }
  },
  "chart": {
    "height": "50%"
  },
  "rangeSelector": {
    "selected": 1
  },
  "title": {
    "text": "Index EOD Analysis"
  },
  "tooltip": {
    "split": true
  },
  "yAxis": [
    {
      "labels": {
        "align": "right",
        "x": -3
      },
      "title": {
        "text": "OHLC"
      },
      "height": "60%"
    },
    {
      "labels": {
        "align": "right",
        "x": -3
      },
      "height": "20%",
      "top": "60%",
      "title": {
        "text": "FII Consolidated PCR"
      }
    },
    {
      "labels": {
        "align": "right",
        "x": -3
      },
      "height": "20%",
      "top": "80%",
      "title": {
        "text": "Net Seller Index"
      }
    }
  ],
  "series": [
    {...}
  ]

标签: highcharts

解决方案


您可以增加标签的宽度:

"yAxis": [...,
    {
        ...
        "title": {
            ...,
            style: {
                width: '200px'
            }
        }
    }
]

现场演示:http: //jsfiddle.net/BlackLabel/eb4g6rtc/

API 参考: https ://api.highcharts.com/highcharts/yAxis.title.style


推荐阅读