如何在对面而不是默认情况下给出plotlines文本样式

时间:2016-06-18 12:23:57

标签: highcharts highstock

我使用Highcharts创建了一个图表。绘制在X轴上绘制线条。我想在对面显示情节线而不是默认

我的代码是

plotLines: [{
                value: pur_time,
                width: 2 ,
                color: '#656568',
                dashStyle: 'dash',
                id: 'plotline',
                label: {
                          text: 'Purchase deadline',
                          style: {
                            color: '#656568',
                            fontWeight: 'bold'
                          }
                        }
            },{
                value: exp_time,
                width: 2 ,
                color: '#A28F29',
                id: 'plotline1',
                label: {
                          text: 'Expiration time',
                          opposite: true,
                          style: {
                            color: '#686A3B',
                            fontWeight: 'bold'
                          }
                        }
            }]

以下是我实际得到的样本

enter image description here

我期待的样子是

enter image description here

1 个答案:

答案 0 :(得分:2)

尝试绘制线标签的rotation属性(请参阅http://api.highcharts.com/highcharts#xAxis.plotLines.label.rotation)。

我修改了API文档中的演示小提琴以匹配您要查找的内容:http://jsfiddle.net/brightmatrix/kuyy5p6f/

          label: {
            text: 'Plot line',
            verticalAlign: 'middle',
            textAlign: 'center',
            rotation: 270,
            x: -5
          }

在这种情况下,我将rotation设置为270以将其翻转,并设置x-5以将其推向左侧。

我希望这有用!