Page 1 of 2

HighCharts - lose the plot gracefully

Posted: Mon 25 Nov 2019 12:57 am
by beteljuice
graphfixPro.js V1.1 - English bug fix - 6th Feb 2021

Following quite a few people wanting to modify the highcharts as provided (cumuluscharts.js), the beteljuice has created a 'plug-in' for the HTML page that holds them.

This script allows you to completely remove or change the default visibility of plots
created by cumuluscharts.js.

It can now rename / translate your titles / labels / tooltips etc.

Wherever your holding page is generated is and this javascript file is where you need to edit.

It will NOT remove graphs (edit your buttons for that).
You cannot remove the 'first' plot in any graph (the beteljuice seriously can't be bothered to write code for that !)

Here's the script and a README
graphfixPro.zip

Usage:

Edit graphfixPro.js as per the README, some examples below and upload to same directory as 'charts' page.
At the bottom of the page containing the charts ADD below all the charts scripts

<script src="graphfixPro.js"></script>

Important:
Then in the same page edit ALL the 'buttons' for the graphs
so that they end with rollout();

<input name="btnTemp" class="button" style=tabindex="1" type="button" value="Temperature" onclick="changeGraph('temp'); rollout();">

EXAMPLES:-

Names are case sensitive and ENGLISH.
GRAPH name is the 'main' title at the top of the graphs.
PLOT names are the individual traces.
NB: "Temperature" GRAPH has a "Temperature" PLOT !

Code: Select all

// beteljuice plot REMOVER - cannot remove first plot of graph !!
// format: ['graph name', 'plot to lose 1', 'plot to lose 2'], NB: NO comma after last (or only) entry !

example: single graph, single plot
lose_plot = [
				["Temperature", "Inside"]
			];
			
example: single graph, muliple plots
lose_plot = [
				["Temperature", "Dew Point", "Wind Chill", "Heat Index"]
			];
			
example: multiple graphs, muliple plots
lose_plot = [
				["Temperature", "Dew Point", "Wind Chill", "Heat Index"],
				["Relative Humidity", "Indoor Humidity"]
			];


// ** A little bit more involved **
// beteljuice plot default VISIBILY - CAN hide first plot of graph 
// format: ['graph name', ['plot to show / hide 1', true],
//						  ['plot to show / hide 2', false] NB: NO comma after last plot !
//			], NB: NO comma after last graph !

example: single graph, single plot
display_plot = [
					["Temperature", ["Temperature", false]]
				];

example: single graph, multiple plots
display_plot = [
					["Temperature", ["Temperature", false], ["Wind Chill", true]]
				];

example: multiple graphs, multiple plots
display_plot = [
					["Temperature", ["Temperature", false], ["Wind Chill", true]],
					["Relative Humidity", ["Indoor Humidity", false]]
				];
That's it ....

Information on translating is in the README and the file itself.

If you've already modified the distribution copy of the cumuluscharts.js ... you're on your own :o

Re: HighCharts - lose the plot gracefully

Posted: Mon 25 Nov 2019 3:27 am
by HansR
Ah, nice. I'm gonna try this.... Thnx. :) :clap:

Re: HighCharts - lose the plot gracefully

Posted: Mon 25 Nov 2019 11:57 am
by HansR
@beteljuice: so I implemented the thing and it works... partially. It works in the sense that the series are deactivated (for Temperature). But as a user (as viewer of the webpage) I can still enable the series and view them.

For the series 'Relative Humidity' it does not seem to work at all (the title is: title: {text: 'Relative Humidity'} ) and the series is name: 'Indoor Humidity'). so I entered in the wxgraphs.php file:

Code: Select all

lose_plot = [
			["Temperature", "Inside", "Apparent"]
			["Relative Humidity", "Indoor Humidity"]
		];
and it still shows the indoor humidity.

So, in summary I have the following observations:
1) The series do not really disappear, they are made invisible (but the user can make it still visible)
2) It does not work for Relative Humidity (maybe the two word title?)

