Horizontal line with Highcharts

60 views
Skip to first unread message

Andre

unread,
Jun 18, 2020, 12:40:19 PM6/18/20
to weewx-user
Is it possible to draw a horizontal colored line on specific yaxis value?
I need a fixed line to show peak values.

Regards Andre

Manfred Maier

unread,
Jun 18, 2020, 12:43:28 PM6/18/20
to weewx-user
Hi,
a line like on my barometer chart (www.wetter-zorneding.de)?

If so: Yes, that's possible but requires some additional lines in the belchertown.js.tmpl

In case this is what you are looking for, I can copy my code here.


Manfred 

Andre

unread,
Jun 18, 2020, 12:49:15 PM6/18/20
to weewx-user
Yes, this is excacly what I'm looking for.
Your code sharing will be very nice.

Manfred Maier

unread,
Jun 18, 2020, 12:57:16 PM6/18/20
to weewx-user
Here you go:

                // Barometer chart plots get a higher precision yAxis tick
                if (s.obsType == "barometer") {
                    if ( typeof s.yAxis_tickInterval === "undefined" ) { 
                        // If no tick interval override, set 0.01 as default tick interval to satisfy an old request for this level of precision. 
                        options.yAxis[this_yAxis].tickInterval = 0.01;
                    }
                    // Define yAxis label float format if rounding is defined. Default to 2 decimals if nothing defined
                    if ( typeof s.rounding !== "undefined" ) {
                        options.yAxis[this_yAxis].labels = { format: '{value:.'+s.rounding+'f}' }
                    } else {
                        options.yAxis[this_yAxis].labels = { format: '{value:.2f}' }
                    }
                    options.yAxis[this_yAxis].plotLines = [{
                        value: 1013.25,
                        color: '#E5544E',
                        width: 1,
                        dashStyle: 'ShortDash',
                        zIndex: 0,
                    }]
                }

                // Dewpoint chart plots get Schwuele indicator for the yAxis
                if (s.obsType == "dewpoint") {
                    options.yAxis[this_yAxis].plotLines = [{
                        value: 17,
                        color: '#E5544E',
                        width: 1,
                        dashStyle: 'ShortDash',
                        zIndex: 0,
                    },
                    {
                        value: 19.9,
                        color: '#E5544E',
                        width: 1,
                        dashStyle: 'ShortDash',
                        zIndex: 0,
                    }]
                }



The first 10 lines or so are already part of the belchertown.js.tmpl (in the 'js' folder) - from line 1374 onwards (in my case). 
The code in bold writing adds a line to the barometer chart. And the next section adds two lines to the Dewpoint chart.

You probably will want to adapt this 'dewpoint' part to your needs.

Manfred 

Andre

unread,
Jun 18, 2020, 1:02:00 PM6/18/20
to weewx-user
Many thanks, Manfred.
So langsam muss ich mal über eine eigene Danksagungseite nur für Dich nachdenken. ;)

Manfred Maier

unread,
Jun 18, 2020, 1:04:33 PM6/18/20
to weewx-user
Keine Sache. Ich habe hier auch unzählige Fragen gestellt und war froh, wenn mir jemand geholfen hat.
Einige meiner Fragen hast Du jetzt auch und ich kenne mittlerweile die Antworten :)

Reply all
Reply to author
Forward
0 new messages