PHP Save Picture

Source: Internet
Author: User
I use Jpgraph to generate the canvas, enter the canvas, but the picture can not be saved successfully, run the program does not have error prompts.
Draw a line chart with PHP
Include ("e:/phpser/appserv/jpgraph/jpgraph/jpgraph.php");
Include ("e:/phpser/appserv/jpgraph/jpgraph/jpgraph_line.php");
$datay = $pm 25;
$graph = new Graph (700,300, "Auto"); Build Canvas
$graph->img->setmargin (50,40,30,40); Set the margins of the canvas
$graph->img->setantialiasing (); Set the smoothing state of the stitches
$graph->setscale ("Textlin"); Set scale style
$graph->setshadow ();//Create a canvas shadow
$graph->title->set ("Changes in PM2.5 value in the last 24 hours");//Set Caption
$graph->title->setfont (ff_simsun,fs_bold);//Set Title font
$graph->setmargincolor ("LightBlue");//Set the background color of the canvas to be light blue
$graph->yaxis->title->setfont (ff_simsun,fs_bold);//Set the font for the y-axis title
$graph->xaxis->setpos ("min");
$graph->yaxis->hidezerolabel ();
$graph->ygrid->setfill (True, ' #EFEFEF @0.5 ', ' #BBCCFF @0.5 ');
$graph->xaxis->setticklabels ($a);
$graph->xaxis->setfont (Ff_simsun); Set the font for the X axis
$graph->yscale->setgrace (20);
$p 1 = new LinePlot ($datay); Create a Line chart object
$p 1->mark->settype (mark_filledcircle); Set data coordinate points as graphical markers
$p 1->mark->setfillcolor ("Red"); Set the color of the fill
$p 1->mark->setwidth (4); Set the diameter of the cylindrical marker to 4 pixels
$p 1->mark->setcolor ("Blue"); Set the stitch color to Blue
$p 1->setcenter (); Draw stitches at the center of each coordinate point on the x-axis
[color= #FF0000] $graph->add ($p 1); Draw a polyline on a chart
$graph->stroke (); Output image
$graph->stroke (' c:/appserv/www/pm25/1.jpg ');


Reply to discussion (solution)

Great god, emergency.

Great god, emergency.

Great god, emergency.

You
$graph->stroke (); Output image
Do you have a picture displayed?

It shows, but it can't be saved.

$graph->stroke (); When the picture is displayed.
But $graph->stroke (' c:/appserv/www/pm25/1.jpg '); the picture doesn't show that there's a problem

Ask God for a rainy order.

Do not understand Ah, in learning, refueling it!!

What are the error hints?
is the path to the saved picture writable?

There are no error prompts,
Save picture my is to use $graph->stroke (' c:/appserv/www/pm25/1.jpg ');
If you do not save the picture with $graph->stroke (); There is no problem with the output canvas

No error, not equal to no error
You can only trace it and see what's wrong.

No, I use $graph->stroke ($filename = ' c:/appserv/www/pm25/1.jpg '); Output image, the result is not displayed only the label of the picture

The result is this:

$graph->stroke ();
$graph->stroke ($filename = ' c:/appserv/www/pm25/1.jpg '); Output image
You can either display the picture or save the picture to solve the problem.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.