apc.html 130 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Appendix C. FAQ</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt09.html" title="Part IX. Appendices"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix C. FAQ</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Part IX. Appendices</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="appendix" title="Appendix C. FAQ"><div class="titlepage"><div><div><h2 class="title"><a name="app.faq"></a>Appendix C. FAQ</h2></div></div></div>
    <div class="qandaset" title="Frequently Asked Questions"><a name="id2623081"></a><dl><dt>C.1. <a href="apc.html#id2623083">Where should I install the library?</a></dt><dt>C.2. <a href="apc.html#id2623132">Can I use JpGraph with Windows/Unix/Linux etc? </a></dt><dt>C.3. <a href="apc.html#id2623153"> My Web-admin does not allow PHP any write permissions and hence I can't use
                    the cache feature of JpGraph. Is there any way to completely turn off the
                    caching feature?</a></dt><dt>C.4. <a href="apc.html#id2623188"> After installation all I get is an empty page when I try any of the
                    examples?</a></dt><dt>C.5. <a href="apc.html#id2623207"> How can I send the generated graph to both the browser and a file at the same
                    time?</a></dt><dt>C.6. <a href="apc.html#id2623322"> What is this 'auto' I see in all the Graph() creating in the Examples
                    directory? Do I need it?</a></dt><dt>C.7. <a href="apc.html#id2623344"> The Client side image map examples does not work on my machine?</a></dt><dt>C.8. <a href="apc.html#id2623366"> When I run 'testsuit_jpgraph.php' I get a warning "Due to insufficient
                    permission the source files can't be automatically created"</a></dt><dt>C.9. <a href="apc.html#id2623393"> How can I pass data to my image generating script?</a></dt><dt>C.10. <a href="apc.html#id2623433"> How can I use data from an Excel spreadsheet?</a></dt><dt>C.11. <a href="apc.html#id2623494"> How do I pass data from a Database (e.g. MySQL) to a script to produce a
                    graph?</a></dt><dt>C.12. <a href="apc.html#id2623533"> I change my data but my image does not get updated? The old image is still
                    send back to the browser?</a></dt><dt>C.13. <a href="apc.html#id2623628"> Can I run JpGraph in batch-mode just outputting an image directly to a file
                    and not streamed back to the browser? </a></dt><dt>C.14. <a href="apc.html#id2623649"> Is there a mailing list for JpGraph? </a></dt><dt>C.15. <a href="apc.html#id2623669"> Do you offer a commercial version of JpGraph with full support and no
                    QPL?</a></dt><dt>C.16. <a href="apc.html#id2623712"> Some of my script just return a blank image and no error messages? </a></dt><dt>C.17. <a href="apc.html#id2623726"> I can see the generated image fine in the browser but I can't print it?
                </a></dt><dt>C.18. <a href="apc.html#id2623764"> How can I generate an image directly to disk without streaming it back to the
                    browser?</a></dt><dt>C.19. <a href="apc.html#id2623786"> When I try to plot graphs with many 1000:s of data points I only get a blank
                    page. Is there a limit in JpGraph to the number of data points you can plot?
                </a></dt><dt>C.20. <a href="apc.html#id2623785"> How can I use an image in a dynamically created PDF?</a></dt><dt>C.21. <a href="apc.html#id2623880"> How can I force the user to get a question to download the generated image
                    instead of just displaying it in the browser? </a></dt><dt>C.22. <a href="apc.html#id2623909"> How can I open up a CSIM link in a graph in a separate window?</a></dt><dt>C.23. <a href="apc.html#id2623967"> No TTF fonts are displayed.</a></dt><dt>C.24. <a href="apc.html#id2624032"> All my TTF fonts are yellow no matter what color I specify?</a></dt><dt>C.25. <a href="apc.html#id2624050"> I get an error "This PHP build has not been configured with TTF support. You
                    need to recompile your PHP installation with FreeType support."</a></dt><dt>C.26. <a href="apc.html#id2624075"> I get an error "Fatal error: Font cant be
                        found"</a></dt><dt>C.27. <a href="apc.html#id2624110"> I get the error "Can't find font file
                        FONT_PATHarial.ttf" (or some other font)</a></dt><dt>C.28. <a href="apc.html#id2624140"> I get an error "Font file ... is not readable or does not
                        exist"</a></dt><dt>C.29. <a href="apc.html#id2624180"> How can I install additional TTF font families? </a></dt><dt>C.30. <a href="apc.html#id2624094"> How can I display special characters that isn't available on the
                    keyboard?</a></dt><dt>C.31. <a href="apc.html#id2624261"> When I put a text object on a graph and use Set90AndMargin() it doesn't
                    show?</a></dt><dt>C.32. <a href="apc.html#id2624327"> I get an error "Error: Cannot add header information
                        - headers already sent ..."
                </a></dt><dt>C.33. <a href="apc.html#id2624383"> I get an error "Unknown function
                            imagecreate"</a></dt><dt>C.34. <a href="apc.html#id2624416"> I get an error "Unknown function
                            imagecreatejpeg"</a></dt><dt>C.35. <a href="apc.html#id2624444"> I get an error "Warning: MkDir failed (Permission
                        denied) in jpgraph.php on line XXXX"</a></dt><dt>C.36. <a href="apc.html#id2624472"> I get an error "Fatal error: Undefined class name
                        "parent" in jpgraph.php on line xxxx"</a></dt><dt>C.37. <a href="apc.html#id2624508"> I get an error "Your data contains non-numeric
                        values."</a></dt><dt>C.38. <a href="apc.html#id2624542"> I get an error "Date is outside specified scale
                        range" trying to create a Gantt chart</a></dt><dt>C.39. <a href="apc.html#id2624570"> I get an error "Invalid file handle in jpgraph.php at
                        line XXXX"</a></dt><dt>C.40. <a href="apc.html#id2624518"> I get an error "Fatal error: Call to undefined
                        function: getcsimareas() ..."
                </a></dt><dt>C.41. <a href="apc.html#id2624550"> I get an error "Fatal error: Call to undefined
                        function: imagetypes()"</a></dt><dt>C.42. <a href="apc.html#id2624654"> I get an error saying something like "Error:
                        'parent::' not valid in context..."</a></dt><dt>C.43. <a href="apc.html#id2624682"> I get an error "Image cannot be displayed because it
                        contains errors.."</a></dt><dt>C.44. <a href="apc.html#id2624727"> When I use PHP5 + JpGraph 2.x I get "A plot has an
                        illegal scale..."</a></dt><dt>C.45. <a href="apc.html#id2624776"> I try to mix bar and line graphs and the bars doesn't get centered and the
                    labels are not correctly aligned?</a></dt><dt>C.46. <a href="apc.html#id2624663"> How do I turn off anti-aliasing for TTF fonts?</a></dt><dt>C.47. <a href="apc.html#id2624842"> The auto-scaling algorithm chooses very tight limits around my Y-values. How
                    do I get more "space" between the end of the scale and the min/max values?
                </a></dt><dt>C.48. <a href="apc.html#id2624861"> I want to use autoscaling to handle the maximum value but I always want the
                    Y-axis to start at 0 regardless of the actual minimum value?</a></dt><dt>C.49. <a href="apc.html#id2624902"> I want the position of the X-axis to be at the bottom of the Y-scale and not
                    always at the position Y=0?</a></dt><dt>C.50. <a href="apc.html#id2624946"> I specify color X in the image but the color displayed is not exactly what I
                    specified?</a></dt><dt>C.51. <a href="apc.html#id2624988"> Can I have labels at an arbitrary angle on the X-axis? </a></dt><dt>C.52. <a href="apc.html#id2625029"> How do I invert the Y-scale so that it has the minimum value on top and the
                    largest value at the bottom?</a></dt><dt>C.53. <a href="apc.html#id2625086"> Can I have the auto-scaling algorithm restrict itself to whole
                    numbers?</a></dt><dt>C.54. <a href="apc.html#id2625104"> Is it possible to have horizontal bar graphs?</a></dt><dt>C.55. <a href="apc.html#id2625124"> Line weight does not seem to work in my graphs? I specify a thick line but
                    still get a thin line?</a></dt><dt>C.56. <a href="apc.html#id2625155"> How can I have more space between the Y-axis and the title? </a></dt><dt>C.57. <a href="apc.html#id2625168"> How can I display both X and Y values above each data point in a line, bar or
                    scatter plot?</a></dt><dt>C.58. <a href="apc.html#id2625213"> Can I display stock box-charts (open, close, high, low) with JpGraph? </a></dt><dt>C.59. <a href="apc.html#id2625231"> Is there any way to specify a newline in the legend box for a specific
                    legend?</a></dt><dt>C.60. <a href="apc.html#id2625258"> How can I print unicode characters?</a></dt><dt>C.61. <a href="apc.html#id2625220"> My background images doesn't display properly. It just shows a black solid
                    square? </a></dt><dt>C.62. <a href="apc.html#id2625314"> How do I make each bar in a bar plot have it's own color?</a></dt><dt>C.63. <a href="apc.html#id2625331"> How can I adjust the position of the axis title?</a></dt><dt>C.64. <a href="apc.html#id2625364"> How can I change the image format, i.e jpeg, gif or png? </a></dt><dt>C.65. <a href="apc.html#id2625346"> How do I specify the font for legends?</a></dt><dt>C.66. <a href="apc.html#id2625424"> When I rotate text and labels the text is not rotated correctly?</a></dt><dt>C.67. <a href="apc.html#id2625406"> When I rotate a paragraph (multi-line) text the paragraph is always left
                    aligned even though I have specified another alignment. It seems fine for
                    non-rotated paragraphs though. What is the problem? </a></dt><dt>C.68. <a href="apc.html#id2625472"> I have a huge number of data points and I only want labels (which I want to
                    specify as text string) and ticks on every n:th data. Can I do this?</a></dt><dt>C.69. <a href="apc.html#id2625497"> How can I make the labels have a 1000 comma separator?</a></dt><dt>C.70. <a href="apc.html#id2625536"> The Y2 axis is no longer positioned at the right side of the graph</a></dt><dt>C.71. <a href="apc.html#id2625573"> How can I include several graphs in the same image?</a></dt><dt>C.72. <a href="apc.html#id2625627"> How can I have an exploded slice with 3D pie plots?</a></dt><dt>C.73. <a href="apc.html#id2625654"> How can I display values for each slice close to the pie?</a></dt><dt>C.74. <a href="apc.html#id2625667"> How can I change between percentage and absolute values for pie slices?
                </a></dt><dt>C.75. <a href="apc.html#id2625719"> Can I display the actual value as labels on the pie bar instead of the
                    percentage?</a></dt><dt>C.76. <a href="apc.html#id2625742"> How can I adust the start angle of the first slice?</a></dt><dt>C.77. <a href="apc.html#id2625757"> When I use IE v5 or v6 I can only save the generated graph image in the
                    browser as a BMP file even if it was generated as a JPEG or PNG encoded
                    image?</a></dt></dl><table border="0" width="100%" summary="Q and A Set"><col align="left" width="1%"><col><tbody>
            <tr class="question" title="C.1."><td align="left" valign="top"><a name="id2623083"></a><a name="id2623097"></a><p><b>C.1.</b></p></td><td align="left" valign="top"><p>Where should I install the library?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> The simple answer is: Anywhere You like! Since the necessary library files
                    are included in Your own script with an "include" (or more likely a
                    require_once) statement it doesn't matter where You put the library as long as
                    Your scripts can access it. A common place is to store the library is in a
                    directory where PHP searches for include files (as specified in Your
                        <code class="filename">php.ini</code> file), for example in
                        "<code class="filename">/usr/share/php</code>" or perhaps
                        "<code class="filename">/usr/local/php</code>" depending on Your PHP configuration. </p><p> An even simpler way is to just store the library in a directory where Your
                    scripts are executed from. However , this is not really recommended. </p></td></tr>
        
            <tr class="question" title="C.2."><td align="left" valign="top"><a name="id2623132"></a><a name="id2623134"></a><p><b>C.2.</b></p></td><td align="left" valign="top"><p>Can I use JpGraph with Windows/Unix/Linux etc? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes. The library itself is OS-agnostic. As long as you have a WEB server
                    which supports PHP 4.3.x (or above) and have the GD library. Please note though
                    that the behavior of PHP/Apache on Unix and Windows seems to have some subtle
                    differences which might affect things like path specification using '/' or '\'. </p><p>
                    </p><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3>
                        <p>The library does not support any 64bit OS and there are known issues
                            with running the library on a 64bit OS (either Unix or Windows). There
                            are currently no plans to address this in the near future.</p>
                    </div><p>
                </p></td></tr>
        
            <tr class="question" title="C.3."><td align="left" valign="top"><a name="id2623153"></a><a name="id2623168"></a><p><b>C.3.</b></p></td><td align="left" valign="top"><p> My Web-admin does not allow PHP any write permissions and hence I can't use
                    the cache feature of JpGraph. Is there any way to completely turn off the
                    caching feature?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes, set the constant "<code class="code">USE_CACHE</code>" to <code class="code">FALSE</code> in
                    jpg-config.php. This way will skip writing file even if a filename has been
                    submitted in the Graph() creation call. You can also accomplish this by not
                    having any file name at all in the call to Graph().</p></td></tr>
        
            <tr class="question" title="C.4."><td align="left" valign="top"><a name="id2623188"></a><a name="id2623198"></a><p><b>C.4.</b></p></td><td align="left" valign="top"><p> After installation all I get is an empty page when I try any of the
                    examples?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> If the HTTP server response is truly absolutely empty (verify that by looking
                    at the source of the page that gets returned to the browser) then the only
                    answer is that the HTTP server has crashed. Most likely it is the PHP process
                    within the server that has crashed. Even though PHP is fairly stable there are
                    still ways of crashing it. To investigate this further You might try to: </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
                            <p>... investigate the system log for traces of a server
                                crash.</p>
                        </li><li class="listitem">
                            <p>... try increase the maximum allowed memory for PHP in php.ini. As
                                a rule it should be a minimum of 32MB (and preferable 64MB)</p>
                        </li><li class="listitem">
                            <p>... upgrade PHP to the latest stable version (and use the compile
                                options shown further down in this FAQ.</p>
                        </li><li class="listitem">
                            <p>... upgrade PHP to the latest stable version (and use the compile
                                options shown further down in this FAQ.</p>
                        </li><li class="listitem">
                            <p>... enable all errors and warning for PHP (in php.ini) to help
                                track down the problem.</p>
                        </li><li class="listitem">
                            <p>... disable output buffering to get errors send back to the
                                browser as soon as possible (in <code class="filename">php.ini</code>)</p>
                        </li></ul></div></td></tr>
        
            <tr class="question" title="C.5."><td align="left" valign="top"><a name="id2623207"></a><a name="id2623284"></a><p><b>C.5.</b></p></td><td align="left" valign="top"><p> How can I send the generated graph to both the browser and a file at the same
                    time?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This is not directly supported by means of any particular option or setting
                    in the library but with small "trick" this is easy enough to accomplish. </p><p> The idea is to use the _IMG_HANDLER option that forces the
                        <code class="code">Graph::Stroke()</code> to just return the image handler and then stop.
                    We can then manually first send the image to the chosen file and then stream it
                    back to the browser using some internal methods in the library. </p><p> The following code snippet shows how this is done </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Graph</span><span class="hl-brackets">(</span><span class="hl-number">400</span><span class="hl-code">,</span><span class="hl-number">300</span><span class="hl-brackets">)</span><span class="hl-code">;  
&lt;... </span><span class="hl-identifier">code</span><span class="hl-code"> </span><span class="hl-identifier">to</span><span class="hl-code"> </span><span class="hl-identifier">generate</span><span class="hl-code"> </span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">graph</span><span class="hl-code"> ...&gt;  
</span><span class="hl-comment">//</span><span class="hl-comment"> Get the  handler to prevent the library from sending the </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> image to the browser</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$gdImgHandler</span><span class="hl-code"> = </span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-identifier">_IMG_HANDLER</span><span class="hl-brackets">)</span><span class="hl-code">;
  
</span><span class="hl-comment">//</span><span class="hl-comment"> Stroke image to a file and  browser  </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Default is PNG so use &quot;.png&quot; as suffix </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$fileName</span><span class="hl-code"> = </span><span class="hl-quotes">&quot;</span><span class="hl-string">/tmp/imagefile.png</span><span class="hl-quotes">&quot;</span><span class="hl-code">; </span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">img</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stream</span><span class="hl-brackets">(</span><span class="hl-var">$fileName</span><span class="hl-brackets">)</span><span class="hl-code">;  
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Send it back to browser </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">img</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Headers</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">img</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stream</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.6."><td align="left" valign="top"><a name="id2623322"></a><a name="id2623324"></a><p><b>C.6.</b></p></td><td align="left" valign="top"><p> What is this 'auto' I see in all the Graph() creating in the Examples
                    directory? Do I need it?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> No. The third argument in the graph call is an optional cache file name and
                    is not necessary unless You want to use the caching feature of JpGraph. By
                    specifying 'auto' the filename is automatically created based on the name of the
                    script file.</p></td></tr>
        
            <tr class="question" title="C.7."><td align="left" valign="top"><a name="id2623344"></a><a name="id2623346"></a><p><b>C.7.</b></p></td><td align="left" valign="top"><p> The Client side image map examples does not work on my machine?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> In order to run the examples the code generates HTML to read the image from
                    the cache directory as Apache sees it. You must adjust the image tag to have the
                    correct path to your cache directory. </p></td></tr>
        
            <tr class="question" title="C.8."><td align="left" valign="top"><a name="id2623366"></a><a name="id2623368"></a><p><b>C.8.</b></p></td><td align="left" valign="top"><p> When I run 'testsuit_jpgraph.php' I get a warning "Due to insufficient
                    permission the source files can't be automatically created"</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This is not a serious problem. When the testsuit is run it tries to create a
                    symbolic link with the same base name as the individual testfile but with
                    extension ".phps". This is just so it is possible to click on an image and then
                    view the source syntax colored. If Apache doesn't have write permissions to the
                    directory where 'testsuit_jpgraph.php' is executed from you will get this
                    warning.</p><p> If you want to use this feature just change the permissions so Apache may
                    write to the directory.</p></td></tr>
        
            <tr class="question" title="C.9."><td align="left" valign="top"><a name="id2623393"></a><a name="id2623395"></a><p><b>C.9.</b></p></td><td align="left" valign="top"><p> How can I pass data to my image generating script?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> There are basically three(four) ways:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
                        <p>Read the data from a file</p>
                    </li><li class="listitem">
                        <p>Read the data from a DB</p>
                    </li><li class="listitem">
                        <p>Pass the data in the &lt;<span class="markup">img</span>&gt; tag using URL
                            parameter passing. For example <code class="code"> &lt;img
                                src="myimg.php?d1=2&amp;d2=7&amp;d3=12" border=0&gt;
                            </code> This method is not suitable for large data sets since there is
                            an upper bound to the length of an URL specification (around 255
                            characters)</p>
                    </li><li class="listitem">
                        <p>A fourth way might be to use session variables to pass the data
                            between different scripts. For large data sets the only practical way is
                            to read the data from a file or from a DB to construct the data
                            vectors.</p>
                    </li></ul></div></td></tr>
        
            <tr class="question" title="C.10."><td align="left" valign="top"><a name="id2623433"></a><a name="id2623464"></a><p><b>C.10.</b></p></td><td align="left" valign="top"><p> How can I use data from an Excel spreadsheet?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Export the data from Excel as a CSV (Comma separated Values) file to be able
                    to easily read the file. Then either write your own routine to read and parse
                    the data from that file or use the utility class "ReadCSV" in
                    "jpgraph_utils.php". </p><p> A basic example on how to do this for a line graph assuming the name of the
                    data file is "data.csv".</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code"> </span><span class="hl-reserved">include</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">../jpgraph.php</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-reserved">include</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">../jpgraph_line.php</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-reserved">include</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">../jpgraph_utils.inc</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;  
</span><span class="hl-var">$n</span><span class="hl-code"> = </span><span class="hl-identifier">ReadFileData</span><span class="hl-code">::</span><span class="hl-identifier">FromCSV</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">data.csv</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-var">$datay</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-reserved">if</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$n</span><span class="hl-code"> == </span><span class="hl-reserved">false</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">     
    </span><span class="hl-reserved">die</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">Can't read data.csv.</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-brackets">}</span><span class="hl-code">  
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Setup the graph $graph = new Graph(400,300);</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">title</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Reading CSV file with </span><span class="hl-quotes">'</span><span class="hl-code">.</span><span class="hl-var">$n</span><span class="hl-code">.</span><span class="hl-quotes">'</span><span class="hl-string"> data points</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetScale</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">intlin</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;  
 
</span><span class="hl-var">$l1</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LinePlot</span><span class="hl-brackets">(</span><span class="hl-var">$datay</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$l1</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.11."><td align="left" valign="top"><a name="id2623494"></a><a name="id2623496"></a><p><b>C.11.</b></p></td><td align="left" valign="top"><p> How do I pass data from a Database (e.g. MySQL) to a script to produce a
                    graph?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> By adding some SQL statements in Your graph scripts that creates the data
                    arrays from the DB. </p><p> Watch out for empty values and strings. JpGraph doesn't know how to plot
                    strings. Any value passed into JpGraph should be only valid numeric data. See
                    the online discussions on populating from a DB Populating DB or the discussion
                    on how to read data from file Reading from file. </p><p> See <code class="uri"><a class="uri" href="http://jpgraph.intellit.nl/viewtopic.php?t=8" target="_top">How to
                        populate arrays from mySQL</a></code>
                </p></td></tr>
        
            <tr class="question" title="C.12."><td align="left" valign="top"><a name="id2623533"></a><a name="id2623524"></a><p><b>C.12.</b></p></td><td align="left" valign="top"><p> I change my data but my image does not get updated? The old image is still
                    send back to the browser?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> What you are seeing is a cached version of Your image. Depending on your
                    setup it could either be that the browser has a cached image or You are using
                    the built-in cache system in the library by accident. </p><p>
                    <span class="bold"><strong>Fixing the browser cache</strong></span> Since the script from
                    the browser point of view is the same it just displays the old image. To fix
                    this you need to turn of the browser image caching. </p><p> Another "trick" that can be used since normally it is impossible to control
                    the browser for the end user is ot add a "dummy" URL argument which changes.
                    This way the browser will always see a new URL and then always reload that file.
                    This could be done for example as:</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">echo ('&lt;img src=&quot;graphscript.php?' .microtime().'&quot;&gt;');</span></pre></td></tr></table></div><p>
                    <span class="bold"><strong>Fixing the library cache</strong></span></p><p> The other reason might be that You have enabled the built-in cache feature in
                    JpGraph. To turn it of You can either </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
                            <p> Not specify a cache name in the call to Graph(). Just call new
                                Graph(200,200) for example.</p>
                        </li><li class="listitem">
                            <p> Turn off the reading from the cache by setting READ_CACHE to
                                false (in jpg-config.inc)</p>
                        </li><li class="listitem">
                            <p> Turn off the reading and writing from the cache by setting
                                USE_CACHE to false (in jpg-config.php)</p>
                        </li><li class="listitem">
                            <p> Use the cache but with a timeout so that the image will be
                                re-generated if the cached image is older then the specified timeout
                                value in the call to Graph().</p>
                        </li></ul></div></td></tr>
        
            <tr class="question" title="C.13."><td align="left" valign="top"><a name="id2623628"></a><a name="id2623630"></a><p><b>C.13.</b></p></td><td align="left" valign="top"><p> Can I run JpGraph in batch-mode just outputting an image directly to a file
                    and not streamed back to the browser? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes. Just specify an absolute file name in the call to Graph::Stroke(). To
                    store the image in the local temp directory use: </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$myGraph-&gt;Stroke(&quot;/tmp/myimage.png&quot;);</span></pre></td></tr></table></div><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3>
                        <p>Note: You must match the file ending Yourself to the format you have
                            chosen to generate the image in.</p>
                    </div></td></tr>
        
            <tr class="question" title="C.14."><td align="left" valign="top"><a name="id2623649"></a><a name="id2623660"></a><p><b>C.14.</b></p></td><td align="left" valign="top"><p> Is there a mailing list for JpGraph? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> No, but there is a user <code class="uri"><a class="uri" href="http://jpgraph.intellit.nl/index.php" target="_top">community forum</a></code> at
                        <code class="uri"><a class="uri" href="http://jpgraph.intellit.nl/index.php" target="_top">http://jpgraph.intellit.nl/index.php</a></code> where users discuss various
                    aspects of the library.</p></td></tr>
        
            <tr class="question" title="C.15."><td align="left" valign="top"><a name="id2623669"></a><a name="id2623694"></a><p><b>C.15.</b></p></td><td align="left" valign="top"><p> Do you offer a commercial version of JpGraph with full support and no
                    QPL?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes, For commercial (non-open-source) you will need to get the "JpGraph
                    Professional License". This allows you you deploy JpGraph in a commercial
                    context. Further details upon contact.</p></td></tr>
        
            <tr class="question" title="C.16."><td align="left" valign="top"><a name="id2623712"></a><a name="id2623714"></a><p><b>C.16.</b></p></td><td align="left" valign="top"><p> Some of my script just return a blank image and no error messages? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This could potentially be a lot of things depending on which browser you are
                    using. One thing you might want to check is that your script doesn't take to
                    long time. In that case they might hit the time limit for running a PHP script
                    as specified in php.ini. You can adjust that time limit with a call to
                    set_time_limit().</p><p> If You are seeing just an empty page (really empty) then this is a sign that
                    Your server has crashed. Most likely an old version of PHP is being used which
                    has taken down the HTTP server process. </p></td></tr>
        
            <tr class="question" title="C.17."><td align="left" valign="top"><a name="id2623726"></a><a name="id2623742"></a><p><b>C.17.</b></p></td><td align="left" valign="top"><p> I can see the generated image fine in the browser but I can't print it?
                </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This is again browser dependent. Some browser does not like to print an image
                    which is generated on-line and does exist as a *.jpg, *.png etc file. No good
                    workaround has been identified short of changing browser. Some browsers (and
                    versions) can print others not. The only real safe way (if you need printing) is
                    to generate the image on disk and then have the browser read the image from
                    there. </p></td></tr>
        
            <tr class="question" title="C.18."><td align="left" valign="top"><a name="id2623764"></a><a name="id2623766"></a><p><b>C.18.</b></p></td><td align="left" valign="top"><p> How can I generate an image directly to disk without streaming it back to the
                    browser?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Two ways: (Preferred way) If you supply a filename in the call to
                    $graph-&gt;Stroke() the image will be written to that file and not be streamed back
                    to the browser. If you prefer to have the image going to the cache directory but
                    not streamed back then you could just set the '$aInlineFlag' in the initial call
                    to Graph() (fifth argument) to false as in
                    </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$mygraph = new Graph(200,200,&quot;auto&quot;,0,false);</span></pre></td></tr></table></div><p>
                    The "auto" argument makes an automatic file name in the cache based on the
                    script name. The 0 indicates that we have no timeout. The advantage with this
                    method is that you can specify a timeout to avoid having the image generated to
                    often. </p></td></tr>
        
            <tr class="question" title="C.19."><td align="left" valign="top"><a name="id2623786"></a><a name="id2623797"></a><p><b>C.19.</b></p></td><td align="left" valign="top"><p> When I try to plot graphs with many 1000:s of data points I only get a blank
                    page. Is there a limit in JpGraph to the number of data points you can plot?
                </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> No, there is no such limit. The problem is most likely that your script takes
                    so long time that the PHP execution limit (as specified in php.ini) aborts the
                    script. If you have more than 10,000 data points JpGraph will work but doing
                    this kind of heavy data analysis on a WEB-server extension is probably not a
                    good idea to start with.</p><p> The other reason could be that the script exhausts the allowed memory limit
                    for PHP as specified in the "php.ini" file. By default this is often set to 8Mb
                    which is to low for a complex JpGraph script. Try increasing the memory limit to
                    a minimum of 16Mb. For very complex graphs with 1000s of data points there might
                    be a need to increase the memory even further. </p></td></tr>
        
            <tr class="question" title="C.20."><td align="left" valign="top"><a name="id2623785"></a><a name="id2623827"></a><p><b>C.20.</b></p></td><td align="left" valign="top"><p> How can I use an image in a dynamically created PDF?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You can do this in two ways, you can either stroke the image created with the
                    library directly to a file where it can be used with Your PDF library of choice.
                    For example, using FPDF (<code class="uri"><a class="uri" href="http://www.fpdf.org/" target="_top">www.fpdf.org</a></code>) the Image() function would have to be used to read an
                    image from the filesystem. </p><p> If You are using the PDF library (APIs included in the PHP distribution but
                    the library itself might require a license depending on Your usage.) you can
                    avoid the storage of the file by getting the image handler for the image
                    directly and use it with PDF. </p><p> With the PDF library you must first open the in memory image with a call to
                        <code class="code">pdf_open_memory_image($pdf, $im)</code>. The following script places
                    an image from JpGraph directly into a PDF page that is returned when running
                    this script. </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">  
 
</span><span class="hl-var">$graph</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Graph</span><span class="hl-brackets">(</span><span class="hl-code">...</span><span class="hl-brackets">)</span><span class="hl-code">;  
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Code to create the graph </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> .........................</span><span class="hl-comment"></span><span class="hl-code">
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Put the image in a PDF page </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$im</span><span class="hl-code"> = </span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-identifier">_IMG_HANDLER</span><span class="hl-brackets">)</span><span class="hl-code">;  
</span><span class="hl-var">$pdf</span><span class="hl-code"> = </span><span class="hl-identifier">pdf_new</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-identifier">pdf_open_file</span><span class="hl-brackets">(</span><span class="hl-var">$pdf</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;  
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Convert the GD image to somehing the </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> PDFlibrary knows how to handle </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$pimg</span><span class="hl-code"> = </span><span class="hl-identifier">pdf_open_memory_image</span><span class="hl-brackets">(</span><span class="hl-var">$pdf</span><span class="hl-code">, </span><span class="hl-var">$im</span><span class="hl-brackets">)</span><span class="hl-code">;
 
</span><span class="hl-identifier">pdf_begin_page</span><span class="hl-brackets">(</span><span class="hl-var">$pdf</span><span class="hl-code">, </span><span class="hl-number">595</span><span class="hl-code">, </span><span class="hl-number">842</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-identifier">pdf_add_outline</span><span class="hl-brackets">(</span><span class="hl-var">$pdf</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">Page 1</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-identifier">pdf_place_image</span><span class="hl-brackets">(</span><span class="hl-var">$pdf</span><span class="hl-code">, </span><span class="hl-var">$pimg</span><span class="hl-code">, </span><span class="hl-number">0</span><span class="hl-code">, </span><span class="hl-number">500</span><span class="hl-code">, </span><span class="hl-number">1</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-identifier">pdf_close_image</span><span class="hl-brackets">(</span><span class="hl-var">$pdf</span><span class="hl-code">, </span><span class="hl-var">$pimg</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-identifier">pdf_end_page</span><span class="hl-brackets">(</span><span class="hl-var">$pdf</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-identifier">pdf_close</span><span class="hl-brackets">(</span><span class="hl-var">$pdf</span><span class="hl-brackets">)</span><span class="hl-code">;  
 
</span><span class="hl-var">$buf</span><span class="hl-code"> = </span><span class="hl-identifier">pdf_get_buffer</span><span class="hl-brackets">(</span><span class="hl-var">$pdf</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-var">$len</span><span class="hl-code"> =</span><span class="hl-identifier">strlen</span><span class="hl-brackets">(</span><span class="hl-var">$buf</span><span class="hl-brackets">)</span><span class="hl-code">;  
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Send PDF mime headers </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-identifier">header</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Content-type: application/pdf</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-identifier">header</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">Content-Length: </span><span class="hl-var">$len</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-identifier">header</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">Content-Disposition: inline; filename=foo.pdf</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;  
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Send the content of the PDF file </span><span class="hl-comment"></span><span class="hl-code">
 
</span><span class="hl-reserved">echo</span><span class="hl-code"> </span><span class="hl-var">$buf</span><span class="hl-code">;  
 
</span><span class="hl-comment">//</span><span class="hl-comment"> .. and clean up </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-identifier">pdf_delete</span><span class="hl-brackets">(</span><span class="hl-var">$pdf</span><span class="hl-brackets">)</span><span class="hl-code">;  
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.21."><td align="left" valign="top"><a name="id2623880"></a><a name="id2623882"></a><p><b>C.21.</b></p></td><td align="left" valign="top"><p> How can I force the user to get a question to download the generated image
                    instead of just displaying it in the browser? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Change your code for creating the image: </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$im</span><span class="hl-code">=</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-identifier">_IMG_HANDLER</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-var">$filename</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">chart</span><span class="hl-quotes">&quot;</span><span class="hl-code">; 
</span><span class="hl-var">$file_type</span><span class="hl-code"> = </span><span class="hl-quotes">&quot;</span><span class="hl-string">image/png</span><span class="hl-quotes">&quot;</span><span class="hl-code">;
</span><span class="hl-var">$file_ending</span><span class="hl-code"> = </span><span class="hl-quotes">&quot;</span><span class="hl-string">png</span><span class="hl-quotes">&quot;</span><span class="hl-code">; 
</span><span class="hl-var">$filename</span><span class="hl-code">=</span><span class="hl-var">$filename</span><span class="hl-code">.</span><span class="hl-quotes">&quot;</span><span class="hl-string">.</span><span class="hl-quotes">&quot;</span><span class="hl-code">.</span><span class="hl-var">$file_ending</span><span class="hl-code">;
 
</span><span class="hl-identifier">header</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">Content-Type: application/</span><span class="hl-var">$file_type</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-identifier">header</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">Content-Disposition:attachment; filename=</span><span class="hl-quotes">&quot;</span><span class="hl-code">.</span><span class="hl-var">$filename</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-identifier">header</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">Pragma: no-cache</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-identifier">header</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">Expires:0</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-identifier">ImagePNG</span><span class="hl-brackets">(</span><span class="hl-var">$im</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p> A html link, which directs to the php page (assuming the filename is
                    chart.php): Download Then, if you click on the link, a download dialog appears
                    and you can download the "chart.png". </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
                        <p>If you directly open chart.php, the image is directly streamed to the
                            browser and the download dialog will not open. </p>
                    </div></td></tr>
        
            <tr class="question" title="C.22."><td align="left" valign="top"><a name="id2623909"></a><a name="id2623921"></a><p><b>C.22.</b></p></td><td align="left" valign="top"><p> How can I open up a CSIM link in a graph in a separate window?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> To open a target CSIM (drill down) in a separate window some javascript in
                    the target link is necessary since this action must be performed in the browser.
                    The target URL needs top be in the form of an action to open up a window (with
                    any optional URL argument that might be needed). For example, assume we have a
                    bar graph and that theb user can click on each bar to get more details. When the
                    user clicks on a bar we open up the detaails witha call to the helper script
                    "bar_details.php" and send the parameter "id" to the script to separate the
                    individual bars. We would then use the following URL link (with javascript) </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">&quot;javascript:window.open('bar_details.php?id=%d','_new','width=500,height=300');void(0)&quot;</span></pre></td></tr></table></div><p> Where the '%d' placeholder must be replaced by the appropriate Id for each
                    bar. To assign the appropriate id we could use the following construct </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Create targets for the image maps so that the details are opened </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> in a separate window </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$fmtStr</span><span class="hl-code"> = </span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:window.open('bar_details.php?id=%d','_new','width=500,height=300');
void(0)</span><span class="hl-quotes">&quot;</span><span class="hl-code">;  
</span><span class="hl-var">$n</span><span class="hl-code"> = </span><span class="hl-identifier">count</span><span class="hl-brackets">(</span><span class="hl-var">$datay</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-var">$targ</span><span class="hl-code">=</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$alts</span><span class="hl-code">=</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-reserved">for</span><span class="hl-brackets">(</span><span class="hl-var">$i</span><span class="hl-code">=</span><span class="hl-number">0</span><span class="hl-code">; </span><span class="hl-var">$i</span><span class="hl-code"> &lt; </span><span class="hl-var">$n</span><span class="hl-code">; ++</span><span class="hl-var">$i</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">     
    </span><span class="hl-var">$targ</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code"> = </span><span class="hl-identifier">sprintf</span><span class="hl-brackets">(</span><span class="hl-var">$fmtStr</span><span class="hl-code">,</span><span class="hl-var">$i</span><span class="hl-code">+</span><span class="hl-number">1</span><span class="hl-brackets">)</span><span class="hl-code">;     
    </span><span class="hl-var">$alts</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">val=%d</span><span class="hl-quotes">'</span><span class="hl-code">; 
</span><span class="hl-brackets">}</span><span class="hl-code">
                    
</span><span class="hl-var">$bplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetCSIMTargets</span><span class="hl-brackets">(</span><span class="hl-var">$targ</span><span class="hl-code">,</span><span class="hl-var">$alts</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$bplot</span><span class="hl-brackets">)</span><span class="hl-code">; 
... 
</span><span class="hl-comment">//</span><span class="hl-comment"> Send back the HTML page to browser </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">StrokeCSIM</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;  
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p> It should be noted that in the above Javascript code we have used the special
                    window name '_new' which means that a new window will be opened each time a user
                    clicks on a bar. By giving the window a specific name the same window would be
                    re-used every time. </p></td></tr>
        
            <tr class="question" title="C.23."><td align="left" valign="top"><a name="id2623967"></a><a name="id2623969"></a><p><b>C.23.</b></p></td><td align="left" valign="top"><p> No TTF fonts are displayed.</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> There are potentially many reasons for this Please start by trying the
                    following bare bones PHP script to see if basic TTF support is available in the
                    PHP setup. </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code"> 
</span><span class="hl-comment">//</span><span class="hl-comment"> Change this defines to where Your fonts are stored </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">DEFINE</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">TTF_DIR</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-quotes">&quot;</span><span class="hl-string">/usr/X11R6/lib/X11/fonts/truetype/</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Change this define to a font file that You know that You have</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">DEFINE</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">TTF_FONTFILE</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-quotes">&quot;</span><span class="hl-string">arial.ttf</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Text to display </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">DEFINE</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">TTF_TEXT</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-quotes">&quot;</span><span class="hl-string">Hello World!</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;  
 
</span><span class="hl-var">$im</span><span class="hl-code"> = </span><span class="hl-identifier">imagecreatetruecolor</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-number">400</span><span class="hl-code">, </span><span class="hl-number">100</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-var">$white</span><span class="hl-code"> = </span><span class="hl-identifier">imagecolorallocate</span><span class="hl-brackets">(</span><span class="hl-var">$im</span><span class="hl-code">, </span><span class="hl-number">255</span><span class="hl-code">, </span><span class="hl-number">255</span><span class="hl-code">, </span><span class="hl-number">255</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-var">$black</span><span class="hl-code"> = </span><span class="hl-identifier">imagecolorallocate</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-var">$im</span><span class="hl-code">, </span><span class="hl-number">0</span><span class="hl-code">, </span><span class="hl-number">0</span><span class="hl-code">, </span><span class="hl-number">0</span><span class="hl-brackets">)</span><span class="hl-code">;
 
</span><span class="hl-identifier">imagefilledrectangle</span><span class="hl-brackets">(</span><span class="hl-var">$im</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-code">,</span><span class="hl-number">399</span><span class="hl-code">,</span><span class="hl-number">99</span><span class="hl-code">,</span><span class="hl-var">$white</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-identifier">imagettftext</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-var">$im</span><span class="hl-code">, </span><span class="hl-number">30</span><span class="hl-code">, </span><span class="hl-number">0</span><span class="hl-code">, </span><span class="hl-number">10</span><span class="hl-code">, </span><span class="hl-number">40</span><span class="hl-code">,</span><span class="hl-var">$black</span><span class="hl-code">, </span><span class="hl-identifier">TTF_DIR</span><span class="hl-code">.</span><span class="hl-identifier">TTF_FONTFILE</span><span class="hl-code">,</span><span class="hl-identifier">TTF_TEXT</span><span class="hl-brackets">)</span><span class="hl-code">;  
</span><span class="hl-identifier">header</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">Content-type: image/png</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-identifier">imagepng</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-var">$im</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p> The above script when run should produce an image with a black text string on
                    a white background. If this doesn't work then there is a setup problem with PHP
                    + TTF. </p><p> As a first step to resolve this recompile Your PHP4 setup using the following
                    basic configuration (depending on the local conditions some options/path might
                    have to be changed). The critical options are marked in bold. </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">./configure
--prefix=/usr/share \ 
--datadir=/usr/share/php \ 
--with-apxs=/usr/sbin/apxs \
--libdir=/usr/share --includedir=/usr/include \ 
--bindir=/usr/bin \
--with-config-file-path=/etc \ 
--enable-mbstring --enable-mbregex \ 
--with-mysql \ 
&lt;span class=&quot;bold&quot;&gt;&lt;strong&gt;--with-gd \ 
--enable-gd-imgstrttf \ 
--enable-gd-native-ttf \
--with-ttf-dir=/usr/lib \ 
--with-freetype-dir=/usr/lib \
--with-zlib-dir=/usr/lib \ 
--with-png-dir=/usr/lib \
--with-jpeg-dir=/usr/lib \
&lt;/strong&gt;&lt;/span&gt;--with-xpm-dir=/usr/X11R6 \
--with-tiff-dir=/usr/lib \ 
--enable-memory-limit --enable-safe-mode \
--bindir=/usr/bin \ 
--enable-bcmath -enable-calendar \ 
--enable-ctype --with-ftp \ 
--enable-magic-quotes \ 
--enable-inline-optimization \ 
--with-iconv</span></pre></td></tr></table></div><p> If there is still no TTF fonts displayed then the next step is to upgrade
                    Your TTF libraries to the latest version. The FreeType version 2.1.9 is known to
                    work well. </p></td></tr>
        
            <tr class="question" title="C.24."><td align="left" valign="top"><a name="id2624032"></a><a name="id2624034"></a><p><b>C.24.</b></p></td><td align="left" valign="top"><p> All my TTF fonts are yellow no matter what color I specify?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You have a old buggy version of the FreeType library, most likely the old
                    FreeType I library is being used. Please upgrade to the latest version of
                    FreeType II.</p></td></tr>
        
            <tr class="question" title="C.25."><td align="left" valign="top"><a name="id2624050"></a><a name="id2624052"></a><p><b>C.25.</b></p></td><td align="left" valign="top"><p> I get an error "This PHP build has not been configured with TTF support. You
                    need to recompile your PHP installation with FreeType support."</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This error is reported if the built-in PHP/GD function <code class="uri"><a class="uri" href="http://www.php.net/manual/en/function.imagettfbbox.php" target="_top">"imagettfbbox()"</a></code> is not available. This is a crucial method to make
                    TTF fonts work with JpGraph. The most likely reason for this problem is that the
                    PHP configuration is faulty and does not have correct support for TTF fonts.
                    Please recompile PHP as shown above and make sure that the built-in version of
                    GD is being used and not the stand-alone library. </p></td></tr>
        
            <tr class="question" title="C.26."><td align="left" valign="top"><a name="id2624075"></a><a name="id2624085"></a><p><b>C.26.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Fatal error: Font cant be
                        found"</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You have either not specified a correct path where your fonts are stored (see
                    top of jpg-config.inc) or you have tried to use a font you do not have
                    installed.</p></td></tr>
        
            <tr class="question" title="C.27."><td align="left" valign="top"><a name="id2624110"></a><a name="id2624112"></a><p><b>C.27.</b></p></td><td align="left" valign="top"><p> I get the error <span class="errmsg">"Can't find font file
                        FONT_PATHarial.ttf"</span> (or some other font)</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You are most likely running on Windows. This seems to be caused by a bug in
                    PHP/Apache (or PHP/IIS) specifically on Windows. The problem seems to be that
                    PHP doesn't remember a DEFINE() setting across two or more include directive. A
                    simple workaround is to hard-code the font path in class TTF in file
                    jpgraph.php. Note: If you have this problem you will most likely also have a
                    problem with the path to the cache directory.</p></td></tr>
        
            <tr class="question" title="C.28."><td align="left" valign="top"><a name="id2624140"></a><a name="id2624016"></a><p><b>C.28.</b></p></td><td align="left" valign="top"><p> I get an error <span class="emphasis"><em>"Font file ... is not readable or does not
                        exist"</em></span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This error is caused by the inability of PHP/JpGraph to read the font file.
                    This could have several reasons: </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
                        <p>The file path or name is wrong and the file really doesn't exist.
                            Please check that the file and path (as shown in the error message)
                            really exists.</p>
                    </li><li class="listitem">
                        <p>If the file exists it might still not be possible for PHP to read the
                            file due to permission problem. Please make sure that PHP can read a
                            file in the TTF directory. This can be verified with the following short
                            script </p>
                        <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code"> 
</span><span class="hl-comment">//</span><span class="hl-comment"> Change this defines to where Your fonts are stored </span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">DEFINE</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">TTF_DIR</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-quotes">&quot;</span><span class="hl-string">/usr/X11R6/lib/X11/fonts/truetype/</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Change this define to a font file that You know that You have</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">DEFINE</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">TTF_FONTFILE</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-quotes">&quot;</span><span class="hl-string">arial.ttf</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;  
 
</span><span class="hl-var">$f</span><span class="hl-code"> = </span><span class="hl-identifier">TTF_DIR</span><span class="hl-code">.</span><span class="hl-identifier">TTF_FONTFILE</span><span class="hl-code">; 
</span><span class="hl-reserved">if</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">file_exists</span><span class="hl-brackets">(</span><span class="hl-var">$f</span><span class="hl-brackets">)</span><span class="hl-code"> === </span><span class="hl-reserved">false</span><span class="hl-code"> || </span><span class="hl-identifier">is_readable</span><span class="hl-brackets">(</span><span class="hl-var">$f</span><span class="hl-brackets">)</span><span class="hl-code"> === </span><span class="hl-reserved">false</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">     
    </span><span class="hl-reserved">echo</span><span class="hl-code"> </span><span class="hl-quotes">&quot;</span><span class="hl-string">FAIL: Can not read font file </span><span class="hl-special">\&quot;</span><span class="hl-var">$f</span><span class="hl-special">\&quot;</span><span class="hl-string">.</span><span class="hl-quotes">&quot;</span><span class="hl-code">; 
</span><span class="hl-brackets">}</span><span class="hl-code"> </span><span class="hl-reserved">else</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">     
    </span><span class="hl-reserved">echo</span><span class="hl-code"> </span><span class="hl-quotes">&quot;</span><span class="hl-string">PASS: Successfully read font file </span><span class="hl-special">\&quot;</span><span class="hl-var">$f</span><span class="hl-special">\&quot;</span><span class="hl-string">.</span><span class="hl-quotes">&quot;</span><span class="hl-code">; 
</span><span class="hl-brackets">}</span><span class="hl-code"> 
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div>
                        <p> If the script reports <span class="emphasis"><em>FAIL</em></span> then it must be
                            investigated whether the file names or permissions are wrong. </p>
                    </li></ul></div></td></tr>
        
            <tr class="question" title="C.29."><td align="left" valign="top"><a name="id2624180"></a><a name="id2624074"></a><p><b>C.29.</b></p></td><td align="left" valign="top"><p> How can I install additional TTF font families? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> See the <code class="uri"><a class="uri" href="phptip04.php" target="_top">Adding additional TTF font
                        families</a></code> section on this site for a full explanation of the necessary
                    steps.</p></td></tr>
        
            <tr class="question" title="C.30."><td align="left" valign="top"><a name="id2624094"></a><a name="id2624231"></a><p><b>C.30.</b></p></td><td align="left" valign="top"><p> How can I display special characters that isn't available on the
                    keyboard?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> By using the standard "&amp;#dddd" encoding of the symbol in a text string.
                    For example, to get the character for the "copyright" symbol &amp;copy; which
                    has the numeric code "00A9" (in Hex) </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$copy = sprintf('&amp;#%04d;',hexdec('00A9'));</span></pre></td></tr></table></div><p>In a similar way this can be used to show Greek letters, for example
                    "&amp;#0946;" (beta) is displayed by</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$beta = sprintf('&amp;#%04d;',hexdec('03B2'));</span></pre></td></tr></table></div><div class="tip" title="Tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3>
                    <p>Use the class "<code class="code">SymChar</code>" defined in jpgraph_utils.php to get
                        easy access to greek and special mathematical symbols. This class allow the
                        specification of common symbols by name. Some examples:</p>
                    <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">// &amp;#0948; (delta)
$gamma = SymChar::Get('delta'); 
 
// &amp;#0956; (mu) 
$mu = SymChar::Get('mu'); 
 
// &amp;#0960; (pi) 
$pi = SymChar::Get('pi'); 
 
// &amp;#0955; (lambda) 
$lambda = SymChar::Get('lambda'); 
 
// &amp;#8747; (integral sign) 
$integral = SymChar::Get('int'); 
 
// &amp;#8776; (approximation sign) 
$approx = SymChar::Get('approx');</span></pre></td></tr></table></div>
                </div></td></tr>
        
            <tr class="question" title="C.31."><td align="left" valign="top"><a name="id2624261"></a><a name="id2624281"></a><p><b>C.31.</b></p></td><td align="left" valign="top"><p> When I put a text object on a graph and use Set90AndMargin() it doesn't
                    show?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> The main cause for this behaviour is that the text object position is rotated
                    90 degrees. For example, putting a text object at Pos(0,0) it will become
                    "invisible". The reason for this behaviour is that the texts position (not the
                    text itself) is rotated around the center of the image 90 degrees clockwise. </p><p> For example, assuming the image is WxH in size. Rotating position (0,0) which
                    is the top left corner of the image gives the rotated position: </p><p>
                    <code class="code">(0,0) =&gt; rotate 90 degrees =&gt; (W,0)</code>
                </p><p> Now, if a string was put at position (W,0) it will be drawn outside the image
                    and hence become invisible. </p><p> If You need to position text with rotated images just keep this in mind and
                    swap the meaning of the X and Y position since the X-position will become the Y
                    position and vice versa after a 90 degree rotation. Some experiments will soon
                    allow You to get the hang of it. </p><div class="tip" title="Tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3>
                    <p>Start with an image that is equal in W and H since this makes it easier to
                        understand the rotation.</p>
                </div></td></tr>
        
            <tr class="question" title="C.32."><td align="left" valign="top"><a name="id2624327"></a><a name="id2624336"></a><p><b>C.32.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Error: Cannot add header information
                        - headers already sent ..."</span>
                </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> First, this is not a problem with JpGraph per se. What has happened is that
                    your PHP file which produces the image has already returned some data to the
                    browser before the image has been sent. This is most often caused by one or more
                    spaces before the first "&lt;?php" The browser will now implicitly set the
                    header to plain text. </p><p> When later JpGraph tries to send the correct image header the browser gets
                    confused since it has already received a header for the current document. (Each
                    document can only have one and only one type). Check your files for any output
                    (even a single space) before the call to Graph::Graph() (or Graph::Stroke()) </p><p> If you are running on Windows this problem could be caused by a blank line at
                    the end of any of the jpgraph_*.php files. All files in jpgraph ends in a
                    newline which some configurations on Windows doesn't like. Remove the newline so
                    that the file ends just after the final "?&gt;" </p><p> Also remember that when you include external file using include/include_once
                    and so on Php include the whole content of the file; this content of the file
                    also include any potential carriage return/line feed or "blank" space before
                    "&lt;?php" and after "?&gt;" These "dirty characters" will stop the JpGraph
                    being properly sent back because they are included in the image streaming.
                </p></td></tr>
        
            <tr class="question" title="C.33."><td align="left" valign="top"><a name="id2624383"></a><a name="id2624385"></a><p><b>C.33.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Unknown function
                            <code class="code">imagecreate</code>"</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You have not compiled PHP with support for the GD graphic library. See PHP
                    documentation for details. Note that you also need to configure PHP to use GD
                    and/or TTF fonts to get JpGraph full functionality</p></td></tr>
        
            <tr class="question" title="C.34."><td align="left" valign="top"><a name="id2624416"></a><a name="id2624418"></a><p><b>C.34.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Unknown function
                            <code class="code">imagecreatejpeg</code>"</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You have not compiled PHP with support for the JPG format. See PHP
                    documentation for details</p></td></tr>
        
            <tr class="question" title="C.35."><td align="left" valign="top"><a name="id2624444"></a><a name="id2624446"></a><p><b>C.35.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Warning: MkDir failed (Permission
                        denied) in jpgraph.php on line XXXX"</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This is a permission problem. To use the cache Apache/PHP must have write
                    permission to the cache directory. Make sure that Apache/PHP have sufficient
                    permissions to write to the specified cache directory.</p></td></tr>
        
            <tr class="question" title="C.36."><td align="left" valign="top"><a name="id2624472"></a><a name="id2624474"></a><p><b>C.36.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Fatal error: Undefined class name
                        "parent" in jpgraph.php on line xxxx"</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You are using an older version of PHP. JpGraph 1.x requires at least PHP
                    4.3</p><p>
                    </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
                        <p>Remember that JpGraph 1.x has reached its end of life and is no longer
                            maintained.</p>
                    </div><p>
                </p></td></tr>
        
            <tr class="question" title="C.37."><td align="left" valign="top"><a name="id2624508"></a><a name="id2624510"></a><p><b>C.37.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Your data contains non-numeric
                        values."</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Most likely Your data really contains non-numeric data which You need to
                    further investigate (for example by printing out the array with a
                        <code class="code">var_dump()</code>. One additional thing to watch out for is if the
                    data looks like ".56" (or "-.56") which is a shortform of "0.56". The problem is
                    that the number starts with an "." (dot) which is non-numeric. The solution is
                    to replace the single dot with a "0."</p></td></tr>
        
            <tr class="question" title="C.38."><td align="left" valign="top"><a name="id2624542"></a><a name="id2624544"></a><p><b>C.38.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Date is outside specified scale
                        range"</span> trying to create a Gantt chart</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> As the error says, you start or end date for a activity is larger/smaller
                    than the max/min value in the scale. If you get this error and you are using
                    automatic scale then you are probably using a null value (empty string "") as
                    start or end date. Check your data</p></td></tr>
        
            <tr class="question" title="C.39."><td align="left" valign="top"><a name="id2624570"></a><a name="id2624572"></a><p><b>C.39.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Invalid file handle in jpgraph.php at
                        line XXXX"</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This is a permission problem. Check that your cache directory has the right
                    permissions to let JpGraph access and write to it. </p></td></tr>
        
            <tr class="question" title="C.40."><td align="left" valign="top"><a name="id2624518"></a><a name="id2624596"></a><p><b>C.40.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Fatal error: Call to undefined
                        function: getcsimareas() ..."</span>
                </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You have enabled the <code class="code">DEFINE("JPG_DEBUG",true)</code> in jpgraph.php.
                    This is an internal debug flag which should always be left untouched. </p></td></tr>
        
            <tr class="question" title="C.41."><td align="left" valign="top"><a name="id2624550"></a><a name="id2624625"></a><p><b>C.41.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Fatal error: Call to undefined
                        function: imagetypes()"</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You have not installed the core GD library correct. <code class="code">imagetypes()</code>
                    is a standard GD function. Please refer to the installation section in the
                    manual for more information on how to verify You setup.</p></td></tr>
        
            <tr class="question" title="C.42."><td align="left" valign="top"><a name="id2624654"></a><a name="id2624656"></a><p><b>C.42.</b></p></td><td align="left" valign="top"><p> I get an error saying something like <span class="errmsg">"Error:
                        'parent::' not valid in context..."</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You are most likely using the Zend cache. There is a bug with some versions
                    of the Zend cache together with the "parent" meta class. If the referenced
                    parent class is in another file that is included this problem seems to occur.
                    The workaround seems to be to put all classes in the same physical file or
                    upgrade the Zend cache to a more recent version.</p></td></tr>
        
            <tr class="question" title="C.43."><td align="left" valign="top"><a name="id2624682"></a><a name="id2624684"></a><p><b>C.43.</b></p></td><td align="left" valign="top"><p> I get an error <span class="errmsg">"Image cannot be displayed because it
                        contains errors.."</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> First of all this is an error message from the browser and not the library.
                    There could be various reasons for this but the most likely scenario is that
                    Your installation of PHP has both enabled output buffering and enabled strict
                    error checking. </p><p> What could now happen is that with output buffering enabled PHP will buffer
                    up any text error messages. This could for example be som "Notice:" warnings if
                    You have forgotten to initialize some variables. When then the library adds the
                    proper image header and the buffered error messages together with the image gets
                    sent back the browser it all falls apart. </p><p> The browser tries to interpret both the error messages and the image data as
                    an image and it of course fails and gives this error message. Why? Because the
                    textual error messages that was buffered is interpreted as if they would belong
                    to the image which of course is nonsense. </p><p> The solution is to disable output-buffering until You are convinced that Your
                    code is without any problem. On a development server it is recommended to always
                    have output buffering disabled. </p></td></tr>
        
            <tr class="question" title="C.44."><td align="left" valign="top"><a name="id2624727"></a><a name="id2624729"></a><p><b>C.44.</b></p></td><td align="left" valign="top"><p> When I use PHP5 + JpGraph 2.x I get <span class="errmsg">"A plot has an
                        illegal scale..."</span></p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> There have been a few reports of this problem and it seems to be due to a
                    faulty PHP 5.x installation. For example a standard SuSE 9.3 PHP5 installation
                    gives this problem. The exact reason for the problem has not been established
                    but it all points to a PHP5 problem since it can be solved by adjusting the PHP
                    installation without any change in the library. </p><p><span class="bold"><strong> Step 1: </strong></span></p><p> First check that Your php.ini file have compatibility mode turned off (in
                        <code class="filename">php.ini</code>)</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">zend.ze1_compatibility_mode=off</span></pre></td></tr></table></div><p>
                    <span class="bold"><strong>Step 2: </strong></span></p><p> If turning the compatibility mode off still doesn't solve the problem the
                    only remaining solution is to re-compile PHP 5. For example on our development
                    servers we use the following configuration Note: We place "php.ini" in
                    "/etc/php5/apache2" and You might want to change this to suit Your specific
                    setup. </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">./configure
--prefix=/usr/share --datadir=/usr/share/php \
--with-apxs2=/usr/sbin/apxs2-prefork \ 
--libdir=/usr/share
--includedir=/usr/include \ 
--bindir=/usr/bin \
--with-config-file-path=/etc/php5/apache2 \ 
--enable-mbstring --enable-mbregex \
--with-mysql  \ 
--with-gd --enable-gd-imgstrttf --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib \ 
--with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-xpm-dir=/usr/X11R6 \ 
--with-tiff-dir=/usr/lib --with-ttf-dir=/usr/lib \
--with-freetype-dir=/usr/lib \ 
--enable-ftp \ 
--enable-memory-limit
--enable-safe-mode \ 
--bindir=/usr/bin \ 
--enable-bcmath -enable-calendar \
--enable-ctype --with-ftp \ 
--enable-magic-quotes \ 
--enable-inline-optimization \ 
--with-bz2 \ 
--with-iconv</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.45."><td align="left" valign="top"><a name="id2624776"></a><a name="id2624802"></a><p><b>C.45.</b></p></td><td align="left" valign="top"><p> I try to mix bar and line graphs and the bars doesn't get centered and the
                    labels are not correctly aligned?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This is a known problem. The best way to partly solve this is to make sure
                    you add the bar plot as the last plot to the graph. The reason behind this
                    problem is that plot that gets added to the graph internally makes modification
                    to the alignment of the plot. Since each plot does not know what other plot has
                    been added it will happily overwrite previous plots settings in the graph. Hence
                    the workaround by adding the bar last. conflicting settings.)</p></td></tr>
        
            <tr class="question" title="C.46."><td align="left" valign="top"><a name="id2624663"></a><a name="id2624823"></a><p><b>C.46.</b></p></td><td align="left" valign="top"><p> How do I turn off anti-aliasing for TTF fonts?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> There is not any built in support in JpGraph to do this. Since the whole
                    purpose of TTF fonts is to provide a smooth font experience there is really no
                    point in wanting to do this. If you want non-aliased fonts you should use the
                    built-in bitmap fonts.</p></td></tr>
        
            <tr class="question" title="C.47."><td align="left" valign="top"><a name="id2624842"></a><a name="id2624844"></a><p><b>C.47.</b></p></td><td align="left" valign="top"><p> The auto-scaling algorithm chooses very tight limits around my Y-values. How
                    do I get more "space" between the end of the scale and the min/max values?
                </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Use the <code class="code">SetGrace()</code> to specify some extra space (as percentage of
                    the scale) between the min/max value and the limits of the scale. For example
                        <code class="code">$graph-&gt;yscale-&gt;SetGrace(10)</code> gives 10% extra space at the
                    ends.</p></td></tr>
        
            <tr class="question" title="C.48."><td align="left" valign="top"><a name="id2624861"></a><a name="id2624874"></a><p><b>C.48.</b></p></td><td align="left" valign="top"><p> I want to use autoscaling to handle the maximum value but I always want the
                    Y-axis to start at 0 regardless of the actual minimum value?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Use the <code class="code">SetAutoMin()</code> method. For example as in </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">...
$graph = new Graph(400,350); 
$graph-&gt;SetScale(&quot;intlin&quot;);
$graph-&gt;yaxis-&gt;scale-&gt;SetAutoMin(0); 
...</span></pre></td></tr></table></div><div class="tip" title="Tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3>
                    <p>If you need to limit the maximum value but auto-scale the minimum value
                        use the <code class="code">SetAutoMax() </code>method.</p>
                </div></td></tr>
        
            <tr class="question" title="C.49."><td align="left" valign="top"><a name="id2624902"></a><a name="id2624916"></a><p><b>C.49.</b></p></td><td align="left" valign="top"><p> I want the position of the X-axis to be at the bottom of the Y-scale and not
                    always at the position Y=0?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> To adjust the position of the Axis Use the <code class="code">Axis::SetPos()</code>
                    method. The argument to this method can be either the numerical scale value on
                    the Y-axis where the X-axis should be positioned or it can be one of the two
                    special value "min" or "max". In the latter case the axis will be positioned on
                    either the minimum or the maximum value of the scale. For example
                    </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">...
$graph-&gt;xaxis-&gt;SetPos(&quot;min&quot;); 
...</span></pre></td></tr></table></div><p>
                    Will put the X-axis at the lowest value of the Y-axis. </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
                        <p>The same positioning is possible for the Y-axis.</p>
                    </div></td></tr>
        
            <tr class="question" title="C.50."><td align="left" valign="top"><a name="id2624946"></a><a name="id2624954"></a><p><b>C.50.</b></p></td><td align="left" valign="top"><p> I specify color X in the image but the color displayed is not exactly what I
                    specified?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This is a result of a finite color palette for GIF, PNG formats. If you are
                    using anti-aliasing, perhaps a background image or even gradient fill you might
                    exhaust the color palette supported in the GD library. Try set the constant
                        <code class="code">USE_APPROX_COLORS</code> to false and generate the picture again. If
                    you now get an error message saying that no more colors can be allocated this is
                    the problem. There is no good workaround if you are using GD 1.x since for PNG
                    the GD 1.x library does not support "True-color". </p><p> The only real solution is to upgrade to GD 2.x to get full true-color
                    support. If you are using a background image try to "degrade" it to have a
                    smaller color palette or turn of anti-aliasing and you might have enough free
                    palette entries to cater for all the colors you want and still use GD 1.x </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
                    <p>This problem is only seen in very, very old installations that use GD 1.x
                        library which has been deprecated since around 2005</p>
                </div></td></tr>
        
            <tr class="question" title="C.51."><td align="left" valign="top"><a name="id2624988"></a><a name="id2624997"></a><p><b>C.51.</b></p></td><td align="left" valign="top"><p> Can I have labels at an arbitrary angle on the X-axis? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes, almost any text can be stroked at an arbitrary angle. For example to
                    have the labels at 45 degrees angle use </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">...
$graph-&gt;xaxis-&gt;SetTickLabels($labels);
$graph-&gt;xaxis-&gt;SetLabelAngle(45); 
...</span></pre></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
                    <p>Internal fonts support 0 and 90 degrees text. If you need to use, say 45
                        degree (or any other arbitrary angle), you must use TTF fonts. </p>
                </div></td></tr>
        
            <tr class="question" title="C.52."><td align="left" valign="top"><a name="id2625029"></a><a name="id2625031"></a><p><b>C.52.</b></p></td><td align="left" valign="top"><p> How do I invert the Y-scale so that it has the minimum value on top and the
                    largest value at the bottom?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> The easiest way to do this is by following a two step process</p><p>a) Negating all Your values and then </p><p>b) Create a callback function for the Y-axis that negates all the display
                    values. </p><p> What will happen now is that after the negative values have been feed into
                    the graph it will create a scale starting at the lowest value, say -8, then go
                    up to the highest, say -1. If these values are then inverted when printed it
                    will in affect achieve the inverted axis appearance. The code snippet below
                    shows a basic example of this technique. </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">... // Callback to negate the argument
function _cb_negate($aVal) {     
    return round(-$aVal); 
}  // A fake depth curve
$ydata = ....  
// Negate all data 
$n = count($ydata); 
for($i=0; $i&lt;$n; ++$i) {     
    $ydata[$i] = -$ydata[$i]; 
}  
 
// Basic graph setup 
$graph = new Graph(400,300); 
$graph-&gt;SetScale(&quot;linlin&quot;);  
 
// Setup axis
$graph-&gt;yaxis-&gt;SetLabelFormatCallback(&quot;_cb_negate&quot;); 
$plot = new LinePlot($ydata,$xdata); 
$graph-&gt;Add($plot); 
$graph-&gt;Stroke();</span></pre></td></tr></table></div><p> Two scripts that uses this technique can be found in the
                        <code class="filename">Examples/</code> directory in the distribution,
                        <code class="filename">"inyaxisex1.php"</code> and
                        <code class="filename">"inyaxisex2.php"</code>. </p></td></tr>
        
            <tr class="question" title="C.53."><td align="left" valign="top"><a name="id2625086"></a><a name="id2625089"></a><p><b>C.53.</b></p></td><td align="left" valign="top"><p> Can I have the auto-scaling algorithm restrict itself to whole
                    numbers?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes, use the "int" scale specification, for example
                        <code class="code">$graph-&gt;SetScale('inttext')</code> will make the Y-axis have an
                    integer scale and the X-axis a text-scale</p></td></tr>
        
            <tr class="question" title="C.54."><td align="left" valign="top"><a name="id2625104"></a><a name="id2625113"></a><p><b>C.54.</b></p></td><td align="left" valign="top"><p> Is it possible to have horizontal bar graphs?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes, Just create a normal bar and call the method
                        <code class="code">Set90AndMargin()</code> to rotate the graph.</p></td></tr>
        
            <tr class="question" title="C.55."><td align="left" valign="top"><a name="id2625124"></a><a name="id2625137"></a><p><b>C.55.</b></p></td><td align="left" valign="top"><p> Line weight does not seem to work in my graphs? I specify a thick line but
                    still get a thin line?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You have probably enabled Anti-aliasing. If anti-aliasing is enabled setting
                    line-weight will have no affect.</p></td></tr>
        
            <tr class="question" title="C.56."><td align="left" valign="top"><a name="id2625155"></a><a name="id2625157"></a><p><b>C.56.</b></p></td><td align="left" valign="top"><p> How can I have more space between the Y-axis and the title? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Use the <code class="code">Axis::SetTitleMargin()</code> method. For example to have a 25
                    pixels margin for the Y-title you could use:
                    </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$mygraph-&gt;yaxis-&gt;SetTitleMargin(25);</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.57."><td align="left" valign="top"><a name="id2625168"></a><a name="id2625184"></a><p><b>C.57.</b></p></td><td align="left" valign="top"><p> How can I display both X and Y values above each data point in a line, bar or
                    scatter plot?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You need to use a value formatting callback. The callback function is called
                    for each data point and is passed the Y-value as argument. This means that if
                    You also need to display the x-value it must be available in the callback
                    function,perhaps as a global data array. </p><p> Something along the lines of</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$datay</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code">...</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-var">$datax</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code">...</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$idx</span><span class="hl-code">=</span><span class="hl-number">0</span><span class="hl-code">; 
 
</span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">xyCallback</span><span class="hl-brackets">(</span><span class="hl-var">$yval</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">   
    </span><span class="hl-reserved">global</span><span class="hl-code"> </span><span class="hl-var">$datax</span><span class="hl-code">, </span><span class="hl-var">$idx</span><span class="hl-code">;   
    </span><span class="hl-reserved">return</span><span class="hl-code"> </span><span class="hl-quotes">'</span><span class="hl-string">(</span><span class="hl-quotes">'</span><span class="hl-code">.</span><span class="hl-var">$datax</span><span class="hl-brackets">[</span><span class="hl-var">$idx</span><span class="hl-code">++</span><span class="hl-brackets">]</span><span class="hl-code">.</span><span class="hl-quotes">&quot;</span><span class="hl-string">, </span><span class="hl-var">$yval</span><span class="hl-string">)</span><span class="hl-quotes">&quot;</span><span class="hl-code">; 
</span><span class="hl-brackets">}</span><span class="hl-code"> 
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Some more code ... </span><span class="hl-comment"></span><span class="hl-code">
 
</span><span class="hl-var">$graph</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Graph</span><span class="hl-brackets">(</span><span class="hl-code">...</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetScale</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">intlin</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-var">$p1</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LinePlot</span><span class="hl-brackets">(</span><span class="hl-var">$datay</span><span class="hl-code">,</span><span class="hl-var">$datax</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$p1</span><span class="hl-code">-&gt;</span><span class="hl-identifier">value</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetFormatCallback</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">xyCallback</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-var">$p1</span><span class="hl-code">-&gt;</span><span class="hl-identifier">value</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Show</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">; 
 
</span><span class="hl-comment">//</span><span class="hl-comment"> Some more code ... </span><span class="hl-comment"></span><span class="hl-code">
 
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">; 
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.58."><td align="left" valign="top"><a name="id2625213"></a><a name="id2625215"></a><p><b>C.58.</b></p></td><td align="left" valign="top"><p> Can I display stock box-charts (open, close, high, low) with JpGraph? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes, just create a <code class="code">StockPlot()</code> graph.</p></td></tr>
        
            <tr class="question" title="C.59."><td align="left" valign="top"><a name="id2625231"></a><a name="id2625239"></a><p><b>C.59.</b></p></td><td align="left" valign="top"><p> Is there any way to specify a newline in the legend box for a specific
                    legend?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes. From version 1.8 full multi-line text paragraphs are supported. Just
                    make sure that your text uses double-quotes and a newline character. </p></td></tr>
        
            <tr class="question" title="C.60."><td align="left" valign="top"><a name="id2625258"></a><a name="id2625260"></a><p><b>C.60.</b></p></td><td align="left" valign="top"><p> How can I print unicode characters?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Use &amp;#XXXX; format in your strings where XXXX is the decimal value for
                    the unicode character. You may find a list of Unicode characters and there
                    encodings at <code class="uri"><a class="uri" href="http://www.unicode.org/charts/" target="_top">www.unicode.org</a></code> Please observe that the encoding in the lists are
                    given in hexadecimal and these values must be converted to decimal. </p><p> Note: If You are working in an UTF-8 environment then the characters may be
                    input directly.</p></td></tr>
        
            <tr class="question" title="C.61."><td align="left" valign="top"><a name="id2625220"></a><a name="id2625295"></a><p><b>C.61.</b></p></td><td align="left" valign="top"><p> My background images doesn't display properly. It just shows a black solid
                    square? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You are using a very old GD version (probably 2.0.1). Background images only
                    work with a truecolor image, (enable the USE_TRUECOLOR constant). Some people
                    have reported that it works as long as the background image is not in PNG
                    format. The drawback with truecolor images is that truefont doesn't work
                    properly in GD versions &lt; 2.0.8 </p></td></tr>
        
            <tr class="question" title="C.62."><td align="left" valign="top"><a name="id2625314"></a><a name="id2625316"></a><p><b>C.62.</b></p></td><td align="left" valign="top"><p> How do I make each bar in a bar plot have it's own color?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Specify an array as argument to <code class="code">BarPlot::SetColor()</code> as in
                    </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$mybarplot-&gt;SetColor(array(&quot;red&quot;,&quot;green&quot;,&quot;blue&quot;,&quot;gray&quot;));</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.63."><td align="left" valign="top"><a name="id2625331"></a><a name="id2625341"></a><p><b>C.63.</b></p></td><td align="left" valign="top"><p> How can I adjust the position of the axis title?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> You can add an alignment parameter when you specify the title. You specify
                    one of "high", "low" or "center" as in </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$mygraph-&gt;xaxis-&gt;SetTitle(&quot;mytitle&quot;,&quot;high&quot;);
$mygraph-&gt;xaxis-&gt;SetTitle(&quot;mytitle&quot;,&quot;center&quot;);
$mygraph-&gt;xaxis-&gt;SetTitle(&quot;mytitle&quot;,&quot;low&quot;);</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.64."><td align="left" valign="top"><a name="id2625364"></a><a name="id2625367"></a><p><b>C.64.</b></p></td><td align="left" valign="top"><p> How can I change the image format, i.e jpeg, gif or png? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Use the <code class="code">Image::SetImgFormat()</code> method at runtime. You can also
                    change the default value with the <code class="code">DEFAULT_GFORMAT</code> define in
                    jpg-config.php. This is normally set to 'auto' format which means that JpGraph
                    will automatically choose the format depending on what is available.</p><p>For example to use the JPEG format :</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$graph-&gt;img-&gt;SetImgFormat('jpeg');</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.65."><td align="left" valign="top"><a name="id2625346"></a><a name="id2625403"></a><p><b>C.65.</b></p></td><td align="left" valign="top"><p> How do I specify the font for legends?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Use the Legend::SetFont() method. As in </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$graph-&gt;legend-&gt;SetFont(FF_FONT1,FS_BOLD);</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.66."><td align="left" valign="top"><a name="id2625424"></a><a name="id2625426"></a><p><b>C.66.</b></p></td><td align="left" valign="top"><p> When I rotate text and labels the text is not rotated correctly?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Red Hat 7.2 has a bug in it's TTF libraries (FreeType 2.0.3) that comes with
                    the distribution. Upgrade to FreeType 2.0.9.</p></td></tr>
        
            <tr class="question" title="C.67."><td align="left" valign="top"><a name="id2625406"></a><a name="id2625445"></a><p><b>C.67.</b></p></td><td align="left" valign="top"><p> When I rotate a paragraph (multi-line) text the paragraph is always left
                    aligned even though I have specified another alignment. It seems fine for
                    non-rotated paragraphs though. What is the problem? </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This is a limitation with the current implementation. (The reason is that GD
                    does not support inter-paragraph alignment so all that logic is done within the
                    libraries string-layout engine. </p><p> At the moment the logic only implements this paragraph alignment for
                    non-rotated paragraphs.) For rotated paragraphs left-alignment will always be
                    used regardless of specified paragraph alignment.</p></td></tr>
        
            <tr class="question" title="C.68."><td align="left" valign="top"><a name="id2625472"></a><a name="id2625474"></a><p><b>C.68.</b></p></td><td align="left" valign="top"><p> I have a huge number of data points and I only want labels (which I want to
                    specify as text string) and ticks on every n:th data. Can I do this?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes. What most users stumble on is the fact that the label array must still
                    contain data for all the data points even though only every n:th data label is
                    displayed. </p><p> This means that if your original data array only contains just the display
                    values it is necessary first to augment the label array with padding spaces to
                    fill it out. </p><p> It is then possible to use the method
                        <code class="code">Axis::SetTextTickInterval()</code> to specify that only every n:th
                    tick+label should be displayed. Something like:
                    </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">// Setup the X-axis 
$graph-&gt;xaxis-&gt;SetTickLabels($datax);
$graph-&gt;xaxis-&gt;SetTextTickInterval( ... );</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.69."><td align="left" valign="top"><a name="id2625497"></a><a name="id2625515"></a><p><b>C.69.</b></p></td><td align="left" valign="top"><p> How can I make the labels have a 1000 comma separator?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> The easiest way is to use the PHP built-in function
                        "<code class="code">number_format()</code>" as a callback (see php manual. <code class="uri"><a class="uri" href="http://www.php.net/manual/en/function.number-format.php" target="_top">number_format()</a></code>)</p><p>For example, to have the line plot display values using this format first
                    setup and install the callback function as: </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$lineplot-&gt;value-&gt;SetFormatCallback(&quot;number_format&quot;);</span></pre></td></tr></table></div><p> If you instead want the Y-axis label to use this kind of formatting install
                    the callback using </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$graph-&gt;yaxis-&gt;SetLabelFormatCallback(&quot;number_format&quot;);</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.70."><td align="left" valign="top"><a name="id2625536"></a><a name="id2625562"></a><p><b>C.70.</b></p></td><td align="left" valign="top"><p> The Y2 axis is no longer positioned at the right side of the graph</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This will happen after that You have manually specified the sclae and/or the
                    tick spacing. If the user manipulates the default scale the library defaults to
                    setting the position of the Y2 axis to the 0 X-position. It is easy to re-adjust
                    the Y2 axis position by calling SetPos() as the following code snippet
                    demonstrates
                    </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$graph-&gt;y2axis-&gt;SetPos('max');
$graph-&gt;y2axis-&gt;SetTitleSide('right');</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.71."><td align="left" valign="top"><a name="id2625573"></a><a name="id2625587"></a><p><b>C.71.</b></p></td><td align="left" valign="top"><p> How can I include several graphs in the same image?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This can be solved by a bit of extra GD code since the library by default do
                    not directly support this functionality. The easiest way to solve this is to
                    manually create a big enough empty graph with plain GD commands. Then get the
                    image handles from the Stroke() methods in the graphs that should be included.
                    It is then possible to use these handles together with the GD copy command and
                    copy the individual graphs to the previously created empty large GD image. </p><p> This is illustrated in the following code snippet. In the example below we
                    assume that graph1 is the same size as the final combined graph we would like to
                    create. This way our combined graph get a background and color as specified in
                    the first graph. </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">// Assume we would like to combine graph1,2 and 3 
 
// ...... create graph 1 here....... 
$handle1 = $graph1-&gt;Stroke( _IMG_HANDLER);  
 
// ...... create graph 2 here.......
$handle2 =  $graph2-&gt;Stroke( _IMG_HANDLER);  
 
// ...... create graph 3 here....... 
$handle3 = $graph3-&gt;Stroke( _IMG_HANDLER);   
 
// Now create the &quot;melting graph&quot; which should contain all three graphs 
// $WIDTH1 and $HEIGHT1 are width and height of graph 1 ($handle1) 
// $WIDTH2 and $HEIGHT2 are width and height of graph 2 ($handle2) 
// $WIDTH3 and $HEIGHT3 are width and height of graph 3 ($handle3) 
// $x2,$x3 and $y2,$y3 shift from top left of global graph (ie position of 
// graph2 and graph3 in global graph)  
$image = imagecreatetruecolor($WIDTH1,$HEIGHT1); 
imagecopy($image, $handle1,0, 0, 0, 0, $WIDTH1,$HEIGHT1); 
imagecopy($image, $handle1,$x1,$y1,0,0,$WIDTH2,$HEIGHT2);
imagecopy($image, $handle1,$x2,$y2,0,0,$WIDTH3,$HEIGHT3);  
 
// Stream the result back as a PNG 
image header(&quot;Content-type: image/png&quot;); 
imagepng ($image);</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.72."><td align="left" valign="top"><a name="id2625627"></a><a name="id2625629"></a><p><b>C.72.</b></p></td><td align="left" valign="top"><p> How can I have an exploded slice with 3D pie plots?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Use either <code class="code">Pi3DPLot::ExplodeSlice()</code> or
                        <code class="code">Pie3DPlot::Explode()</code>
                </p></td></tr>
        
            <tr class="question" title="C.73."><td align="left" valign="top"><a name="id2625654"></a><a name="id2625656"></a><p><b>C.73.</b></p></td><td align="left" valign="top"><p> How can I display values for each slice close to the pie?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Use the method <code class="code">PiePlot::value::Show()</code></p></td></tr>
        
            <tr class="question" title="C.74."><td align="left" valign="top"><a name="id2625667"></a><a name="id2625678"></a><p><b>C.74.</b></p></td><td align="left" valign="top"><p> How can I change between percentage and absolute values for pie slices?
                </p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Use <code class="code">PiePlot::SetValueType($aType)</code> where <code class="code">$aType</code> is
                    either <code class="code">PIE_VALUE_ABS</code> or <code class="code">PIE_VALUE_PERCENTAGE</code>. To
                    hide/show values on the pie you access the value property of the plot (just like
                    in line plots) If you want some special format of the string you also need to
                    specify a format string. By default just a number gets printed. If you (for
                    example) want percent with a "%" sign you should use a format string like "%d%%"
                    (assuming you just want to display whole numbers)
                    </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$mypieplot-&gt;value-&gt;SetFormat(&quot;%d%%&quot;);
$mypieplot-&gt;value-&gt;Show(); // Defaults to TRUE
$mypieplot-&gt;SetValueType(PIE_VALUE_PERCENTAGE);</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.75."><td align="left" valign="top"><a name="id2625719"></a><a name="id2625721"></a><p><b>C.75.</b></p></td><td align="left" valign="top"><p> Can I display the actual value as labels on the pie bar instead of the
                    percentage?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Yes, use
                    </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$pieplot-&gt;SetLabelType(PIE_LABEL_ABS);</span></pre></td></tr></table></div><p> and
                    make sure labels are not hidden. </p></td></tr>
        
            <tr class="question" title="C.76."><td align="left" valign="top"><a name="id2625742"></a><a name="id2625744"></a><p><b>C.76.</b></p></td><td align="left" valign="top"><p> How can I adust the start angle of the first slice?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> Use </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$pieplot-&gt;SetStartAngle(45);</span></pre></td></tr></table></div></td></tr>
        
            <tr class="question" title="C.77."><td align="left" valign="top"><a name="id2625757"></a><a name="id2625764"></a><p><b>C.77.</b></p></td><td align="left" valign="top"><p> When I use IE v5 or v6 I can only save the generated graph image in the
                    browser as a BMP file even if it was generated as a JPEG or PNG encoded
                    image?</p></td></tr>
            <tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> This is a bug in the way IE handles HTTP headers. By default the library
                    sends no-cache headers to instruct the browser to always make a HTTP request to
                    the server. This is necessary since graph scripts normally have the same name
                    but the graphs may change over time and we don't want the browser to be fooled
                    by thinking it has already fetched the graph before. </p><p> The only known workaround is to tell the library not to send back any
                    no-cache headers as illustrated below. </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$graph-&gt;img-&gt;SetExpired(false);                     
$graph-&gt;Stroke();</span></pre></td></tr></table></div><p> The <code class="code">SetExpired(false)</code> call instructs the library to not send
                    back any has-expired headers.</p></td></tr>
        </tbody></table></div>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="pt09.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>