Re: HighCharts - lose the plot gracefully

Posted: Mon 25 Nov 2019 1:31 pm
by beteljuice
1) The series do not really disappear, they are made invisible (but the user can make it still visible)
If they are invisible (and no legend) how can they be activated ?

but ... that may be because ...
2) It does not work for Relative Humidity (maybe the two word title?)

Code: Select all

lose_plot = [
			["Temperature", "Inside", "Apparent"]
			["Relative Humidity", "Indoor Humidity"]
		];
read again:

Code: Select all

// format: ['graph name', 'plot to lose 1', 'plot to lose 2'], NB: NO comma after last entry !
lose_plot = [
/* example
			["What", "something else"],
*/
			["Temperature", "Inside", "Apparent"]
		];
You need a comma after your first (Temperature) array ;)

Re: HighCharts - lose the plot gracefully

Posted: Mon 25 Nov 2019 1:41 pm
by HansR
Ah, temperature now indeed works. :oops:
But alas, not the humidity graph. :roll:

And I did check and double checked spelling (title text and naming of the series), actually I used cut and paste but inside humidity stays visible.

Re: HighCharts - lose the plot gracefully

Posted: Mon 25 Nov 2019 2:10 pm
by beteljuice
Ah ... logic error by the beteljuice :oops:

Fixed in first post ...

Re: HighCharts - lose the plot gracefully

Posted: Mon 25 Nov 2019 2:43 pm
by HansR
Ah... OK. Works great now.

Re: HighCharts - lose the plot gracefully

Posted: Thu 27 Feb 2020 11:52 am
by beteljuice
V2 - IMPORTANT bug fix - 27 Feb 2020

Errors through dynamic data loading discovered / resolved.

Please use NEW version (In first post)

Re: HighCharts - lose the plot gracefully

Posted: Thu 27 Feb 2020 9:30 pm
by beteljuice
Version 2.1 27 Feb 2020

:groan: Should've known it was too good to be true ...
Needed the mutation observer to fire up on new graph load as well as initial chart load.

Extra facility ?

Posted: Fri 28 Feb 2020 4:13 pm
by beteljuice
No ... Not a bug fix :lol:

Comment has been made that a user not only wants to REMOVE some plots, but also change default VISIBILITY.

I'm pretty confident I can expand the script to accommodate this if there is an interest ...

Re: HighCharts - lose the plot gracefully

Posted: Fri 28 Feb 2020 4:41 pm
by HansR
Yes, that would be nice.

Re: HighCharts - lose the plot gracefully

Posted: Sun 01 Mar 2020 12:29 am
by beteljuice
V4 -Improved functionality - 29th Feb 2020

The script now allows you to completely remove or change the default visibility of plots
created by cumuluscharts.js.

Re: HighCharts - lose the plot gracefully

Posted: Sun 01 Mar 2020 11:30 am
by HansR
Works great. 8-) :!:

lose the plot gracefully - UPDATE

Posted: Sat 21 Mar 2020 10:07 pm
by beteljuice
Hello Dear Readers ..

IE11 bug fix
NEW - can do translations !

New graphfixPro.js file from first post ...

Re: HighCharts - lose the plot gracefully

Posted: Fri 05 Feb 2021 9:19 pm
by iandrews
Have just set this up on the latest version of CumulusMX (v3.9.7 (3107)) and have a small (well 2) issues.

All seems to be working (e.g I have hidden the Inside Temperature), however the "Wind Dir." chart now doesn't display, there is just white space where the chart should be. I haven't done anything in graphfixPro.js to do with the Wind Dir. chart, and if I remove the <script src="graphfixPro.js"></script> line from the trends.htm file it works again.

Also, if I go to the trends page from another page the Temperature chart (which displays by default) still has the Inside Temperature shown, however if I then click on the Temperature button the Inside Temperature is then not shown. Is there a way to have the Temperature chart display as expected as soon as the page loads without having to click on the button.