Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Cumulus JpGraph Graphs?

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Cumulus JpGraph Graphs?

Post by n9mfk »

hi all, im get these error

Warning: array_reverse() [function.array-reverse]: The argument should be an array in /virtual/users/e15744-16642/web/graphs/temp.php on line 132

Warning: array_reverse() [function.array-reverse]: The argument should be an array in /virtual/users/e15744-16642/web/graphs/temp.php on line 133

Warning: array_reverse() [function.array-reverse]: The argument should be an array in /virtual/users/e15744-16642/web/graphs/temp.php on line 134
JpGraph Error Empty input data array specified for plot. Must have at least one data point.

http://www.n9mfk.com/graphs/temp.php
what have i missed?
Thanks Beau
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: Cumulus JpGraph Graphs?

Post by daj »

You will need to post your php code here -- giving a link to it will not show the code as it is interpreted by the webserver and we only see the results (i.e. the error) ;)
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: Cumulus JpGraph Graphs?

Post by n9mfk »

here is the code

Code: Select all

<?php
############################################################################
# A Project of TNET Services, Inc.
############################################################################
#
#   Project:    Cumulus Project 
#   Package:    Cumulus Weather JpGraph Graphs
#   Module:     intemp.php
#   Purpose:    Temp Graph Script
#   Version:    3.1 - October 26th, 2008
#   Authors:    Kevin W. Reed <programs@tnet.com>
#               TNET Services, Inc.
#   Copyright:  (c) 1992-2008 Copyright TNET Services, Inc.
#
#   License:    
#
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation; either version 2
#   of the License, or (at your option) any later version.
#   
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 
#   USA.
#
############################################################################
#   HISTORY
############################################################################
#
#   1.0     Released Oct 10th, 2008
#           Initial Release
#
#   1.2     Released Oct 12th, 2008
#           Added Debugging Ability
#           Added CLI Capabilities
#           Added Info Display to Graphs
#
#   1.2.1   Released Oct 14th, 2008
#           Modifications for JpGraph for old Pos() calls and
#           unsupported SetAntiAliasing()
#
#	2.0		Released Oct 18th, 2008
#			Modifications to match 1.8.2 Beta which extended
#			The number of fields in realtime.txt
#
#	3.0		Released Oct 19th, 2008
#			Modifications to match 1.8.2 Beta which extended
#			The number of fields in realtime.txt includes
#			rebuild of data field access routines.
#
############################################################################
#   This document uses Tab 4 Settings
############################################################################
$DATA   = array();
require_once("GraphSettings.php");
global  $SITE;
############################################################################
$SITE['hrs']            = 24;       # Adjustable via level
$SITE['tick']           = 2;        # Adjustable via level
$SITE['freq']           = 0;        # Adjustable via freq
############################################################################
# Check for passed variables
############################################################################
check_debug();      # Checks to see if Debug requested
check_level();      # Checks to see if level was passed to the script
check_freq();       # Checks to see if freq was passed to the script
check_info();       # Checks to see if info was passed
check_sourceview(); # Checks to see if Source View Was passed to the script
check_dataview();   # Checks to see if Data View Was passed to the script
set_tz( $SITE['tz'] );
############################################################################

// Load Contents of Realtime.log file

debug_out("obtaining data from: " . $SITE['hloc'] . $SITE['datafile']);

$rawdata = array_reverse( file($SITE['hloc'] . $SITE['datafile']));

debug_out("Obtained " . count($rawdata));
debug_out("Want to obtain " . $SITE['hrs']);

$wanted = $SITE['hrs'];
$got = 0;

$x = array();
$y1 = array();
$y2 = array();
$maxval = 0;

debug_out("Starting Array Sweep");

