wxnewpage.php

I try to create a new page and no success see:

http://www.jeanrobertmarion.com/wxepaisseurdeneige.php

Here the script:

Any idea why it does not work ?

Thank you for help.


wxepaisseurdeneige.php.txt (3.84 KB)

Hi Jean-Robert,

The reason it doesn’t work is the script inside is trying to create an image so the resulting PNG is embedded in the HTML instead of being recognized as a image and displayed by the browser.

Take this code

<?php
# PHPlot Example: Linepoints plot with Data Value Labels
require_once './phplot/phplot.php';

//Import and re-format data
$row = 0;
if (($handlex = fopen("customtextout.txt", "r")) !== FALSE) {
    while (($rdata = fgetcsv($handlex, 1440, ",")) !== FALSE) {
        $num = count($rdata);

{
$data[$row][0] = $rdata[3];        
$data[$row][1] = $rdata[6];        

        }
$row++;
    }
    fclose($handlex);
}

//Added this section to get the last 24 records from the array - Thanks Kevin!

if((count($data)>24)) {
   $data = array_slice($data,-24);
}

/*

);
print_r($data);
*/
$plot = new PHPlot(1600, 600);
$plot->SetImageBorderType('raised'); // Improves presentation in the manual
$plot->SetPlotType('stackedbars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
$plot->SetTitle("Epaisseur de la neige dernieres 24 heures a St-Etienne-des-Gres, Quebec Canada\n"
              . "(en cm)");

# Turn on Y data labels:
$plot->SetYDataLabelPos('plotin');

# Turn on X data label lines (drawn from X axis up to data point):
$plot->SetDrawXDataLabelLines(True);

# With Y data labels, we don't need Y ticks, Y tick labels, or grid lines.
$plot->SetYTickLabelPos('both');
$plot->SetYTickPos('both');
$plot->SetDrawYGrid(True);
# X tick marks are meaningless with this data:
$plot->SetXTickPos('plotdown');
$plot->SetXTickLabelPos('none');

$plot->DrawGraph();

?>

from the page and put it in a new file (all by itself, with no additional HTML before or after it. Call it plot-image1.php

Then in the wxepaisseurdeneig.php script, just put

<div id="main-copy">
<img src="plot-image1.php" />

</div><!-- end main-copy -->

Then the browser will invoke the plot-image1.php script via the call and the PNG should be displayed normally in the page.

Best regards,
Ken

Hi Ken

Thank you, it work very well.

Thank you for your precious help.

Jean-Robert