简体   繁体   中英

Changing the styles of a label of plotLines in HighChart

In this example http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/xaxis/plotlines-label-align-right/

the label "Plot Line" is on the right side . My aim is to make it to the left and give some gap from the margin .

This is what I have tried .

yAxis: {
        plotLines: [{
            color: 'red',
            width: 2,
            value: 100,
            label: {
                text: 'Plot line',
                align: 'left',
                x: -10,
                style: {
                            color: "green",
                            marginLeft: 4,
                            fontSize: "8px"
                        }
            }
        }]
    }

Even though the label moves to left , the marginLeft or paddingLeft doesnt seem to work . How do I place the label 4px from left?

You can do that by setting x to 4

yAxis: {
    plotLines: [{
        color: 'red',
        width: 2,
        value: 100,
        label: {
            text: 'Plot line',
            align: 'left',
            x: 4
        }
    }]
}

x appears to be the horizontal offset from the starting position as defined by align for the label

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM