Page 1 of 1

Highcharts graphs hi-low data & month title problem

Posted: Sun 22 Mar 2015 7:48 pm
by mm23
Hello everybody....I need help
On my web page http://vrijemeusibeniku.com/povijesni-prikaz /TEMPERATURA/Ekstremi, data and month titles on X axis does not match...

Month' s titles below the x axis are arranged o.k (considering the beginning of the measurement in November 2014) .... Stu (2014)., Pro (2014)., Sij (2015)., Velj (2015)., Ozu (2015) ...... or on English…… Nov (2014). , Dec., Jan (2015)., Feb., March……but the data are arranged chronologically by month (Jan, Feb, March….), but not in "real" chronological order considering the measurment start, starting from January (2015), February (2015) , March (2015), November (2014), December (2014). I solved this problem when it first came out, but when the next month completed, it all comes back again like it is now.
In short that means that where below the x-axis wrote November, are displayed data for January.....etc

Somebody please help….. or I just have to wait until one (first) year of the measurements finished


All of the above refers to data for temperature (Temperatura) and wind (Vjetar)

Thanks!

Re: Highcharts graphs hi-low data & month title problem

Posted: Sun 22 Mar 2015 8:40 pm
by mcrossley
I'm not sure I follow. It looks OK to me.

The y-axis is showing the months in the correct order: Jan -> Dec (Sij -> Pro)

You only have data for Nov (2014), Dec, Jan, Feb Mar. And that is being plotted against the correct months, the last two columns and the first three.

Perhaps the name is confusing, I called it 'by year', it would be better called 'by month'.

Re: Highcharts graphs hi-low data & month title problem

Posted: Sun 22 Mar 2015 9:27 pm
by mm23
....hard to explain....
If you look at the data for last month Ozu. (March), the minimum temperature was -4. 6 .... actually it's data for December http://vrijemeusibeniku.com/tablica-noa ... 2014&mo=12

Thanks!

Re: Highcharts graphs hi-low data & month title problem

Posted: Sun 22 Mar 2015 11:01 pm
by mcrossley
Ah, sorry, I was looking at the wrong graph :oops:

You are correct, the SQL select statement will not work with the graph until you have a full years worth of data.

In order to fix that I think you would have to create a temporary table with twelve rows - one for each month and left join the dayfile table to it.
Or, you could do a join against some unions like this...

Code: Select all

SELECT MAX(d.MaxTemp), MIN(d.MinTemp), ROUND(AVG(d.MaxTemp), 1), ROUND(AVG(d.MinTemp), 1)
FROM (
	SELECT 1 AS MONTH
	UNION SELECT 2
	UNION SELECT 3
	UNION SELECT 4
	UNION SELECT 5
	UNION SELECT 6
	UNION SELECT 7
	UNION SELECT 8
	UNION SELECT 9
	UNION SELECT 10
	UNION SELECT 11
	UNION SELECT 12
) AS m
LEFT JOIN daydata d
ON date_format(d.logdate, '%c') = m.month
GROUP BY m.month
Your problem then would be how HighCharts would cope with null values for the missing months

Re: Highcharts graphs hi-low data & month title problem

Posted: Mon 23 Mar 2015 9:54 pm
by mm23
Many thanks Mark for your help and quick response.
I'll see what I can do about this issue.....

Re: Highcharts graphs hi-low data & month title problem

Posted: Tue 24 Mar 2015 9:51 am
by mcrossley
I just tested adding null values as both text "null" and straight reference null to a bar graph, and HighCharts coped fine, it didn't plot anything for those series with null, and plotted the two valid values in the last two columns.

Look at the 1800 plot inthis JSFiddle

Re: Highcharts graphs hi-low data & month title problem

Posted: Tue 24 Mar 2015 10:26 am
by mcrossley
Actually, I fixed this a better way, the temperature and wind hi/lo PHP scripts have been updated on my site to cope with tables that only have partial year data. It makes to response slightly larger, but means they should now work for everyone.

Re: Highcharts graphs hi-low data & month title problem

Posted: Tue 24 Mar 2015 9:05 pm
by mm23
Is there any chance that I "borrow" these scripts or I'll have to "handle" on any other way :arrow: ;) .....

Anyway, thanks a lot again......

Re: Highcharts graphs hi-low data & month title problem

Posted: Tue 24 Mar 2015 9:08 pm
by mcrossley
Sure, you can view the source and copy them to your site.

Re: Highcharts graphs hi-low data & month title problem

Posted: Tue 24 Mar 2015 9:30 pm
by mm23
....you talking 'bout historicTemperatureYearly and historicWindYearly ?

Re: Highcharts graphs hi-low data & month title problem

Posted: Tue 24 Mar 2015 10:08 pm
by mcrossley
Nope, I thought the problem was with historicTemperatureHiLo.php and the corresponding wind version?

Re: Highcharts graphs hi-low data & month title problem

Posted: Tue 24 Mar 2015 10:27 pm
by mm23
Yes, Mark sorry.....you are right. I messed up with the script name.......

Re: Highcharts graphs hi-low data & month title problem

Posted: Tue 24 Mar 2015 10:43 pm
by mcrossley
Let me know if the updates do fix the problem for you.