Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I plot a diagonal plotline in highcharts?

Tags:

highcharts

Is it possible to have a diagonal plotline in highcharts?

I have a line chart which tracks weightloss (y axis = weight, x axis = time), and I need a plotline which starts at the initial weight, and plots diagonally to the time when the user should have lost the weight by.

I can plot a simply flat plotline like this:

plotLines: [{
            value: 0.696,
            width: 3,
            color: 'red',
            dashStyle: 'dash',
            label: {
                text: 'Latest value',
                align: 'right',
                y: 5,
                x: 0
            }
        }]

but, that's just a simple flat line.

Any ideas?

like image 930
ojsglobal Avatar asked May 01 '26 17:05

ojsglobal


1 Answers

Easiest way is to simply use a separate line series.

Plot just your first and last point. You can disable markers, turn off mousetracking, and hide from the legend if you want it to behave just like a plotLine.

http://api.highcharts.com/highcharts#plotOptions.series.enableMouseTracking

http://api.highcharts.com/highcharts#plotOptions.series.marker.enabled

http://api.highcharts.com/highcharts#plotOptions.series.showInLegend

like image 60
jlbriggs Avatar answered May 05 '26 14:05

jlbriggs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!