Page 20 of 25

Re: Highcharts Graphs

Posted: Sat 07 May 2016 6:43 am
by BeaumarisWX
Hi,
For those still using (realtimeCumulus.js).
I made a tiny change to the (realtimeCumulus.js) as when using the (Drag / over an area) the "Reset zoom" button was always placed on the Chart itself, resulting in it sitting over the top of some graph Lines (depending on selection).
if you wish to reposition "Reset zoom" button as I have (outside the Chart area);
Change this:

Code: Select all

    $(document).ready(function () {
        // define the chart options
        options = {
            chart: {
                renderTo: 'container',
                zoomType: 'x'
            },

            credits: {
To:

Code: Select all

    $(document).ready(function () {
        // define the chart options
        options = {
            chart: {
                renderTo: 'container',
                zoomType: 'x',
				resetZoomButton: {
                position: {
                    align: 'right', // by default
                    verticalAlign: 'top', // by default
                    x: -10,
                    y: 10
                },
                relativeTo: 'chart'
				}
            },

            credits: {
regards,

Re: Highcharts Graphs

Posted: Fri 19 Aug 2016 3:28 pm
by happyweather123
I want to change units in realtime highcharts graphs from mph to km/h. And if i change the text and tooltips on it it only changes the text, but i want to convert the like for an example 4mph to 12km/h.
Can you help ?

Re: Highcharts Graphs

Posted: Fri 19 Aug 2016 3:48 pm
by mcrossley
Your data is already in km/h, so why do you need to convert it?

Re: Highcharts Graphs

Posted: Fri 19 Aug 2016 3:53 pm
by happyweather123
Beacuse it shows the same wind data in mph and also in km/h.

Re: Highcharts Graphs

Posted: Fri 19 Aug 2016 4:27 pm
by mcrossley
OK, for the updates after the page loads you will have to amend the line where the new minutes data gets added to the graph. So around line 60...

Code: Select all

			chart.series[3].addPoint([tim, +getRealtimeValue('wspeed')], false, shift);
to convert from mph to km/h multiply by 1.609344...

Code: Select all

			chart.series[3].addPoint([tim, +getRealtimeValue('wspeed')*1.609344], false, shift);
To convert the historic data loaded when the graph first shows is more complex. You will have to loop through the whole array converting each value.

I'm still pretty sure this isn't what you want to do though. ;) Your data is already in km/h you just need to change the labels from mph to km/h.

Or are you saying you want to add another plot to the graph that shows mph as well as the km/h data already displayed? If so then the conversion needs to be the other way around - and divide by 1.609344.

Re: Highcharts Graphs

Posted: Fri 19 Aug 2016 4:50 pm
by happyweather123
Well i multipled the windspeed at line 60 but it still shows data in mph. And yes. i just want to change the labels.

If i understand you want to say that the new data will accept that change. Am i right?

Re: Highcharts Graphs

Posted: Mon 29 Aug 2016 12:55 am
by Mapantz
As i've been on a bit of a roll with getting these highcharts going with sql lately, I thought i'd have a read through of the last couple of pages, regarding adding the 'sunbyhour' table.
I'm starting with that first, until I get it working, then i'll add the 'sunbymonthhour' if all goes to plan :lol:

Firstly, I created the sunbyhour table, then executed the insert statement that Mark provided.
2016-08-29.png
I think I've done something wrong though, because if I pull it up here: http://www.warehamwx.co.uk/cumulus/util ... Hourly.php

I see that there's no hour prefix showing on each of the values..

Sorry to be a pain, i'm new to all of this, but finding it fascinating to use, as it's much more efficient to get the data and to do things, rather than relying on cronjobs and text files etc..

Best regards.

Apologies - Two minutes after writing all of that, I realised this: :oops:

$ret[] = array((int)$row['hours'], (float)$row['percent']);

Can I also clarify, does the trigger statement get added in to the Dayfile table, with the 'TIME' set to 'AFTER'? I presume it will run that statement, as soon as CMX inserts the new line after midnight?

Re: Highcharts Graphs

Posted: Mon 29 Aug 2016 7:41 pm
by mcrossley
Mapantz wrote: Can I also clarify, does the trigger statement get added in to the Dayfile table, with the 'TIME' set to 'AFTER'? I presume it will run that statement, as soon as CMX inserts the new line after midnight?
Yes, and yes :)

Re: Highcharts Graphs

Posted: Fri 09 Sep 2016 9:41 pm
by Mapantz
This is a strange one, and i've only found it by accident (while changing colours and such, and checking by pressed F5)

http://www.warehamwx.co.uk/cumulus/trends.htm

Click the 'Wind Dir' button and look at the scatter, then click it a few more times, but keep your eye on certain points. It keeps changing the scatter for me. Is that normal, or is something going on?
2016-09-09.png
2016-09-09 (1).png

Re: Highcharts Graphs

Posted: Sat 10 Sep 2016 10:24 am
by mcrossley
Hi Tina, yes it is changing. Here's why...

[Assumption:- you are using a fairly frequent update rate for the real-time data - say 5 seconds]

You have set up the script to return every 15th record from the database (good move if you have very frequent updates, they wouldn't all fit on the graph anyway - though every 12th ~= 1 minute?).

So if you insert a new table row every 5 seconds (guess), then the 'every 15th sub-set moves on every 5 seconds.
You *may*/should see that the pattern repeats - with a new point added at the end - every 15 * 5 secs = 75 seconds or so. (I haven't tried!)

You don't see this effect of the other graphs as the data is slow changing in comparison to wind direction.

I have set the cache TTL for the data returned at 10 minutes on my server, if you did that it would save some load on the server, and a person clicking around the graphs would see consistent data within the same visit.

An alternative approach, would be to amend the database query so it only returned the first row of each new minute, rather than every 15th. Then teh data would be consistent with just the minutes rolling in and out of the 'window'.

Re: Highcharts Graphs

Posted: Sat 10 Sep 2016 12:03 pm
by Mapantz
Ah - I didn't think about that!

So I could amend this then?

Code: Select all

realtimeLogSql.php?recordAge=1440&recordUnit=minute&nth=15&bearing&avgbearing
My realtime upload to sql is every 4 seconds.

PS: I've now moved my anemometer to the chimney, if you take a look at this graph I saved from yesterday, you'll see where it was originally, and then when it was moved. It is much more consistent! :)
chart.png

Re: Highcharts Graphs

Posted: Sat 10 Sep 2016 1:56 pm
by mcrossley
Yep, if you change the "nth=15" parameter, that controls how many data entries are skipped. So at 4 seconds per row, nth=15 should be giving you one record per minute. If you set it at 1 (or delete it) you will get back all the records for period. HighCharts may not plot them all on the default view, as it starts to filter out records to speed up the display, but you should see them when you zoom in.

The wind direction is visibly less 'waggy' afterwards :)

Re: Highcharts Graphs

Posted: Sat 10 Sep 2016 4:18 pm
by Mapantz
That's the problem though, if I set nth to 1, or delete it, the data completely lags the highchart and it becomes unseable. I guess it'll have to be a random scatter each time then. :)

Re: Highcharts Graphs

Posted: Fri 30 Sep 2016 3:09 pm
by Mapantz
All the exporting options have disappeared from my graphs today, has anyone else's gone?

I was using:

Code: Select all

  <script src="http://code.highcharts.com/modules/exporting.js"></script>
The link still works, but it looks like it was updated. I don't know what has changed for it not to work though.

Re: Highcharts Graphs

Posted: Fri 30 Sep 2016 4:09 pm
by mcrossley
Highcharts have updated to version 5.0.0 - and it's broken stuff again! I'm going to link to 4.2.7 until I can sort this out.