foreach($rawdata as $key) {
    if ($got < $wanted) {
    	
    	$DATA = preg_split('/ +/', $key);
        
        if (freq_check(substr( ret_value("time"),3,2))) {
            debug_out("Storing data");
            debug_out("Xaxis = " . timeto12(substr(ret_value("time"),0,2)));
            debug_out("Y1axis = " . ret_value("intemp") );
            debug_out("Y2axis = " . ret_value("inhum") );
            
            $rx[] = timeto12(substr(ret_value("time"),0,2));
            $ry1[] =  ret_value("intemp");
            $ry2[] = ret_value("inhum");
 
            $SITE['tempunit'] 	= "&#xb0;" . ret_value("tempunit");
            $SITE['pressunit'] 	= ret_value("pressunit");
            $SITE['rainunit'] 	= ret_value("rainunit");
            $SITE['windunit']	= ret_value("windunit");
	        $got++;
        }
    }
}

debug_out("Collected " . count($rx) . " records.");
debug_out("TempUnit = " . $SITE['tempunit'] );
debug_out("PressUnit = " . $SITE['pressunit'] );
debug_out("RainUnit = " . $SITE['rainunit'] );
debug_out("WindUnit = " . $SITE['windunit'] );
debug_out("Completed Array Sweep. Reversing Data"); 

$x = array_reverse($rx);
$y1 = array_reverse($ry1);
$y2 = array_reverse($ry2);

debug_out("Output of Xaxis Array");
debug_out_pre(1);
if ($SITE['debug']) {
    print_r($x);
}
debug_out_pre(0);

debug_out("Output of Y1axis Array");
debug_out_pre(1);
if ($SITE['debug']) {
    print_r($y1);
}
debug_out_pre(0);   

debug_out("Output of Y2axis Array");
debug_out_pre(1);
if ($SITE['debug']) {
    print_r($y2);
}
debug_out_pre(0); 

debug_out("Starting Graph Creation");

$graph = new Graph(400,250,"auto",30);    
$graph->SetScale("textlin");
$graph->SetY2Scale("lin",0,100);
$graph->SetMarginColor($SITE['bgncolor']);
$graph->SetFrame(true,'#CDCABB',4);
$graph->img->SetMargin(45,40,20,55);

// Create the two linear plot
$lineplot=new LinePlot($y1);
$lineplot2=new LinePlot($y2);

// Add the plot to the graph
$graph->Add($lineplot);
$graph->AddY2($lineplot2);
$lineplot2->SetWeight(2);

// titles
$graph->title->SetFont(FF_VERDANA,FS_BOLD,8);
$graph->title->Set($SITE['sitename']);
$graph->title->SetColor("azure4");
$graph->title->SetPos(0.003,0.54,"left","top");

//x-axis
$graph->xaxis->SetColor($SITE['txtcolor']);
$graph->xaxis->SetTickLabels($x);
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,6);
$graph->xaxis->SetTextLabelInterval($SITE['tick']);
$graph->xaxis->HideTicks(true,true); 
$graph->xaxis->SetPos("min"); 
$graph->xgrid->Show(true);

//y-axis
$graph->yaxis->SetColor($SITE['txtcolor']);
$graph->yaxis->SetLabelFormat('%0.0f ' . $SITE['tempunit']);
$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,6);
$graph->yaxis->scale->SetGrace(5);
$graph->yaxis->HideTicks(true,true); 

//y2-axis
$graph->y2axis->scale->ticks->Set(20);
$graph->y2axis->SetColor($SITE['txtcolor']);
$graph->y2axis->SetLabelFormat('%0.0f%%'); 
$graph->y2axis->SetFont(FF_VERDANA,FS_NORMAL,6);
$graph->y2axis->HideTicks(true,true); 
$graph->y2grid->Show(true);

// Set the colors for the plots
$lineplot->SetColor("red");
$lineplot->SetWeight(2);
$lineplot->SetFillColor("lightred@0.5");
$lineplot2->SetColor("lightblue");
$lineplot2->SetFillColor("lightblue@0.5");
$lineplot2->SetWeight(2);

// Print Wording on graphic

$txt2=new Text("cumulus");
$txt2->SetFont(FF_VERDANA, FS_BOLD,35);
$txt2->ParagraphAlign('left');
$txt2->SetPos(0.003,0.54,"left","center");
$txt2->SetColor("azure4@0.85");
$txt2->SetAngle(90);
$graph->AddText($txt2);

