Pchart Chart Chinese Display related issues

Source: Internet
Author: User
Pchart Chart Chinese display problem
Project needs, chart display data, personal ability Limited,

/* Cat:bar Chart */
Header ("content-type:text/html; Charset=utf-8 ");
/* Pchart Library inclusions */
Include ("class/pdata.class.php");
Include ("class/pdraw.class.php");
Include ("class/pimage.class.php");

/* Create and populate the PData object */
$MyData = new PData ();
$MyData->addpoints (Array (150,220,300,250,420,200,300,200,100), "test");
$MyData->setaxisname (0, "Hits");
$MyData->addpoints (Array ("January", "February", "March", "April", "May", "June", "July", "August", "September"), "Months");
$MyData->setseriedescription ("Months", "Month");
$MyData->setabscissa ("Months");

/* Create the Pchart object */
$myPicture = new Pimage (700,230, $MyData);

/* Turn of antialiasing */
$myPicture->antialias = FALSE;

/* Add a border to the picture */
$myPicture->drawgradientarea (0,0,700,230,direction_vertical,array ("Startr" =>240, "STARTG" =>240, "StartB "=>240," Endr "=>180," ENDG "=>180," Endb "=>180," Alpha "=>100));
$myPicture->drawgradientarea (0,0,700,230,direction_horizontal,array ("Startr" =>240, "STARTG" =>240, " STARTB "=>240," Endr "=>180," ENDG "=>180," Endb "=>180," Alpha "=>20));
$myPicture->drawrectangle (0,0,699,229,array ("R" =>0, "G" =>0, "B" =>0));

/* Set The default font */
$myPicture->setfontproperties (Array ("fontname" = "Fonts/pf_arma_five.ttf", "FontSize" =>6));

/* Define the chart area */
$myPicture->setgrapharea (60,40,650,200);

/* Draw the scale */
$scaleSettings = Array ("GRIDR" =>200, "GRIDG" =>200, "Gridb" =>200, "Drawsubticks" =>true, "Cyclebackground" =>true);
$myPicture->drawscale ($scaleSettings);

/* Write the chart legend */
$myPicture->drawlegend (580,12,array ("Style" =>legend_noborder, "Mode" =>legend_horizontal));

/* Turn on Shadow Computing */
$myPicture->setshadow (True,array ("X" =>1, "Y" =>1, "R" =>0, "G" =>0, "B" =>0, "Alpha" =>10));

/* Draw the chart */
$myPicture->setshadow (True,array ("X" =>1, "Y" =>1, "R" =>0, "G" =>0, "B" =>0, "Alpha" =>10));
$settings = Array ("Surrounding" =>-30, "innersurrounding" =>30);
$myPicture->drawbarchart ($settings);
Ob_clean (); Key code to prevent the ' image cannot be displayed because of its own error '.
Header ("Content-type:image/png");
/* Render the picture (choose the best) */
$myPicture->autooutput ("Examples/pictures/example.drawbarchart.simple.png");

How to put $MyData->addpoints (Array (150,220,300,250,420,200,300,200,100), "test"), the string test is displayed in Chinese, how to $MyData Setaxisname (0, "Hits"), display Chinese, such as $MyData->setaxisname (0, "set");
------Solution--------------------
Is it not possible to write directly in Chinese?
------Solution--------------------
Comment out the header ("content-type:text/html; Charset=utf-8 ");
------Solution--------------------
Is it the latest version?
See you later, next.
------Solution--------------------
1, the header is not, because you are the image of the way out
2, you choose the font is a Western text body, no Chinese characters can not be displayed, you need to choose a Chinese font
3, if your program is not utf-8, then all the characters to be exported must be converted into Utf-8
  • 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.