$txt1=new Text("indoor");
$txt1->SetFont( FF_VERDANA, FS_BOLD,29);
$txt1->ParagraphAlign('left');
$txt1->SetPos(0.11,0.92,"left","center");
$txt1->SetColor("azure4@0.6");
$graph->AddText($txt1);

$txt3=new Text(date("M j Y",time()));
$txt3->SetFont(FF_VERDANA, FS_BOLD,8);
$txt3->SetPos(0.8,0.015,"left","top");
$txt3->SetColor("azure4");
$graph->AddText($txt3);

// Place small monthly under right index
$txtaa=new Text($chrs . "Hum");
$txtaa->SetFont(FF_VERDANA, FS_BOLD,5);
$txtaa->SetPos(374,204,'center');
$txtaa->SetColor("azure4");
$graph->AddText($txtaa);

// Place small daily under right index
$txtab=new Text($chrs . "Temp");
$txtab->SetFont(FF_VERDANA, FS_BOLD,5);
$txtab->SetPos(22,204,'center');
$txtab->SetColor("azure4");
$graph->AddText($txtab);

// If Info is on, then display
// Chart Hours and Sample on graph

if ($SITE['info']) {
    $chrs = $SITE['hrs'];
    if ($SITE['freq'] == 0) {
        $fq = "Once an Hour";
    }
    if ($SITE['freq'] == 1) {
        $chrs = $chrs / 2;
        $fq = "Twice an Hour";
    }
    if ($SITE['freq'] == 2) {
        $chrs = $chrs /4;
        $fq = "4x an Hour";
    }
    
    $txt4=new Text($chrs . " hr Chart");
    $txt4->SetFont(FF_VERDANA, FS_BOLD,6);
    $txt4->SetPos(350,219,'center');
    $txt4->SetColor("azure4");
    $graph->AddText($txt4);
    
    
    $txt5=new Text($fq);
    $txt5->SetFont(FF_VERDANA, FS_BOLD,6);
    $txt5->SetPos(350,228,'center');
    $txt5->SetColor("azure4");
    $graph->AddText($txt5);
}


// Display the graph
if (! $SITE['debug']) {
    $graph->Stroke();
} else {
    debug_out("Graph Creation complete.  Graph output suppresed due to debug");
}

exit;

############################################################################
# SourceView Function
############################################################################

function check_sourceview () {
    global $SITE;
    
    if ($SITE['mode'] == "cli" ) {
        $val = get_cli_passed("view");
        list($what,$with) = split("=",$val);
        if ($what == "view" && $with == $SITE['viewpass']) {
            $filenameReal = __FILE__;
            readfile($filenameReal);
            exit;
        }
    }
        
    if ( isset($_GET['view']) && $_GET['view'] == 'sce1' ) {
        $filenameReal = __FILE__;
        $download_size = filesize($filenameReal);
        header('Pragma: public');
        header('Cache-Control: private');
        header('Cache-Control: no-cache, must-revalidate');
        header("Content-type: text/plain");
        header("Accept-Ranges: bytes");
        header("Content-Length: $download_size");
        header('Connection: close');
        readfile($filenameReal);
        exit;
    }
}

############################################################################
# END OF SCRIPT
############################################################################
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus JpGraph Graphs?

Post by steve »

I'm not really familiar with how this stuff works, but one thing I see is that your realtime.log file seems to have stopped being updated. The last entry is at 2009-07-17 17:50:12, and even allowing for time zones that must be over 12 hours ago. The script seems to be expecting 24 entries and there are only 16 in there; and then when it processes the entries doing whatever it does, there are none left, which is presumably where the error then comes in (run 'debug' on the script: http://www.n9mfk.com/graphs/temp.php?debug).

Has your cron job stopped? (Assuming that's how the realtime.log should get updated).
Steve
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: Cumulus JpGraph Graphs?

Post by n9mfk »

Hi all,
my host does not support cron job but i tried anther way that did not work
any ideas ?
User avatar
aadal
Posts: 168
Joined: Tue 04 Nov 2008 8:07 pm
Weather Station: WH 1080
Location: Skodje
Contact:

Re: Cumulus JpGraph Graphs?

Post by aadal »

  • Windows Vista
Image

Image
Post Reply