├── .gitignore
├── LICENSE
├── LICENSE.fonts.txt
├── LICENSE.momchil.txt
├── README.md
├── bench.cmd
├── bugs
├── bug27.php
├── bug29.2.php
└── bug29.php
├── buildAll.cmd
├── change.log
├── composer.json
├── examples
├── bench.php
├── bootstrap.php
├── example.Combo.area.lines.php
├── example.Combo.php
├── example.Mixed.classes.php
├── example.addRandomValues.php
├── example.barcode.IMB.php
├── example.barcode.ITF.php
├── example.barcode.MSI.php
├── example.barcode.PDF417.basic.php
├── example.barcode.PDF417.binary.php
├── example.barcode.PDF417.log.numbers.php
├── example.barcode.PDF417.numbers.php
├── example.barcode.aztec.allchars.php
├── example.barcode.aztec.basic.pairCode.php
├── example.barcode.aztec.basic.php
├── example.barcode.aztec.binary.long.php
├── example.barcode.aztec.binary.php
├── example.barcode.aztec.string.php
├── example.barcode.codabar.php
├── example.barcode.dmtxs.long.php
├── example.barcode.dmtxs.short.php
├── example.barcode.eanext.php
├── example.barcode.encode11.php
├── example.barcode.encode128.php
├── example.barcode.encode39.php
├── example.barcode.encode93.php
├── example.barcode.i25.php
├── example.barcode.pharma.php
├── example.barcode.pharma2T.php
├── example.barcode.planet.php
├── example.barcode.qrcode.all.masks.php
├── example.barcode.qrcode.basic.php
├── example.barcode.qrcode.kanji.php
├── example.barcode.qrcode.long.php
├── example.barcode.qrcode.very.long.php
├── example.barcode.rms4cc.php
├── example.barcode.s25.php
├── example.barcode.upce.php
├── example.basic.php
├── example.createFunctionSerie.php
├── example.createFunctionSerie.scatter.php
├── example.draw2DPie.labels.php
├── example.draw2DPie.php
├── example.draw2DRing.php
├── example.draw2DRingValues.php
├── example.draw3DPie.labels.php
├── example.draw3DPie.php
├── example.draw3DPie.transparent.php
├── example.draw3DRing.php
├── example.draw3DRingValues.php
├── example.drawAnscombeQuartet.php
├── example.drawAntialiasPixel.php
├── example.drawAreaChart.enhanced.php
├── example.drawAreaChart.php
├── example.drawAreaChart.simple.php
├── example.drawAreaChart.threshold.php
├── example.drawAreaMirror.php
├── example.drawArrow.php
├── example.drawArrowLabel.php
├── example.drawBarChart.borders.php
├── example.drawBarChart.can.php
├── example.drawBarChart.floating.php
├── example.drawBarChart.palette.php
├── example.drawBarChart.php
├── example.drawBarChart.poll.php
├── example.drawBarChart.shaded.php
├── example.drawBarChart.simple.php
├── example.drawBarChart.spacing.php
├── example.drawBarChart.span.php
├── example.drawBarChart.vertical.php
├── example.drawBestfit.php
├── example.drawBezier.php
├── example.drawBubbleChart.php
├── example.drawBubbleChart.simple.php
├── example.drawBubbleChart.square.php
├── example.drawCircle.php
├── example.drawContour.php
├── example.drawDerivative.php
├── example.drawDerivative.simple.php
├── example.drawFilledCircle.php
├── example.drawFilledRectangle.php
├── example.drawFilledSplineChart.php
├── example.drawFilledSplineChart.threshold.php
├── example.drawFilledStepChart.php
├── example.drawFromGIF.php
├── example.drawFromJPG.php
├── example.drawFromPNG.php
├── example.drawGeometricMean.php
├── example.drawGradientArea.php
├── example.drawHarmonicMean.php
├── example.drawIndicator.php
├── example.drawLabel.barchart.php
├── example.drawLabel.bubble.php
├── example.drawLabel.caption.php
├── example.drawLabel.php
├── example.drawLabel.scatter.php
├── example.drawLabel.stacked.php
├── example.drawLabel.vertical.php
├── example.drawLegend.php
├── example.drawLine.php
├── example.drawLineChart.network.php
├── example.drawLineChart.php
├── example.drawLineChart.plots.php
├── example.drawLineChart.reversed.php
├── example.drawLineChart.simple.php
├── example.drawMedian.php
├── example.drawPieLegend.php
├── example.drawPlotChart.icon.php
├── example.drawPlotChart.php
├── example.drawPlotChart.simple.php
├── example.drawPolygon.php
├── example.drawProgress.php
├── example.drawRectangle.php
├── example.drawRoundedFilledRectangle.php
├── example.drawRoundedRectangle.php
├── example.drawScale.color.php
├── example.drawScale.custom.php
├── example.drawScale.dates.php
├── example.drawScale.floating.php
├── example.drawScale.labels.php
├── example.drawScale.manual.php
├── example.drawScale.multiple.php
├── example.drawScale.php
├── example.drawScale.reverse.php
├── example.drawScatter.shape.php
├── example.drawScatter.simple.php
├── example.drawScatterBestFit.php
├── example.drawScatterLineChart.php
├── example.drawScatterLineChart.trigo.php
├── example.drawScatterPlotChart.php
├── example.drawScatterScale.manual.php
├── example.drawScatterScale.php
├── example.drawScatterSplineChart.php
├── example.drawSimple.php
├── example.drawSpline.php
├── example.drawSplineChart.php
├── example.drawSplineChart.reversed.php
├── example.drawSplineChart.simple.php
├── example.drawStackedAreaChart.normalized.php
├── example.drawStackedAreaChart.php
├── example.drawStackedAreaChart.simple.php
├── example.drawStackedBarChart.border.php
├── example.drawStackedBarChart.can.php
├── example.drawStackedBarChart.php
├── example.drawStackedBarChart.pyramid.php
├── example.drawStackedBarChart.rounded.php
├── example.drawStackedBarChart.shaded.php
├── example.drawStandardDeviation.php
├── example.drawStepChart.php
├── example.drawStepChart.simple.php
├── example.drawStockChart.median.php
├── example.drawStockChart.php
├── example.drawStockChart.simple.php
├── example.drawSurface.palette.php
├── example.drawSurface.php
├── example.drawSurface.simple.php
├── example.drawText.php
├── example.drawThreshold.labels.php
├── example.drawThreshold.php
├── example.drawThresholdArea.php
├── example.drawXThreshold.php
├── example.drawXThresholdArea.php
├── example.drawZoneChart.php
├── example.drawingObjects.php
├── example.normalize.php
├── example.polar.php
├── example.polar.values.php
├── example.pyramid.php
├── example.radar.fixedmax.php
├── example.radar.labels.php
├── example.radar.php
├── example.radar.values.php
├── example.setFontProperties.php
├── example.setShadow.php
├── example.split.php
├── example.spring.complex.php
├── example.spring.labels.php
├── example.spring.php
├── example.spring.relations.php
├── example.text.alignment.php
├── example.transparent.background.php
├── example.writeBounds.php
├── fetch.src.php
├── functions.inc.php
├── index.php
├── myColors.php
├── pDataExt.php
├── resources
│ ├── accept.png
│ ├── application_form.png
│ ├── application_view_list.png
│ ├── application_view_tile.png
│ ├── background.console.png
│ ├── blocnote.png
│ ├── chart_bar.png
│ ├── chart_bar_edit.png
│ ├── chart_curve.png
│ ├── chart_line.png
│ ├── cog.png
│ ├── color_swatch.png
│ ├── comment.png
│ ├── computer.gif
│ ├── dash-explorer-blank.png
│ ├── dash-explorer-last.png
│ ├── dash-explorer-noleaf.png
│ ├── dash-explorer.png
│ ├── dash.png
│ ├── database_table.png
│ ├── folder.png
│ ├── hologram.png
│ ├── landscape1.jpg
│ ├── landscape2.jpg
│ ├── layout_edit.png
│ ├── page_edit.png
│ ├── paintcan.png
│ ├── serie1.png
│ ├── serie2.png
│ ├── shape_flip_vertical.png
│ ├── tab.png
│ ├── vector.png
│ ├── wait.gif
│ ├── wand.png
│ └── wrench.png
└── sandbox
│ ├── functions.js
│ ├── helper.class.php
│ ├── index.php
│ ├── render.php
│ └── style.css
├── fonts
├── Abel-Regular.ttf
├── Cairo-Regular.ttf
├── Dosis-Light.ttf
├── Gayathri-Regular.ttf
├── PressStart2P-Regular.ttf
└── Signika-Regular.ttf
├── index.php
├── pChart
├── Barcodes
│ ├── Aztec
│ │ ├── Binary.php
│ │ ├── Dynamic.php
│ │ ├── Encoder.php
│ │ ├── ReedSolomon.php
│ │ └── Token.php
│ ├── DMTX
│ │ └── Encoder.php
│ ├── Linear
│ │ ├── Codabar.php
│ │ ├── Code11.php
│ │ ├── Code128.php
│ │ ├── Code39.php
│ │ ├── Code93.php
│ │ ├── Eanext.php
│ │ ├── IMB.php
│ │ ├── ITF.php
│ │ ├── MSI.php
│ │ ├── Pharmacode.php
│ │ ├── Postnet.php
│ │ ├── Rms4cc.php
│ │ ├── UPC.php
│ │ └── b2of5.php
│ ├── PDF417
│ │ ├── Codes.php
│ │ ├── Encoder.php
│ │ ├── EncoderByte.php
│ │ ├── EncoderNumber.php
│ │ ├── EncoderText.php
│ │ └── ReedSolomon.php
│ ├── QRCode
│ │ ├── Encoder.php
│ │ ├── Frame.php
│ │ ├── Mask.php
│ │ └── ReedSolomon.php
│ └── pConf.php
├── pBarcodes1D.php
├── pBarcodes2D.php
├── pBubble.php
├── pCharts.php
├── pColor.php
├── pColorGradient.php
├── pData.php
├── pDraw.php
├── pException.php
├── pIndicator.php
├── pPie.php
├── pPyramid.php
├── pRadar.php
├── pScatter.php
├── pSpring.php
├── pStock.php
└── pSurface.php
├── php.webserver.cmd
└── readme.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | php.exe
2 | php.ini
3 | php7ts.dll
4 | php8ts.dll
5 | php_gd2.dll
6 | cloc-1.80.exe
7 | php.webserver.cmd
8 | Barcodes/*
9 | QRCode/*
10 | PDF417/*
11 | temp/*
12 | php_xdebug*
13 | WinCacheGrind*
14 | php_gd.dll
15 |
--------------------------------------------------------------------------------
/LICENSE.momchil.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Momchil Bozhinov
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Code is being tested against PHP versions 7.0 to 8.0
2 | PHP version 8.1 brings breaking changes to imagefilledpolygon and count
3 | for this reason I will create a separate repo for it.
4 |
5 |
6 | pChart 2.1 library for PHP 7 (7-Compatible branch)
7 | ===================
8 |
9 | The good old pChart got an overhaul!
10 |
11 | - All examples work fine with zero code modifications to them
12 | - Code was beautified
13 | - Made minor improvements and added some speed ups
14 |
15 |
16 | pChart 2.2
17 | ===================
18 | This version will NOT work with your existing code, but supports PHP 7.0 & 7.1
19 | Please check the change log for the complete list of changes.
20 |
21 | Major changes:
22 | - Code cleanup
23 | - Bootstrapped
24 | - Exceptions
25 | - Introduced pColor & pColorGradient
26 | - Moved functions around
27 | - Added support for compression and filters in PNG output
28 | - Cache: added PDO SQLite storage option
29 | - ImageMapper: JavaScript re-write using jQuery
30 | - ImageMapper: added PDO SQLite storage option
31 | - Removed DelayedLoader
32 |
33 |
34 | pChart 2.3 (recommended)
35 | ===================
36 | Goals:
37 | - Reduce the use of the hard disk to fonts only
38 | - Eliminate not-exactly-free 3rd party components
39 | - Add the first batch of new features since 2011
40 |
41 | Major changes:
42 | - PHP 7.2+ required from now on
43 | - Introduce pQRCode /* Check my PHP-QRCode-fork repo */
44 | - Replace all fonts with Open Font licensed ones
45 | - Performace boost
46 | - pBarcode to own dir
47 | - No more config files (palettes & barcode db)
48 |
49 |
50 | pChart 2.4 (in progress)
51 | ===================
52 | Goals:
53 | - Introduce pPyramid
54 |
55 | Major changes:
56 | - Removed pImageMap, pCache, pBarcode
57 | - Introduced the new Barcodes lib /* Check out my PHP-Barcodes-fork repo */
58 | - Introduced the new PDF417 lib /* Check out my PHP-PDF417-fork repo */
59 | - Introduced the new Aztec lib /* Check out my PHP-Aztec-fork repo */
60 | - Introduced the new QRCode lib /* Check out my PHP-QRCode-fork repo */
61 | - Explicitly declare the visibility for methods and properties
62 |
--------------------------------------------------------------------------------
/bench.cmd:
--------------------------------------------------------------------------------
1 | ECHO OFF
2 | setlocal ENABLEDELAYEDEXPANSION
3 |
4 | CLS
5 |
6 | php -v 1>NUL 2>NUL
7 | IF NOT %ERRORLEVEL% == 0 GOTO noPHP
8 |
9 | php examples\bench.php
10 |
11 | ECHO.
12 | ECHO.
13 | ECHO Examples rendered in the "temp\" folder.
14 | ECHO.
15 | GOTO end
16 |
17 | :noPHP
18 | ECHO.
19 | ECHO The PHP binaries can't be found!
20 | ECHO.
21 | ECHO Examples rendering has been aborded.
22 |
23 | :end
24 | PAUSE >NUL
--------------------------------------------------------------------------------
/bugs/bug29.2.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([50, 10, 35, 5], "Serie1");
15 |
16 | /* Define the abscissa serie */
17 | $myPicture->myData->addPoints(["50€ ", "10€", "35€", "5€"],"Labels");
18 | $myPicture->myData->setAbscissa("Labels");
19 |
20 | /* Draw a solid background */
21 | $myPicture->drawFilledRectangle(0,0,500,400,["Color"=>new pColor(30,40,30,20)]);
22 |
23 | /* Overlay with a gradient */
24 | $myPicture->drawGradientArea(0,0,500,400, DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
25 |
26 | $myPicture->setFontProperties(["FontName"=>"pChart/fonts/Cairo-Regular.ttf","FontSize"=>12,"Color"=>new pColor(80)]);
27 |
28 | /* Create the pPie object */
29 | $PieChart = new pPie($myPicture);
30 |
31 | /* Draw an AA pie chart */
32 | $PieChart->draw3DRing(215,200,["Radius"=>53, "DrawLabels"=>TRUE,"WriteValues"=>PIE_VALUE_NATURAL,"DataGapAngle"=>8,"DataGapRadius"=>4,"Border"=>TRUE, "BorderColor"=>new pColor(40)]);
33 |
34 | /* Write the legend box */
35 | $PieChart->drawPieLegend(20,40,["FontSize"=>12, "BoxSize"=>16,"Style"=>LEGEND_BOX,"Mode"=>LEGEND_VERTICAL]);
36 |
37 | /* Render the picture (choose the best way) */
38 | $myPicture->autoOutput("temp/bug29.2.png");
39 |
--------------------------------------------------------------------------------
/bugs/bug29.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([50, 10, 35, 5], "Serie1");
15 |
16 | /* Define the abscissa serie */
17 | $myPicture->myData->addPoints(["50€ ", "10€", "35€", "5€"],"Labels");
18 | $myPicture->myData->setAbscissa("Labels");
19 |
20 | /* Draw a solid background */
21 | $myPicture->drawFilledRectangle(0,0,350,280,["Color"=>new pColor(30,40,30,20)]);
22 |
23 | /* Overlay with a gradient */
24 | $myPicture->drawGradientArea(0,0,350,280, DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
25 |
26 | $myPicture->setFontProperties(["FontName"=>"pChart/fonts/Cairo-Regular.ttf","FontSize"=>12,"Color"=>new pColor(80)]);
27 |
28 | /* Create the pPie object */
29 | $PieChart = new pPie($myPicture);
30 |
31 | /* Draw an AA pie chart */
32 | $PieChart->draw3DPie(215,200,["Radius"=>53, "DrawLabels"=>TRUE,"WriteValues"=>PIE_VALUE_NATURAL,"DataGapAngle"=>8,"DataGapRadius"=>4,"Border"=>TRUE, "BorderColor"=>new pColor(40)]);
33 |
34 | /* Write the legend box */
35 | $PieChart->drawPieLegend(20,40,["FontSize"=>12, "BoxSize"=>16,"Style"=>LEGEND_BOX,"Mode"=>LEGEND_VERTICAL]);
36 |
37 | /* Render the picture (choose the best way) */
38 | $myPicture->autoOutput("temp/bug29.png");
39 |
--------------------------------------------------------------------------------
/buildAll.cmd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/buildAll.cmd
--------------------------------------------------------------------------------
/change.log:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/change.log
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bozhinov/pchart2.0-for-php7",
3 | "description": "pChart 2.3 compatible with PHP 7",
4 | "keywords": [
5 | "php",
6 | "charts",
7 | "php7",
8 | "form",
9 | "pie",
10 | "bar",
11 | "qrcode",
12 | "barcode",
13 | "server side charts"
14 | ],
15 | "homepage": "https://github.com/bozhinov/pChart2.0-for-PHP7",
16 | "type": "project",
17 | "license": "GPL-3.0",
18 | "support": {
19 | "issues": "https://github.com/bozhinov/pChart2.0-for-PHP7/issues",
20 | "source": "https://github.com/bozhinov/pChart2.0-for-PHP7"
21 | },
22 | "authors": [
23 | {
24 | "name": "Momchil Bozhinov(bozhinov)",
25 | "email": "momchil@bojinov.info"
26 | }
27 | ],
28 |
29 | "autoload": {
30 | "classmap": [
31 | "pChart/"
32 | ]
33 | },
34 |
35 | "minimum-stability": "dev",
36 | "prefer-stable": true,
37 |
38 | "require": {
39 | "php": ">=7.2",
40 | "ext-gd": "*"
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/examples/bench.php:
--------------------------------------------------------------------------------
1 | %s]%s\r", $perc, str_repeat("=", $bar), str_repeat(" ", $width-$bar), $info);
19 | }
20 |
21 | $bench_allFiles = glob("examples/example.*");
22 | $bench_countFiles = count($bench_allFiles);
23 | $bench_i = 0;
24 |
25 | foreach ($bench_allFiles as $bench_fileName){
26 | if (!in_array($bench_fileName, $bench_ignored)){
27 | //echo "Processing: ".$bench_fileName."\r\n";
28 | eval('?>' . file_get_contents($bench_fileName, TRUE) . 'drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | #"mode" => "PRE",
17 | "scale" => 2,
18 | "ratio" => 3,
19 | "padding" => 10,
20 | "height" => 20
21 | ];
22 |
23 | # unable to verify. could not find app to scan it.
24 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_IMB, $myPicture);
25 | $barcodes->draw("94107-18350", 0, 0, $opts);
26 |
27 | $myPicture->autoOutput("temp/example.barcodes.imb.png");
28 |
--------------------------------------------------------------------------------
/examples/example.barcode.ITF.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [];
16 |
17 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_ITF, $myPicture);
18 | $barcodes->draw("12250000234502", 1, 1, $opts);
19 |
20 | $myPicture->autoOutput("temp/example.barcodes.ITF.png");
21 |
--------------------------------------------------------------------------------
/examples/example.barcode.MSI.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | #"mode" => "+",
17 | "scale" => 2,
18 | "padding" => 10,
19 | "label" => [
20 | 'height'=> 10,
21 | 'size' => 1,
22 | 'color' => new pColor(0)
23 | ]
24 | ];
25 |
26 | # unable to verify. could not find app to scan it.
27 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_MSI, $myPicture);
28 | $barcodes->draw("123456789", 0, 0, $opts);
29 |
30 | $myPicture->autoOutput("temp/example.barcodes.msi.png");
31 |
--------------------------------------------------------------------------------
/examples/example.barcode.PDF417.basic.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | // Text to be encoded into the barcode
16 | $text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur
17 | imperdiet sit amet magna faucibus aliquet. Aenean in velit in mauris imperdiet
18 | scelerisque. Maecenas a auctor erat.';
19 |
20 | // draw the data, returns a BarcodeData object
21 | $pdf417 = new pBarcodes2D(BARCODES_ENGINE_PDF417, $myPicture);
22 | $pdf417->draw($text, 10, 10);
23 |
24 | /* Render the picture (choose the best way) */
25 | $myPicture->autoOutput("temp/example.barcodes.pdf417.basic.png");
26 |
--------------------------------------------------------------------------------
/examples/example.barcode.PDF417.binary.php:
--------------------------------------------------------------------------------
1 | draw($text, 1, 1, ['hint' => BARCODES_PDF417_HINT_BINARY]);
21 |
22 | /* Render the picture (choose the best way) */
23 | $myPicture->autoOutput("temp/example.barcodes.pdf417.binary.png");
24 |
--------------------------------------------------------------------------------
/examples/example.barcode.PDF417.log.numbers.php:
--------------------------------------------------------------------------------
1 | draw($text, 1, 1, ['hint' => BARCODES_PDF417_HINT_NUMBERS]);
20 |
21 | /* Render the picture (choose the best way) */
22 | $myPicture->autoOutput("temp/example.barcodes.pdf417.long.numbers.png");
23 |
--------------------------------------------------------------------------------
/examples/example.barcode.PDF417.numbers.php:
--------------------------------------------------------------------------------
1 | draw($text, 1, 1);
19 |
20 | /* Render the picture (choose the best way) */
21 | $myPicture->autoOutput("temp/example.barcodes.pdf417.numbers.png");
22 |
--------------------------------------------------------------------------------
/examples/example.barcode.aztec.allchars.php:
--------------------------------------------------------------------------------
1 | ?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
16 |
17 | // draw the data
18 | $aztec->draw($text, 1, 1);
19 |
20 | /* Render the picture (choose the best way) */
21 | $myPicture->autoOutput('temp/example.barcodes.aztec.allchars.png');
--------------------------------------------------------------------------------
/examples/example.barcode.aztec.basic.pairCode.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,450,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $aztec = new pBarcodes2D(BARCODES_ENGINE_AZTEC, $myPicture);
16 |
17 | // Text to be encoded
18 | $text = 'Hello World 3 4 5 asasdas22345 . 456!';
19 |
20 | // draw the data
21 | $aztec->draw($text, 20, 20);
22 |
23 | /* Render the picture (choose the best way) */
24 | $myPicture->autoOutput('temp/example.barcodes.aztec.pairCode.png');
25 |
--------------------------------------------------------------------------------
/examples/example.barcode.aztec.basic.php:
--------------------------------------------------------------------------------
1 | draw($text, $posX = 10, $posY = 10);
19 |
20 | /* Render the picture (choose the best way) */
21 | $myPicture->autoOutput('temp/example.barcodes.aztec.basic.png');
22 |
--------------------------------------------------------------------------------
/examples/example.barcode.aztec.binary.long.php:
--------------------------------------------------------------------------------
1 | draw($text, 1, 1, ["hint" => BARCODES_AZTEC_HINT_BINARY]);
20 |
21 | /* Render the picture (choose the best way) */
22 | $myPicture->autoOutput('temp/example.barcodes.aztec.binary.long.png');
23 |
--------------------------------------------------------------------------------
/examples/example.barcode.aztec.binary.php:
--------------------------------------------------------------------------------
1 | ?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
16 |
17 | // draw the data
18 | $aztec->draw($text, 1, 1, ["hint" => BARCODES_AZTEC_HINT_BINARY]);
19 |
20 | /* Render the picture (choose the best way) */
21 | $myPicture->autoOutput('temp/example.barcodes.aztec.binary.png');
22 |
--------------------------------------------------------------------------------
/examples/example.barcode.aztec.string.php:
--------------------------------------------------------------------------------
1 | draw($text, 1, 1, ["hint" => BARCODES_AZTEC_HINT_BINARY]);
22 |
23 | /* Render the picture (choose the best way) */
24 | $myPicture->autoOutput('temp/example.barcodes.aztec.string.png');
25 |
--------------------------------------------------------------------------------
/examples/example.barcode.codabar.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = ["height" => 30, "padding" => 10];
16 |
17 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_CODABAR, $myPicture);
18 | $barcodes->draw("31117013206375", 1, 1, $opts);
19 |
20 | $myPicture->autoOutput("temp/example.barcodes.codabar.png");
21 |
--------------------------------------------------------------------------------
/examples/example.barcode.dmtxs.long.php:
--------------------------------------------------------------------------------
1 | draw($data, 1, 1, $opts);
20 |
21 | $myPicture->autoOutput("temp/example_dmtxs_long.png");
22 |
--------------------------------------------------------------------------------
/examples/example.barcode.dmtxs.short.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,250,250,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $barcodes = new pBarcodes2D(BARCODES_ENGINE_DMTX, $myPicture);
16 |
17 | $data = 154703;
18 | $opts = [
19 | "palette" => [
20 | "bgColor" => new pColor(255), // CS - Color of spaces
21 | "color" => new pColor(0) // CM - Color of modules
22 | ],
23 | 'padding' => 6,
24 | 'pattern' => BARCODES_DTMX_PATTERN_RECT,
25 | 'GS-1' => true
26 | ];
27 |
28 | $barcodes->draw($data, 10, 10, $opts);
29 |
30 | $myPicture->autoOutput("temp/example_dmtxs_short.png");
31 |
--------------------------------------------------------------------------------
/examples/example.barcode.eanext.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | "mode" => "EAN5", # EAN2
17 | "scale" => 2,
18 | "ratio" => 3,
19 | "padding" => 10,
20 | "height" => 20
21 | ];
22 |
23 | # unable to verify. could not find app to scan it.
24 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_EANEXT, $myPicture);
25 | $barcodes->draw("51515", 0, 0, $opts);
26 |
27 | $myPicture->autoOutput("temp/example.barcodes.eanext.png");
28 |
--------------------------------------------------------------------------------
/examples/example.barcode.encode11.php:
--------------------------------------------------------------------------------
1 | 40,
16 | 'width' => 220,
17 | "label" => [
18 | 'height'=> 10,
19 | 'size' => 1,
20 | 'color' => (new pColor())->fromHex("2AFF55")
21 | ]
22 | ];
23 |
24 | # unable to verify. could not find app to scan it.
25 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_CODE11, $myPicture);
26 | $barcodes->draw("1232342342342343312", 0, 0, $opts);
27 |
28 | $myPicture->autoOutput("temp/example.barcodes.encode11.png");
29 |
--------------------------------------------------------------------------------
/examples/example.barcode.encode128.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $data = "Do what you want !";
16 |
17 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_CODE128, $myPicture);
18 | $barcodes->draw($data, 10, 10, []);
19 |
20 | /* Render the picture (choose the best way) */
21 | $myPicture->autoOutput("temp/example.barcodes.encode128.png");
22 |
--------------------------------------------------------------------------------
/examples/example.barcode.encode39.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | "mode" => "E+",
17 | "nobackground" => true,
18 | "label" => [
19 | 'height'=> 10,
20 | 'size' => 3,
21 | 'offset' => 5,
22 | 'color' => (new pColor())->fromHex("ffffff")
23 | ]
24 | ];
25 |
26 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_CODE39, $myPicture);
27 | $barcodes->draw("12250000234502{}", 1, 1, $opts);
28 |
29 | $myPicture->autoOutput("temp/example.barcodes.encode39.png");
30 |
--------------------------------------------------------------------------------
/examples/example.barcode.encode93.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [];
16 |
17 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_CODE93, $myPicture);
18 | $barcodes->draw("ABC-1234-/+", 1, 1, $opts);
19 |
20 | $myPicture->autoOutput("temp/example.barcodes.encode93.png");
21 |
--------------------------------------------------------------------------------
/examples/example.barcode.i25.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | "mode" => "Interleaved+",
17 | "scale" => 2,
18 | "ratio" => 3,
19 | "padding" => 10,
20 | "height" => 20
21 | ];
22 |
23 | # unable to verify. could not find app to scan it.
24 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_B2OF5, $myPicture);
25 | $barcodes->draw("51515", 0, 0, $opts);
26 |
27 | $myPicture->autoOutput("temp/example.barcodes.i25.png");
28 |
--------------------------------------------------------------------------------
/examples/example.barcode.pharma.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | "scale" => 2,
17 | "padding" => 10,
18 | "label" => [
19 | 'height'=> 10,
20 | 'size' => 1,
21 | 'color' => new pColor(0)
22 | ]
23 | ];
24 |
25 | # unable to verify. could not find app to scan it.
26 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_PHARMA, $myPicture);
27 | $barcodes->draw("123456789", 0, 0, $opts);
28 |
29 | $myPicture->autoOutput("temp/example.barcodes.pharma.png");
30 |
--------------------------------------------------------------------------------
/examples/example.barcode.pharma2T.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | "mode" => "2T",
17 | "scale" => 10,
18 | "ratio" => 3,
19 | "height" => 65,
20 | "label" => [
21 | 'height'=> 10,
22 | 'size' => 1,
23 | 'color' => new pColor(0)
24 | ]
25 | ];
26 |
27 | # unable to verify. could not find app to scan it.
28 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_PHARMA, $myPicture);
29 | $barcodes->draw("123456789", 0, 0, $opts);
30 |
31 | $myPicture->autoOutput("temp/example.barcodes.pharma2T.png");
32 |
--------------------------------------------------------------------------------
/examples/example.barcode.planet.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | "mode" => "planet",
17 | "scale" => 2,
18 | "ratio" => 3,
19 | "padding" => 10,
20 | "height" => 20,
21 | "label" => [
22 | 'height'=> 10,
23 | 'size' => 1,
24 | 'color' => new pColor(0)
25 | ]
26 | ];
27 |
28 | # unable to verify. could not find app to scan it.
29 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_POSTNET, $myPicture);
30 | $barcodes->draw("55555-1237", 0, 0, $opts);
31 |
32 | $myPicture->autoOutput("temp/example.barcodes.planet.png");
33 |
--------------------------------------------------------------------------------
/examples/example.barcode.qrcode.all.masks.php:
--------------------------------------------------------------------------------
1 | draw('https://github.com/bozhinov/PHP-QRCode-fork', 1, 1, ['level' => BARCODES_QRCODE_LEVEL_Q, 'scale' => 10, 'padding' => 4]);
15 |
16 | /* Render the picture (choose the best way) */
17 | $myPicture->autoOutput('temp/example.barcodes.qrcode.all.masks.png');
18 |
--------------------------------------------------------------------------------
/examples/example.barcode.qrcode.basic.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,700,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $QRCode = new pBarcodes2D(BARCODES_ENGINE_QRCODE, $myPicture);
16 | $QRCode->draw(
17 | 'http://www.test.bg/long long long string',
18 | $x = 20,
19 | $y = 20,
20 | [
21 | 'palette' => ['color' => new pColor(255), 'bgColor' => new pColor(0)], // colors are reversed
22 | "error_correction" => BARCODES_QRCODE_LEVEL_L,
23 | "scale" => 7,
24 | "padding" => 4,
25 | "random_mask" => 4
26 | ]
27 | );
28 |
29 | /* Render the picture (choose the best way) */
30 | $myPicture->autoOutput('temp/example.barcodes.qrcode.basic.png');
31 |
32 | /* Usage
33 |
34 | */
35 | # Levels
36 | # https://www.qrcode.com/en/about/error_correction.html
37 | # Level L = ~7%
38 | # Level M = ~15%
39 | # Level Q = ~25%
40 | # Level H = ~30%
41 |
42 | # Encoding hints
43 | # https://www.thonky.com/qr-code-tutorial/data-encoding
44 | # Encoding Mode Maximum number of characters a 40-L code can contain
45 | # Numeric 7089 characters
46 | # Alphanumeric 4296 characters
47 | # Byte 2953 characters
48 | # Kanji 1817 characters
--------------------------------------------------------------------------------
/examples/example.barcode.qrcode.kanji.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.barcode.qrcode.kanji.php
--------------------------------------------------------------------------------
/examples/example.barcode.qrcode.long.php:
--------------------------------------------------------------------------------
1 | draw('http://www.test.bg/ long long long string', 1, 1);
15 |
16 | /* Render the picture (choose the best way) */
17 | $myPicture->autoOutput('temp/example.barcodes.qrcode.long.png');
18 |
--------------------------------------------------------------------------------
/examples/example.barcode.qrcode.very.long.php:
--------------------------------------------------------------------------------
1 | draw(str_repeat("A", 256), 1, 1, ['level' => BARCODES_QRCODE_LEVEL_Q, 'scale' => 10, 'padding' => 4]);
15 |
16 | /* Render the picture (choose the best way) */
17 | $myPicture->autoOutput('temp/example.barcodes.QRcode.very.long.png');
--------------------------------------------------------------------------------
/examples/example.barcode.rms4cc.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | "mode" => "KIX",
17 | "scale" => 2,
18 | "ratio" => 3,
19 | "padding" => 10,
20 | "height" => 20,
21 | "label" => [
22 | 'height'=> 10,
23 | 'size' => 1,
24 | 'color' => new pColor(0)
25 | ]
26 | ];
27 |
28 | # unable to verify. could not find app to scan it.
29 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_RMS4CC, $myPicture);
30 | $barcodes->draw("RoyalMail", 0, 0, $opts);
31 |
32 | $myPicture->autoOutput("temp/example.barcodes.rms4cc.png");
33 |
--------------------------------------------------------------------------------
/examples/example.barcode.s25.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | "mode" => "Standard",
17 | "scale" => 2,
18 | "ratio" => 3,
19 | "padding" => 10,
20 | "height" => 20
21 | ];
22 |
23 | # unable to verify. could not find app to scan it.
24 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_B2OF5, $myPicture);
25 | $barcodes->draw("51515", 0, 0, $opts);
26 |
27 | $myPicture->autoOutput("temp/example.barcodes.s25.png");
28 |
--------------------------------------------------------------------------------
/examples/example.barcode.upce.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
14 |
15 | $opts = [
16 | "mode" => "upce",
17 | "scale" => 2,
18 | "padding" => 10,
19 | ];
20 |
21 | # unable to verify. could not find app to scan it.
22 | $barcodes = new pBarcodes1D(BARCODES_ENGINE_UPC, $myPicture);
23 | $barcodes->draw("0123456", 0, 0, $opts);
24 |
25 | $myPicture->autoOutput("temp/example.barcodes.upce.png");
26 |
--------------------------------------------------------------------------------
/examples/example.basic.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([1,3,4,3,5], "Serie1");
15 |
16 | /* Choose a nice font */
17 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>11]);
18 |
19 | /* Define the boundaries of the graph area */
20 | $myPicture->setGraphArea(60,40,670,190);
21 |
22 | /* Draw the scale, keep everything automatic */
23 | $myPicture->drawScale();
24 |
25 | /* Draw the scale, keep everything automatic */
26 | (new pCharts($myPicture))->drawSplineChart();
27 |
28 | /* Render the picture (choose the best way) */
29 | $myPicture->autoOutput("temp/example.basic.png");
30 |
31 |
--------------------------------------------------------------------------------
/examples/example.draw2DPie.labels.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([50,2,3,4,7,10,25,48,41,10],"ScoreA");
17 | $myPicture->myData->setSerieDescription("ScoreA","Application A");
18 |
19 | /* Define the abscissa serie */
20 | $myPicture->myData->addPoints(["A0","B1","C2","D3","E4","F5","G6","H7","I8","J9"],"Labels");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Draw a solid background */
24 | $myPicture->drawFilledRectangle(0,0,300,300,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
25 |
26 | /* Overlay with a gradient */
27 | $myPicture->drawGradientArea(0,0,300,260, DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
28 | $myPicture->drawGradientArea(0,0,300,20, DIRECTION_VERTICAL, ["StartColor"=>ColorBlack(),"EndColor"=>new pColor(50,50,50,100)]);
29 |
30 | /* Add a border to the picture */
31 | $myPicture->drawRectangle(0,0,299,259,["Color"=>ColorBlack()]);
32 |
33 | /* Write the picture title */
34 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
35 | $myPicture->drawText(10,15,"pPie - Draw 2D pie charts",["Color"=>ColorWhite()]);
36 |
37 | /* Set the default font properties */
38 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>9,"Color"=>new pColor(80)]);
39 |
40 | /* Enable shadow computing */
41 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,ColorBlack($Alpha=50)]);
42 |
43 | /* Create the pPie object */
44 | $PieChart = new pPie($myPicture);
45 |
46 | /* Draw an AA pie chart */
47 | $PieChart->draw2DPie(160,140,["DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE]);
48 |
49 | /* Write the legend box */
50 | $myPicture->setShadow(FALSE);
51 | $PieChart->drawPieLegend(15,40,["Color"=>new pColor(200,200,200,20)]);
52 |
53 | /* Render the picture (choose the best way) */
54 | $myPicture->autoOutput("temp/example.draw2DPie.labels.png");
55 |
56 |
--------------------------------------------------------------------------------
/examples/example.draw2DRing.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([50,2,3,4,7,10,25,48,41,10],"ScoreA");
17 | $myPicture->myData->setSerieDescription("ScoreA","Application A");
18 |
19 | /* Define the abscissa serie */
20 | $myPicture->myData->addPoints(["A0","B1","C2","D3","E4","F5","G6","H7","I8","J9"],"Labels");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Draw a solid background */
24 | $myPicture->drawFilledRectangle(0,0,300,300,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
25 |
26 | /* Overlay with a gradient */
27 | $myPicture->drawGradientArea(0,0,300,260, DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
28 | $myPicture->drawGradientArea(0,0,300,20, DIRECTION_VERTICAL, ["StartColor"=>ColorBlack(), "EndColor"=>new pColor(50)]);
29 |
30 | /* Add a border to the picture */
31 | $myPicture->drawRectangle(0,0,299,259,["Color"=>ColorBlack()]);
32 |
33 | /* Write the picture title */
34 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
35 | $myPicture->drawText(10,15,"pPie - Draw 2D ring charts",["Color"=>ColorWhite()]);
36 |
37 | /* Set the default font properties */
38 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>9,"Color"=>new pColor(80)]);
39 |
40 | /* Enable shadow computing */
41 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>ColorBlack($Alpha=50)]);
42 |
43 | /* Create the pPie object */
44 | $PieChart = new pPie($myPicture);
45 |
46 | /* Draw an AA pie chart */
47 | $PieChart->draw2DRing(160,140,["DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE]);
48 |
49 | /* Write the legend box */
50 | $myPicture->setShadow(FALSE);
51 | $PieChart->drawPieLegend(15,40,["Color"=>new pColor(200,200,200,20)]);
52 |
53 | /* Render the picture (choose the best way) */
54 | $myPicture->autoOutput("temp/example.draw2DRing.png");
55 |
56 |
--------------------------------------------------------------------------------
/examples/example.draw2DRingValues.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([50,2,3,4,7,10,25,48,41,10],"ScoreA");
17 | $myPicture->myData->setSerieDescription("ScoreA","Application A");
18 |
19 | /* Define the abscissa serie */
20 | $myPicture->myData->addPoints(["A0","B1","C2","D3","E4","F5","G6","H7","I8","J9"],"Labels");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Draw a solid background */
24 | $myPicture->drawFilledRectangle(0,0,300,300,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
25 |
26 | /* Overlay with a gradient */
27 | $myPicture->drawGradientArea(0,0,300,260, DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
28 | $myPicture->drawGradientArea(0,0,300,20, DIRECTION_VERTICAL, ["StartColor"=>ColorBlack(), "EndColor"=>new pColor(50)]);
29 |
30 | /* Add a border to the picture */
31 | $myPicture->drawRectangle(0,0,299,259,["Color"=>ColorBlack()]);
32 |
33 | /* Write the picture title */
34 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
35 | $myPicture->drawText(10,15,"pPie - Draw 2D ring charts",["Color"=>ColorWhite()]);
36 |
37 | /* Set the default font properties */
38 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>9,"Color"=>new pColor(80)]);
39 |
40 | /* Enable shadow computing */
41 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>ColorBlack($Alpha=50)]);
42 |
43 | /* Create the pPie object */
44 | $PieChart = new pPie($myPicture);
45 |
46 | /* Draw an AA pie chart */
47 | $PieChart->draw2DRing(160,140,["WriteValues"=>TRUE,"ValueColor"=>ColorWhite(),"Border"=>TRUE]);
48 |
49 | /* Write the legend box */
50 | $myPicture->setShadow(FALSE);
51 | $PieChart->drawPieLegend(15,40,["Color"=>new pColor(200,200,200,20)]);
52 |
53 | /* Render the picture (choose the best way) */
54 | $myPicture->autoOutput("temp/example.draw2DRingValue.png");
55 |
56 |
--------------------------------------------------------------------------------
/examples/example.draw3DPie.labels.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([50,2,3,4,7,10,25,48,41,10],"ScoreA");
17 | $myPicture->myData->setSerieDescription("ScoreA","Application A");
18 |
19 | /* Define the abscissa serie */
20 | $myPicture->myData->addPoints(["A0","B1","C2","D3","E4","F5","G6","H7","I8","J9"],"Labels");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Draw a solid background */
24 | $myPicture->drawFilledRectangle(0,0,300,300,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
25 |
26 | /* Overlay with a gradient */
27 | $myPicture->drawGradientArea(0,0,300,260, DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
28 | $myPicture->drawGradientArea(0,0,300,20, DIRECTION_VERTICAL, ["StartColor"=>ColorBlack(), "EndColor"=>new pColor(50)]);
29 |
30 | /* Add a border to the picture */
31 | $myPicture->drawRectangle(0,0,299,259,["Color"=>ColorBlack()]);
32 |
33 | /* Write the picture title */
34 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
35 | $myPicture->drawText(10,15,"pPie - Draw 2D pie charts",["Color"=>ColorWhite()]);
36 |
37 | /* Set the default font properties */
38 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>9,"Color"=>new pColor(80)]);
39 |
40 | /* Create the pPie object */
41 | $PieChart = new pPie($myPicture);
42 |
43 | /* Draw an AA pie chart */
44 | $PieChart->draw3DPie(160,140,["Radius"=>70,"DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE]);
45 |
46 | /* Write the legend box */
47 | $myPicture->setShadow(FALSE);
48 | $PieChart->drawPieLegend(15,40,["Color"=>new pColor(200,200,200,20)]);
49 |
50 | /* Render the picture (choose the best way) */
51 | $myPicture->autoOutput("temp/example.draw3DPie.labels.png");
52 |
53 |
--------------------------------------------------------------------------------
/examples/example.draw3DPie.transparent.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([40,30,20],"ScoreA");
17 | $myPicture->myData->setSerieDescription("ScoreA","Application A");
18 |
19 | /* Define the abscissa serie */
20 | $myPicture->myData->addPoints(["A","B","C"],"Labels");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Set the default font properties */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>10,"Color"=>new pColor(80)]);
25 |
26 | /* Create the pPie object */
27 | $PieChart = new pPie($myPicture);
28 |
29 | /* Enable shadow computing */
30 | $myPicture->setShadow(TRUE,["X"=>3,"Y"=>3,"Color"=>ColorBlack($Alpha=10)]);
31 |
32 | /* Draw a split pie chart */
33 | $PieChart->draw3DPie(120,90,["Radius"=>100,"DataGapAngle"=>12,"DataGapRadius"=>10,"Border"=>TRUE]);
34 |
35 | /* Write the legend box */
36 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6,"Color"=>ColorBlack()]);
37 | $PieChart->drawPieLegend(140,160,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
38 |
39 | /* Render the picture (choose the best way) */
40 | $myPicture->autoOutput("temp/example.draw3DPie.transparent.png");
41 |
42 |
--------------------------------------------------------------------------------
/examples/example.draw3DRing.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([50,2,3,4,7,10,25,48,41,10],"ScoreA");
17 | $myPicture->myData->setSerieDescription("ScoreA","Application A");
18 |
19 | /* Define the abscissa serie */
20 | $myPicture->myData->addPoints(["A0","B1","C2","D3","E4","F5","G6","H7","I8","J9"],"Labels");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Draw a solid background */
24 | $myPicture->drawFilledRectangle(0,0,400,400,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
25 |
26 | /* Overlay with a gradient */
27 | $myPicture->drawGradientArea(0,0,400,400,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
28 | $myPicture->drawGradientArea(0,0,400,20,DIRECTION_VERTICAL, ["StartColor"=>ColorBlack(), "EndColor"=>new pColor(50)]);
29 |
30 | /* Add a border to the picture */
31 | $myPicture->drawRectangle(0,0,399,399,["Color"=>ColorBlack()]);
32 |
33 | /* Write the picture title */
34 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
35 | $myPicture->drawText(10,15,"pPie - Draw 3D ring charts",["Color"=>ColorWhite()]);
36 |
37 | /* Set the default font properties */
38 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>8,"Color"=>new pColor(80)]);
39 |
40 | /* Enable shadow computing */
41 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>ColorBlack($Alpha=50)]);
42 |
43 | /* Create the pPie object */
44 | $PieChart = new pPie($myPicture);
45 |
46 | /* Draw an AA pie chart */
47 | $PieChart->draw3DRing(200,200,["DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE]);
48 |
49 | /* Write the legend box */
50 | $PieChart->drawPieLegend(45,360,["Mode"=>LEGEND_HORIZONTAL,"Style"=>LEGEND_NOBORDER,"Color"=>new pColor(200,200,200,20)]);
51 |
52 | /* Render the picture (choose the best way) */
53 | $myPicture->autoOutput("temp/example.draw3DRing.png");
54 |
55 |
--------------------------------------------------------------------------------
/examples/example.draw3DRingValues.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([50,2,3,4,7,10,25,48,41,10],"ScoreA");
17 | $myPicture->myData->setSerieDescription("ScoreA","Application A");
18 |
19 | /* Define the abscissa serie */
20 | $myPicture->myData->addPoints(["A0","B1","C2","D3","E4","F5","G6","H7","I8","J9"],"Labels");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Draw a solid background */
24 | $myPicture->drawFilledRectangle(0,0,400,400,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
25 |
26 | /* Overlay with a gradient */
27 | $myPicture->drawGradientArea(0,0,400,400,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
28 | $myPicture->drawGradientArea(0,0,400,20,DIRECTION_VERTICAL,["StartColor"=>ColorBlack(), "EndColor"=>new pColor(50)]);
29 |
30 | /* Add a border to the picture */
31 | $myPicture->drawRectangle(0,0,399,399,["Color"=>ColorBlack()]);
32 |
33 | /* Write the picture title */
34 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
35 | $myPicture->drawText(10,15,"pPie - Draw 3D ring charts",["Color"=>ColorWhite()]);
36 |
37 | /* Set the default font properties */
38 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>9,"Color"=>new pColor(80)]);
39 |
40 | /* Enable shadow computing */
41 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>ColorBlack($Alpha=50)]);
42 |
43 | /* Create the pPie object */
44 | $PieChart = new pPie($myPicture);
45 |
46 | /* Draw an AA pie chart */
47 | $PieChart->draw3DRing(200,200,["WriteValues"=>TRUE,"Border"=>TRUE]);
48 |
49 | /* Write the legend box */
50 | $PieChart->drawPieLegend(45,360,["Mode"=>LEGEND_HORIZONTAL,"Style"=>LEGEND_NOBORDER,"Color"=>new pColor(200,200,200,20)]);
51 |
52 | /* Render the picture (choose the best way) */
53 | $myPicture->autoOutput("temp/example.draw3DRingValues.png");
54 |
55 |
--------------------------------------------------------------------------------
/examples/example.drawAntialiasPixel.php:
--------------------------------------------------------------------------------
1 | drawGradientArea(0,0,700,230, DIRECTION_VERTICAL, ["StartColor"=>new pColor(180,193,91,100),"EndColor"=>new pColor(120,137,72,100)]);
13 | $myPicture->drawGradientArea(0,0,700,230, DIRECTION_HORIZONTAL, ["StartColor"=>new pColor(180,193,91,20),"EndColor"=>new pColor(120,137,72,20)]);
14 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0),"EndColor"=>new pColor(50)]);
15 |
16 | /* Add a border to the picture */
17 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
18 |
19 | /* Write the picture title */
20 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
21 | $myPicture->drawText(10,15,"drawAntialiasPixel() - Drawing anti-aliased pixel with transparency",["Color"=>new pColor(255)]);
22 |
23 | /* Draw some alpha pixels */
24 | $PixelColor = new pColor(128,255,255);
25 | for($X=0;$X<=160;$X++)
26 | {
27 | for($Y=0;$Y<=160;$Y++)
28 | {
29 | $PixelColor->__construct(128, 255 - $Y, $X, cos(deg2rad($X*2))*50+50);
30 | $myPicture->drawAntialiasPixel($X*2+20.4,$Y+45,$PixelColor);
31 | $myPicture->drawAntialiasPixel($X+400,$Y+45,$PixelColor);
32 | }
33 | }
34 | /* Render the picture (choose the best way) */
35 | $myPicture->autoOutput("temp/example.drawantialiaspixel.png");
36 |
37 |
--------------------------------------------------------------------------------
/examples/example.drawAreaChart.simple.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([4,2,10,12,8,3],"Probe 1");
16 | $myPicture->myData->addPoints([3,12,15,8,5,5],"Probe 2");
17 | $myPicture->myData->addPoints([2,7,5,18,15,22],"Probe 3");
18 | $myPicture->myData->setSerieProperties("Probe 2",["Ticks" => 4]);
19 | $myPicture->myData->setAxisName(0,"Temperatures");
20 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun"],"Labels");
21 | $myPicture->myData->setSerieDescription("Labels","Months");
22 | $myPicture->myData->setAbscissa("Labels");
23 |
24 | /* Turn off Anti-aliasing */
25 | $myPicture->setAntialias(FALSE);
26 |
27 | /* Add a border to the picture */
28 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
29 |
30 | /* Write the chart title */
31 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>11]);
32 | $myPicture->drawText(150,35,"Average temperature",["FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE]);
33 |
34 | /* Set the default font */
35 | $myPicture->setFontProperties(["FontSize"=>7]);
36 |
37 | /* Define the chart area */
38 | $myPicture->setGraphArea(60,40,650,200);
39 |
40 | /* Draw the scale */
41 | $scaleSettings = ["XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE];
42 | $myPicture->drawScale($scaleSettings);
43 |
44 | /* Write the chart legend */
45 | $myPicture->drawLegend(540,20,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
46 |
47 | /* Turn on Anti-aliasing */
48 | $myPicture->setAntialias(TRUE);
49 |
50 | /* Draw the area chart */
51 | (new pCharts($myPicture))->drawAreaChart();
52 |
53 | /* Render the picture (choose the best way) */
54 | $myPicture->autoOutput("temp/example.drawAreaChart.simple.png");
55 |
56 |
--------------------------------------------------------------------------------
/examples/example.drawArrow.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL,["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawArrow() - Arrows on your charts",["Color"=>new pColor(255)]);
26 |
27 | /* Turn on shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>new pColor(0,0,0,20)]);
29 |
30 | /* Draw some arrows */
31 | for($i=1;$i<=100;$i=$i+8)
32 | {
33 | $myPicture->drawArrow($i+5,215,$i*7+5,30,["FillColor"=>new pColor(intval($i*2.5),intval($i*2.5),intval($i*2.5)),"Ticks"=>$i % 5]);
34 | }
35 |
36 | /* Render the picture (choose the best way) */
37 | $myPicture->autoOutput("temp/example.drawArrow.png");
38 |
39 |
--------------------------------------------------------------------------------
/examples/example.drawArrowLabel.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL,["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawArrowLabel() - Adaptive label positioning",["Color"=>new pColor(255)]);
26 |
27 | /* Turn on shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,new pColor(0,0,0,10)]);
29 |
30 | /* Draw an arrow with a 45 degree angle */
31 | $myPicture->drawArrowLabel(348,113,"Blue",["FillColor"=>new pColor(37,78,117),"Length"=>40,"Angle"=>45]);
32 |
33 | /* Draw an arrow with a 135 degree angle */
34 | $myPicture->drawArrowLabel(348,117,"Red",["FillColor"=>new pColor(188,49,42),"Length"=>40,"Angle"=>135,"Position"=>POSITION_BOTTOM,"Ticks"=>2]);
35 |
36 | /* Draw an arrow with a 225 degree angle */
37 | $myPicture->drawArrowLabel(352,117,"Green",["FillColor"=>new pColor(51,119,35),"Length"=>40,"Angle"=>225,"Position"=>POSITION_BOTTOM,"Ticks"=>3]);
38 |
39 | /* Draw an arrow with a 315 degree angle */
40 | $myPicture->drawArrowLabel(352,113,"Yellow",["FillColor"=>new pColor(239,231,97),"Length"=>40,"Angle"=>315,"Ticks"=>4]);
41 |
42 | /* Render the picture (choose the best way) */
43 | $myPicture->autoOutput("temp/example.drawArrowLabel.png");
44 |
45 |
--------------------------------------------------------------------------------
/examples/example.drawBarChart.borders.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([150,220,300,-250,-420,-200,300,200,100],"Server A");
16 | $myPicture->myData->addPoints([140,0,340,-300,-320,-300,200,100,50],"Server B");
17 | $myPicture->myData->setAxisName(0,"Hits");
18 | $myPicture->myData->addPoints(["January","February","March","April","May","June","July","August","September"],"Months");
19 | $myPicture->myData->setSerieDescription("Months","Month");
20 | $myPicture->myData->setAbscissa("Months");
21 |
22 | /* Turn off Anti-aliasing */
23 | $myPicture->setAntialias(FALSE);
24 |
25 | /* Add a border to the picture */
26 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(240),"EndColor"=>new pColor(180)]);
27 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240,240,240,20), "EndColor"=>new pColor(180,180,180,20)]);
28 |
29 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
30 |
31 | /* Set the default font */
32 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
33 |
34 | /* Define the chart area */
35 | $myPicture->setGraphArea(60,40,650,200);
36 |
37 | /* Draw the scale */
38 | $myPicture->drawScale(["GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
39 |
40 | /* Write the chart legend */
41 | $myPicture->drawLegend(580,12,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
42 |
43 | /* Turn shadow on */
44 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
45 |
46 | /* Draw the chart */
47 | (new pCharts($myPicture))->drawBarChart(["Surrounding"=>-30,"InnerSurrounding"=>30]);
48 |
49 | /* Render the picture (choose the best way) */
50 | $myPicture->autoOutput("temp/example.drawBarChart.simple.png");
51 |
52 |
--------------------------------------------------------------------------------
/examples/example.drawBarChart.can.php:
--------------------------------------------------------------------------------
1 | myData->loadPalette($palette_light, $overwrite=TRUE);
25 | $myPicture->myData->addPoints([150,220,300,-250,-420,-200,300,200,100],"Server A");
26 | $myPicture->myData->addPoints([140,0,340,-300,-320,-300,200,100,50],"Server B");
27 | $myPicture->myData->setAxisName(0,"Hits");
28 | $myPicture->myData->addPoints(["January","February","March","April","May","June","July","August","September"],"Months");
29 | $myPicture->myData->setSerieDescription("Months","Month");
30 | $myPicture->myData->setAbscissa("Months");
31 |
32 | /* Draw the background */
33 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(240),"EndColor"=>new pColor(180)]);
34 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240,240,240,20),"EndColor"=>new pColor(180,180,180,20)]);
35 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
36 |
37 | /* Draw the scale */
38 | $myPicture->setGraphArea(50,30,680,200);
39 | $myPicture->drawScale(["CycleBackground"=>TRUE,"DrawSubTicks"=>TRUE,"GridColor"=>new pColor(0,0,0,10)]);
40 |
41 | /* Turn on shadow computing */
42 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
43 |
44 | /* Draw the chart */
45 | (new pCharts($myPicture))->drawBarChart([
46 | "Gradient"=>TRUE,
47 | "GradientMode"=>GRADIENT_EFFECT_CAN,
48 | "DisplayPos"=>LABEL_POS_INSIDE,
49 | "DisplayValues"=>TRUE,
50 | "DisplayColor"=>new pColor(255),
51 | "DisplayShadow"=>TRUE,
52 | "Surrounding"=>10
53 | ]);
54 |
55 | /* Write the chart legend */
56 | $myPicture->drawLegend(580,12,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
57 |
58 | /* Render the picture (choose the best way) */
59 | $myPicture->autoOutput("temp/example.drawBarChart.can.png");
60 |
61 |
--------------------------------------------------------------------------------
/examples/example.drawBarChart.palette.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([13251,4118,3087,1460,1248,156,26,9,8],"Hits");
16 | $myPicture->myData->setAxisName(0,"Hits");
17 | $myPicture->myData->addPoints(["Firefox","Chrome","Internet Explorer","Opera","Safari","Mozilla","SeaMonkey","Camino","Lunascape"],"Browsers");
18 | $myPicture->myData->setSerieDescription("Browsers","Browsers");
19 | $myPicture->myData->setAbscissa("Browsers", ["Name" => "Browsers"]);
20 |
21 | /* Draw the background */
22 | $myPicture->drawGradientArea(0,0,500,500,DIRECTION_VERTICAL,["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
23 | $myPicture->drawGradientArea(0,0,500,500,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240,240,240,20), "EndColor"=>new pColor(180,180,180,20)]);
24 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
25 |
26 | /* Draw the chart scale */
27 | $myPicture->setGraphArea(100,30,480,480);
28 | $myPicture->drawScale(["CycleBackground"=>TRUE,"DrawSubTicks"=>TRUE,"GridColor"=>new pColor(0,0,0,10),"Pos"=>SCALE_POS_TOPBOTTOM]);
29 |
30 | /* Turn on shadow computing */
31 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
32 |
33 | /* Create the per bar palette */
34 | $Palette = [
35 | new pColor(188,224,46),
36 | new pColor(224,100,46),
37 | new pColor(224,214,46),
38 | new pColor(46,151,224),
39 | new pColor(176,46,224),
40 | new pColor(224,46,117),
41 | new pColor(92,224,46),
42 | new pColor(224,176,46)
43 | ];
44 |
45 | /* Draw the chart */
46 | (new pCharts($myPicture))->drawBarChart(["DisplayPos"=>LABEL_POS_INSIDE,"DisplayValues"=>TRUE,"Rounded"=>TRUE,"Surrounding"=>30,"OverrideColors"=>$Palette]);
47 |
48 | /* Write the legend */
49 | $myPicture->drawLegend(500,215,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
50 |
51 | /* Render the picture (choose the best way) */
52 | $myPicture->autoOutput("temp/example.drawBarChart.palette.png");
53 |
54 |
--------------------------------------------------------------------------------
/examples/example.drawBarChart.poll.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([60,30,10],"Answers");
16 | $myPicture->myData->setAxisName(0,"Answers (%)");
17 | $myPicture->myData->addPoints(["I do agree ","I disagree ","No opinion "],"Options");
18 | $myPicture->myData->setAbscissa("Options");
19 |
20 | /* Write the chart title */
21 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>15]);
22 | $myPicture->drawText(20,34,"Q: Flexibility is a key point of this library",["FontSize"=>20]);
23 |
24 | /* Define the default font */
25 | $myPicture->setFontProperties(["FontSize"=>7]);
26 |
27 | /* Set the graph area */
28 | $myPicture->setGraphArea(70,60,480,200);
29 | $myPicture->drawGradientArea(70,60,480,200,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(200,200,200,30),"EndColor"=>new pColor(255,255,255,30)]);
30 |
31 | /* Draw the chart scale */
32 | $scaleSettings = ["AxisAlpha"=>10,"TickAlpha"=>10,"DrawXLines"=>FALSE,"Mode"=>SCALE_MODE_START0,"GridColor"=>new pColor(0,0,0,10),"Pos"=>SCALE_POS_TOPBOTTOM];
33 | $myPicture->drawScale($scaleSettings);
34 |
35 | /* Turn on shadow computing */
36 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
37 |
38 | /* Draw the chart */
39 | (new pCharts($myPicture))->drawBarChart(["DisplayValues"=>TRUE,"DisplayShadow"=>TRUE,"DisplayPos"=>LABEL_POS_INSIDE,"Rounded"=>TRUE,"Surrounding"=>30]);
40 |
41 | /* Render the picture (choose the best way) */
42 | $myPicture->autoOutput("temp/example.drawBarChart.poll.png");
43 |
44 |
--------------------------------------------------------------------------------
/examples/example.drawBarChart.shaded.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([150,220,300,-250,-420,-200,300,200,100],"Server A");
16 | $myPicture->myData->addPoints([140,0,340,-300,-320,-300,200,100,50],"Server B");
17 | $myPicture->myData->setAxisName(0,"Hits");
18 | $myPicture->myData->addPoints(["January","February","March","April","May","June","July","August","September"],"Months");
19 | $myPicture->myData->setSerieDescription("Months","Month");
20 | $myPicture->myData->setAbscissa("Months");
21 |
22 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
23 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240,240,240,20), "EndColor"=>new pColor(180,180,180,20)]);
24 | $myPicture->setFontProperties(array("FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7));
25 |
26 | /* Draw the scale */
27 | $myPicture->setGraphArea(50,30,680,200);
28 | $myPicture->drawScale(["CycleBackground"=>TRUE,"DrawSubTicks"=>TRUE,"GridColor"=>new pColor(0,0,0,10)]);
29 |
30 | /* Turn on shadow computing */
31 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
32 |
33 | /* Draw the chart */
34 | (new pCharts($myPicture))->drawBarChart([
35 | "Gradient"=>TRUE,
36 | "DisplayPos"=>LABEL_POS_INSIDE,
37 | "DisplayValues"=>TRUE,
38 | "DisplayColor"=>new pColor(255),
39 | "DisplayShadow"=>TRUE,
40 | "Surrounding"=>10
41 | ]);
42 |
43 | /* Write the chart legend */
44 | $myPicture->drawLegend(580,12,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
45 |
46 | /* Render the picture (choose the best way) */
47 | $myPicture->autoOutput("temp/example.drawBarChart.shaded.png");
48 |
49 |
--------------------------------------------------------------------------------
/examples/example.drawBarChart.simple.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([150,220,300,-250,-420,-200,300,200,100],"Server A");
16 | $myPicture->myData->addPoints([140,0,340,-300,-320,-300,200,100,50],"Server B");
17 | $myPicture->myData->setAxisName(0,"Hits");
18 | $myPicture->myData->addPoints(["January","February","March","April","May","June","July","August","September"],"Months");
19 | $myPicture->myData->setSerieDescription("Months","Month");
20 | $myPicture->myData->setAbscissa("Months");
21 |
22 | /* Turn off Anti-aliasing */
23 | $myPicture->setAntialias(FALSE);
24 |
25 | /* Add a border to the picture */
26 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
27 |
28 | /* Set the default font */
29 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
30 |
31 | /* Define the chart area */
32 | $myPicture->setGraphArea(60,40,650,200);
33 |
34 | /* Draw the scale */
35 | $myPicture->drawScale(["GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
36 |
37 | /* Write the chart legend */
38 | $myPicture->drawLegend(580,12,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
39 |
40 | /* Turn on shadow computing */
41 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
42 |
43 | /* Draw the chart */
44 | (new pCharts($myPicture))->drawBarChart([
45 | "Gradient"=>TRUE,
46 | "GradientMode"=>GRADIENT_EFFECT_CAN,
47 | "DisplayPos"=>LABEL_POS_INSIDE,
48 | "DisplayValues"=>TRUE,
49 | "DisplayColor"=>new pColor(255),
50 | "DisplayShadow"=>TRUE,
51 | "Surrounding"=>10
52 | ]);
53 |
54 | /* Render the picture (choose the best way) */
55 | $myPicture->autoOutput("temp/example.drawBarChart.simple.png");
56 |
57 |
--------------------------------------------------------------------------------
/examples/example.drawBarChart.spacing.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([150,220,300,250,420,200,300,200,100],"Server A");
16 | $myPicture->myData->addPoints([140,0,340,300,320,300,200,100,50],"Server B");
17 | $myPicture->myData->setAxisName(0,"Hits");
18 | $myPicture->myData->addPoints(["January","February","March","April","May","June","July","August","September"],"Months");
19 | $myPicture->myData->setSerieDescription("Months","Month");
20 | $myPicture->myData->setAbscissa("Months");
21 |
22 | /* Turn off Anti-aliasing */
23 | $myPicture->setAntialias(FALSE);
24 |
25 | /* Add a border to the picture */
26 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
27 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240,240,240,20), "EndColor"=>new pColor(180,180,180,20)]);
28 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
29 |
30 | /* Set the default font */
31 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
32 |
33 | /* Define the chart area */
34 | $myPicture->setGraphArea(60,40,650,200);
35 |
36 | /* Draw the scale */
37 | $scaleSettings = ["GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE];
38 | $myPicture->drawScale($scaleSettings);
39 |
40 | /* Write the chart legend */
41 | $myPicture->drawLegend(580,12,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
42 |
43 | /* Turn on shadow computing */
44 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
45 |
46 | /* Draw the chart */
47 | (new pCharts($myPicture))->drawBarChart(["Surrounding"=>-30,"InnerSurrounding"=>30,"Interleave"=>0]);
48 |
49 | /* Render the picture (choose the best way) */
50 | $myPicture->autoOutput("temp/example.drawBarChart.spacing.png");
51 |
52 |
--------------------------------------------------------------------------------
/examples/example.drawBarChart.span.php:
--------------------------------------------------------------------------------
1 | myData->loadPalette($palette_blind, $overwrite=TRUE);
25 | $myPicture->myData->addPoints([150,220,300,250,420,200,300,200,110],"Server A");
26 | $myPicture->myData->addPoints(["January","February","March","April","May","June","July","August","September"],"Months");
27 | $myPicture->myData->setSerieDescription("Months","Month");
28 | $myPicture->myData->setAbscissa("Months");
29 |
30 | /* Create the floating 0 data serie */
31 | $myPicture->myData->addPoints([60,80,20,40,40,50,90,30,100],"Floating 0");
32 | $myPicture->myData->setSerieProperties("Floating 0",["isDrawable" => FALSE]);
33 |
34 | /* Set the default font */
35 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>10,"Color"=>new pColor(110)]);
36 |
37 | /* Write the title */
38 | $myPicture->drawText(10,15,"Net Income 2k8");
39 |
40 | /* Set the graphical area */
41 | $myPicture->setGraphArea(50,30,680,180);
42 |
43 | /* Draw the scale */
44 | $AxisBoundaries = [0=>array("Min"=>0,"Max"=>500)];
45 | $myPicture->drawScale([
46 | "InnerTickWidth"=>0,
47 | "OuterTickWidth"=>0,
48 | "Mode"=>SCALE_MODE_MANUAL,
49 | "ManualScale"=>$AxisBoundaries,
50 | "LabelRotation"=>45,
51 | "DrawXLines"=>FALSE,
52 | "GridColor"=>new pColor(0,0,0,30),
53 | "GridTicks"=>0,
54 | "AxisColor"=>new pColor(0,0,0,50),
55 | "RemoveYAxis" => TRUE
56 | ]);
57 |
58 | /* Turn on shadow computing */
59 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
60 |
61 | /* Draw the chart */
62 | (new pCharts($myPicture))->drawBarChart(["Floating0Serie"=>"Floating 0","Surrounding"=>10]);
63 |
64 | /* Render the picture (choose the best way) */
65 | $myPicture->autoOutput("temp/example.drawBarChart.span.png");
66 |
67 |
--------------------------------------------------------------------------------
/examples/example.drawBarChart.vertical.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([13251,4118,3087,1460,1248,156,26,9,8],"Hits");
16 | $myPicture->myData->setAxisProperties(0, ["Name" => "Hits", "Display" => AXIS_FORMAT_METRIC, "Format" => 1]);
17 | $myPicture->myData->addPoints(["Firefox","Chrome","Internet Explorer","Opera","Safari","Mozilla","SeaMonkey","Camino","Lunascape"],"Browsers");
18 | $myPicture->myData->setSerieDescription("Browsers","Browsers");
19 | $myPicture->myData->setAbscissa("Browsers", ["Name" => "Browsers"]);
20 |
21 | $myPicture->drawGradientArea(0,0,500,500,DIRECTION_VERTICAL, myColors::myGridColor());
22 | $myPicture->drawGradientArea(0,0,500,500,DIRECTION_HORIZONTAL,myColors::myGridColor($Alpha=20));
23 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
24 |
25 | /* Draw the chart scale */
26 | $myPicture->setGraphArea(100,30,480,480);
27 | $myPicture->drawScale(["CycleBackground"=>TRUE,"DrawSubTicks"=>TRUE,"GridColor"=>myColors::Black(10),"Pos"=>SCALE_POS_TOPBOTTOM]);
28 |
29 | /* Turn on shadow computing */
30 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>myColors::Black(10)]);
31 |
32 | /* Draw the chart */
33 | (new pCharts($myPicture))->drawBarChart(["DisplayPos"=>LABEL_POS_INSIDE,"DisplayValues"=>TRUE,"Rounded"=>TRUE,"Surrounding"=>30]);
34 |
35 | /* Write the legend */
36 | $myPicture->drawLegend(500,215,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
37 |
38 | /* Render the picture (choose the best way) */
39 | $myPicture->autoOutput("temp/example.drawBarChart.vertical.png");
40 |
41 |
--------------------------------------------------------------------------------
/examples/example.drawBestfit.php:
--------------------------------------------------------------------------------
1 | myData->addPoints($Points_1,"Probe 1");
23 | $myPicture->myData->addPoints($Points_2,"Probe 2");
24 |
25 | /* Give a name to the Y axis */
26 | $myPicture->myData->setAxisName(0,"Temperatures");
27 |
28 | /* Turn off Anti-aliasing */
29 | $myPicture->setAntialias(FALSE);
30 |
31 | /* Add a border to the picture */
32 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
33 |
34 | /* Write the chart title */
35 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>11]);
36 | $myPicture->drawText(150,35,"Average temperature",["FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE]);
37 |
38 | /* Set the default font */
39 | $myPicture->setFontProperties(["FontSize"=>7]);
40 |
41 | /* Define the chart area */
42 | $myPicture->setGraphArea(60,40,650,200);
43 |
44 | /* Draw the scale */
45 | $myPicture->drawScale(["XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
46 |
47 | /* Turn on Anti-aliasing */
48 | $myPicture->setAntialias(TRUE);
49 |
50 | $myCharts = new pCharts($myPicture);
51 |
52 | /* Draw the line of best fit */
53 | $myCharts->drawBestFit();
54 |
55 | /* Turn on shadows */
56 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
57 |
58 | /* Draw the line chart */
59 | $myCharts->drawPlotChart();
60 |
61 | /* Write the chart legend */
62 | $myPicture->drawLegend(580,20,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
63 |
64 | /* Render the picture (choose the best way) */
65 | $myPicture->autoOutput("temp/example.drawBestFit.png");
66 |
67 |
--------------------------------------------------------------------------------
/examples/example.drawBezier.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL,["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawBezier() - some cubic curves",["Color"=>new pColor(255)]);
26 |
27 | /* Turn on shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
29 |
30 | /* Draw one bezier curve */
31 | $myPicture->drawBezier(20,40,280,170,130,160,160,60,["Color"=>new pColor(255),"ShowControl"=>TRUE]);
32 |
33 | /* Draw one bezier curve */
34 | $myPicture->drawBezier(360,120,630,120,430,50,560,190,["Color"=>new pColor(255),"ShowControl"=>TRUE,"Ticks"=>4,"DrawArrow"=>TRUE,"ArrowTwoHeads"=>TRUE]);
35 |
36 | /* Render the picture (choose the best way) */
37 | $myPicture->autoOutput("temp/example.drawBezier.png");
38 |
39 |
--------------------------------------------------------------------------------
/examples/example.drawBubbleChart.simple.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([34,55,15,62,38,42],"Probe1");
18 | $myPicture->myData->addPoints([5,30,20,9,15,10],"Probe1Weight");
19 | $myPicture->myData->addPoints([5,10,-5,-1,0,-10],"Probe2");
20 | $myPicture->myData->addPoints([6,10,14,10,14,6],"Probe2Weight");
21 | $myPicture->myData->setSerieDescription("Probe1","This year");
22 | $myPicture->myData->setSerieDescription("Probe2","Last year");
23 | $myPicture->myData->setAxisName(0,"Current stock");
24 | $myPicture->myData->addPoints(["Apple","Banana","Orange","Lemon","Peach","Strawberry"],"Product");
25 | $myPicture->myData->setAbscissa("Product", ["Name" => "Selected Products"]);
26 |
27 | /* Turn off Anti-aliasing */
28 | $myPicture->setAntialias(FALSE);
29 |
30 | /* Draw the border */
31 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
32 |
33 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
34 |
35 | /* Define the chart area */
36 | $myPicture->setGraphArea(60,30,650,190);
37 |
38 | /* Draw the scale */
39 | $myPicture->drawScale(["GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
40 |
41 | /* Create the Bubble chart object and scale up */
42 | $myPicture->setAntialias(TRUE);
43 | $myBubbleChart = new pBubble($myPicture);
44 |
45 | /* Scale up for the bubble chart */
46 | $bubbleDataSeries = ["Probe1","Probe2"];
47 | $bubbleWeightSeries = ["Probe1Weight","Probe2Weight"];
48 | $myBubbleChart->bubbleScale($bubbleDataSeries,$bubbleWeightSeries);
49 |
50 | /* Draw the bubble chart */
51 | $myBubbleChart->drawBubbleChart($bubbleDataSeries,$bubbleWeightSeries,["BorderWidth"=>4,"BorderColor"=>new pColor(0,0,0,50),"Surrounding"=>20]);
52 |
53 | /* Write the chart legend */
54 | $myPicture->drawLegend(570,13,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
55 |
56 | /* Render the picture (choose the best way) */
57 | $myPicture->autoOutput("temp/example.drawBubbleChart.simple.png");
58 |
59 |
--------------------------------------------------------------------------------
/examples/example.drawCircle.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL,["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawCircle() - Transparency & colors",["Color"=>new pColor(255)]);
26 |
27 | /* Draw some circles */
28 | $myPicture->drawCircle(100,125,50,50,["Color"=>new pColor(213,226,0,100)]);
29 | $myPicture->drawCircle(140,125,50,50,["Color"=>new pColor(213,226,0,70)]);
30 | $myPicture->drawCircle(180,125,50,50,["Color"=>new pColor(213,226,0,40)]);
31 | $myPicture->drawCircle(220,125,50,50,["Color"=>new pColor(213,226,0,20)]);
32 |
33 | /* Turn on shadow computing */
34 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
35 |
36 | /* Draw a customized circles */
37 | $myPicture->drawCircle(480,60,20,20, ["Color"=>new pColor(209,31,27)]);
38 | $myPicture->drawCircle(480,100,30,20,["Color"=>new pColor(209,125,27)]);
39 | $myPicture->drawCircle(480,140,40,20,["Color"=>new pColor(209,198,27),"Ticks"=>4]);
40 | $myPicture->drawCircle(480,180,50,20,["Color"=>new pColor(134,209,27),"Ticks"=>4]);
41 |
42 | /* Render the picture (choose the best way) */
43 | $myPicture->autoOutput("temp/example.drawCircle.png");
44 |
45 |
--------------------------------------------------------------------------------
/examples/example.drawContour.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,400,400,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
16 |
17 | /* Do a gradient overlay */
18 | $myPicture->drawGradientArea(0,0,400,400,DIRECTION_VERTICAL,["StartColor"=>new pColor(194,231,44,50), "EndColor"=>new pColor(43,107,58,50)]);
19 | $myPicture->drawGradientArea(0,0,400,20, DIRECTION_VERTICAL,["StartColor"=>new pColor(0), "EndColor"=>new pColor(50)]);
20 |
21 | /* Add a border to the picture */
22 | $myPicture->drawRectangle(0,0,399,399,["Color"=>new pColor(0)]);
23 |
24 | /* Write the picture title */
25 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
26 | $myPicture->drawText(10,15,"pSurface() :: 2D surface charts",["Color"=>new pColor(255)]);
27 |
28 | /* Define the charting area */
29 | $myPicture->setGraphArea(20,40,380,380);
30 | $myPicture->drawFilledRectangle(20,40,380,380,["Color"=>new pColor(255,255,255,20),"Surrounding"=>-200]);
31 |
32 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1]);
33 |
34 | /* Create the surface object */
35 | $mySurface = new pSurface($myPicture);
36 |
37 | /* Set the grid size */
38 | $mySurface->setGrid(20,20);
39 |
40 | /* Write the axis labels */
41 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
42 | $mySurface->writeXLabels(["Position"=>LABEL_POSITION_BOTTOM]);
43 | $mySurface->writeYLabels();
44 |
45 | /* Add random values */
46 | for($i=0; $i<=50; $i++)
47 | {
48 | $mySurface->addPoint(rand(0,20),rand(0,20),rand(0,100));
49 | }
50 |
51 | /* Compute the missing points */
52 | $mySurface->computeMissing();
53 |
54 | /* Draw the surface chart */
55 | $mySurface->drawSurface(["Border"=>TRUE,"Surrounding"=>40]);
56 |
57 | /* Draw the contour with a threshold of 50 */
58 | $mySurface->drawContour(50,["Color"=>new pColor(0)]);
59 |
60 | /* Render the picture (choose the best way) */
61 | $myPicture->autoOutput("temp/example.surface.png");
62 |
63 |
--------------------------------------------------------------------------------
/examples/example.drawDerivative.simple.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([3,12,15,8,5,-5,5,-5,-3,4,5,10],"Probe");
16 | $myPicture->myData->setAxisName(0,"Temperatures");
17 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"],"Labels");
18 | $myPicture->myData->setSerieDescription("Labels","Months");
19 | $myPicture->myData->setAbscissa("Labels", ["Name" => "Months"]);
20 |
21 | /* Turn off Anti-aliasing */
22 | $myPicture->setAntialias(FALSE);
23 |
24 | /* Set the default font */
25 | $myPicture->setFontProperties(["Color"=>new pColor(0),"FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
26 |
27 | /* Define the chart area */
28 | $myPicture->setGraphArea(50,40,680,170);
29 |
30 | /* Draw the scale */
31 | $myPicture->drawScale(["XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"DrawSubTicks"=>TRUE,"GridColor"=>new pColor(100,100,100,15)]);
32 |
33 | /* Create the pCharts object */
34 | $pCharts = new pCharts($myPicture);
35 |
36 | /* Draw the chart */
37 | $myPicture->setAntialias(TRUE);
38 | $pCharts->drawSplineChart();
39 | $myPicture->setAntialias(FALSE);
40 |
41 | /* Draw the series derivative graph */
42 | $pCharts->drawDerivative(["Caption"=>FALSE]);
43 |
44 | /* Write the chart legend */
45 | $myPicture->drawLegend(640,20,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
46 |
47 | /* Render the picture (choose the best way) */
48 | $myPicture->autoOutput("temp/example.drawDerivative.simple.png");
49 |
50 |
--------------------------------------------------------------------------------
/examples/example.drawFilledCircle.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawCircle() - Transparency & colors",["Color"=>new pColor(255)]);
26 |
27 | /* Draw some filled circles */
28 | $myPicture->drawFilledCircle(100,125,50,["Color"=>new pColor(213,226,0,100)]);
29 | $myPicture->drawFilledCircle(140,125,50,["Color"=>new pColor(213,226,0,70)]);
30 | $myPicture->drawFilledCircle(180,125,50,["Color"=>new pColor(213,226,0,40)]);
31 | $myPicture->drawFilledCircle(220,125,50,["Color"=>new pColor(213,226,0,20)]);
32 |
33 | /* Turn on shadow computing */
34 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
35 |
36 | /* Draw a customized filled circles */
37 | $myPicture->drawFilledCircle(480,60,19, ["Color"=>new pColor(209,31,27), "Surrounding"=>30]);
38 | $myPicture->drawFilledCircle(480,100,19,["Color"=>new pColor(209,125,27),"Surrounding"=>30]);
39 | $myPicture->drawFilledCircle(480,140,19,["Color"=>new pColor(209,198,27),"Surrounding"=>30,"Ticks"=>4]);
40 | $myPicture->drawFilledCircle(480,180,19,["Color"=>new pColor(134,209,27),"Surrounding"=>30,"Ticks"=>4]);
41 |
42 | /* Render the picture (choose the best way) */
43 | $myPicture->autoOutput("temp/example.drawFilledCircle.png");
44 |
45 |
--------------------------------------------------------------------------------
/examples/example.drawFilledRectangle.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawFilledRectangle() - Transparency & colors",["Color"=>new pColor(255)]);
26 |
27 | /* Turn on shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
29 |
30 | /* Draw a customized filled rectangle */
31 | $myPicture->drawFilledRectangle(20,60,400,170,["Color"=>new pColor(150,200,170),"Dash"=>TRUE,"DashColor"=>new pColor(170,220,190),"BorderColor"=>new pColor(255)]);
32 |
33 | /* Draw a customized filled rectangle */
34 | $myPicture->drawFilledRectangle(30,30,200,200, ["Color"=>new pColor(209,134,27,30)]);
35 | $myPicture->drawFilledRectangle(480,50,650,80, ["Color"=>new pColor(209,31,27), "Surrounding"=>30]);
36 | $myPicture->drawFilledRectangle(480,90,650,120, ["Color"=>new pColor(209,125,27),"Surrounding"=>30]);
37 | $myPicture->drawFilledRectangle(480,130,650,160,["Color"=>new pColor(209,198,27),"Surrounding"=>30,"Ticks"=>2]);
38 | $myPicture->drawFilledRectangle(480,170,650,200,["Color"=>new pColor(134,209,27),"Surrounding"=>30,"Ticks"=>2]);
39 |
40 | /* Render the picture (choose the best way) */
41 | $myPicture->autoOutput("temp/example.drawFilledRectangle.png");
42 |
43 |
--------------------------------------------------------------------------------
/examples/example.drawFromGIF.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawFromGIF() - add pictures to your charts",["Color"=>new pColor(255)]);
26 |
27 | /* Turn off shadow computing */
28 | $myPicture->setShadow(FALSE);
29 |
30 | /* Draw a GIF object */
31 | $myPicture->drawFromGIF(180,50,"examples/resources/computer.gif");
32 |
33 | /* Turn on shadow computing */
34 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>new pColor(0,0,0,20)]);
35 |
36 | /* Draw a GIF object */
37 | $myPicture->drawFromGIF(400,50,"examples/resources/computer.gif");
38 |
39 | /* Write the legend */
40 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
41 | $TextSettings = ["Color"=>new pColor(255),"FontSize"=>10,"FontName"=>"fonts/Abel-Regular.ttf","Align"=>TEXT_ALIGN_BOTTOMMIDDLE];
42 | $myPicture->drawText(240,200,"Without shadow",$TextSettings);
43 | $myPicture->drawText(460,200,"With enhanced shadow",$TextSettings);
44 |
45 | /* Render the picture (choose the best way) */
46 | $myPicture->autoOutput("temp/example.drawFromGIF.png");
47 |
48 |
--------------------------------------------------------------------------------
/examples/example.drawFromJPG.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawFromJPG() - add pictures to your charts",["Color"=>new pColor(255)]);
26 |
27 | /* Turn off shadow computing */
28 | $myPicture->setShadow(FALSE);
29 |
30 | /* Draw a JPG object */
31 | $myPicture->drawFromJPG(100,45,"examples/resources/landscape1.jpg");
32 |
33 | /* Turn on shadow computing */
34 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>new pColor(0,0,0,20)]);
35 |
36 | /* Draw a JPG object */
37 | $myPicture->drawFromJPG(380,45,"examples/resources/landscape2.jpg");
38 |
39 | /* Write the legend */
40 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
41 | $TextSettings = ["Color"=>new pColor(255),"FontSize"=>10,"FontName"=>"fonts/Abel-Regular.ttf","Align"=>TEXT_ALIGN_BOTTOMMIDDLE];
42 | $myPicture->drawText(220,210,"Without shadow",$TextSettings);
43 | $myPicture->drawText(490,210,"With enhanced shadow",$TextSettings);
44 |
45 | /* Render the picture (choose the best way) */
46 | $myPicture->autoOutput("temp/example.drawFromJPG.png");
47 |
48 |
--------------------------------------------------------------------------------
/examples/example.drawFromPNG.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawFromPNG() - add pictures to your charts",["Color"=>new pColor(255)]);
26 |
27 | /* Turn off shadow computing */
28 | $myPicture->setShadow(FALSE);
29 |
30 | /* Draw a PNG object */
31 | $myPicture->drawFromPNG(180,50,"examples/resources/hologram.png");
32 |
33 | /* Turn on shadow computing */
34 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
35 |
36 | /* Draw a PNG object */
37 | $myPicture->drawFromPNG(400,50,"examples/resources/blocnote.png");
38 |
39 | /* Write the legend */
40 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
41 | $TextSettings = ["Color"=>new pColor(255),"FontSize"=>10,"FontName"=>"fonts/Abel-Regular.ttf","Align"=>TEXT_ALIGN_BOTTOMMIDDLE];
42 | $myPicture->drawText(240,190," Without shadow\r\n(only PNG alpha channels)",$TextSettings);
43 | $myPicture->drawText(460,200,"With enhanced shadow",$TextSettings);
44 |
45 | /* Render the picture (choose the best way) */
46 | $myPicture->autoOutput("temp/example.drawFromPNG.png");
47 |
48 |
--------------------------------------------------------------------------------
/examples/example.drawGradientArea.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawGradientArea() - Transparency & colors",["Color"=>new pColor(255)]);
26 |
27 | /* Draw a gradient area */
28 | /* $End color is ignored and Level is applied to $Start color */
29 | $EndColor = new pColor(0,0,0);
30 | $myPicture->drawGradientArea(20,60,400,170, DIRECTION_HORIZONTAL, ["StartColor"=>new pColor(181,209,27),"EndColor"=>$EndColor],$Levels = -50);
31 | $myPicture->drawGradientArea(30,30,200,200, DIRECTION_VERTICAL, ["StartColor"=>new pColor(209,134,27,30),"EndColor"=>$EndColor],$Levels = -50);
32 | $myPicture->drawGradientArea(480,50,650,80, DIRECTION_HORIZONTAL, ["StartColor"=>new pColor(209,31,27), "EndColor"=>$EndColor],$Levels = 50);
33 | $myPicture->drawGradientArea(480,90,650,120,DIRECTION_VERTICAL, ["StartColor"=>new pColor(209,125,27),"EndColor"=>$EndColor],$Levels = 50);
34 | $myPicture->drawGradientArea(480,130,650,160,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(209,198,27),"EndColor"=>$EndColor],$Levels = 50);
35 | $myPicture->drawGradientArea(480,170,650,200,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(134,209,27),"EndColor"=>$EndColor],$Levels = 50);
36 |
37 | /* Render the picture (choose the best way) */
38 | $myPicture->autoOutput("temp/example.drawGradientArea.png");
39 |
40 |
--------------------------------------------------------------------------------
/examples/example.drawIndicator.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.drawIndicator.php
--------------------------------------------------------------------------------
/examples/example.drawLabel.barchart.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.drawLabel.barchart.php
--------------------------------------------------------------------------------
/examples/example.drawLabel.caption.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.drawLabel.caption.php
--------------------------------------------------------------------------------
/examples/example.drawLabel.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.drawLabel.php
--------------------------------------------------------------------------------
/examples/example.drawLabel.scatter.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.drawLabel.scatter.php
--------------------------------------------------------------------------------
/examples/example.drawLabel.stacked.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([4,1,0,12,8,4,0,12,8],"Frontend #1");
16 | $myPicture->myData->addPoints([3,12,15,8,VOID,VOID,12,15,8],"Frontend #2");
17 | $myPicture->myData->addPoints([4,4,4,4,4,4,4,4,4],"Frontend #3");
18 | $myPicture->myData->setAxisName(0,"Average Usage");
19 | $myPicture->myData->addPoints(["January","February","March","April","May","June","July","August","September"],"Labels");
20 | $myPicture->myData->setSerieDescription("Labels","Months");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Draw background */
24 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
25 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240,240,240,20), "EndColor"=>new pColor(180,180,180,20)]);
26 |
27 | /* Set the default font properties */
28 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
29 |
30 | /* Draw the scale and the chart */
31 | $myPicture->setGraphArea(60,20,680,190);
32 | $myPicture->drawScale(["XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL_START0]);
33 |
34 | (new pCharts($myPicture))->drawStackedAreaChart(["DrawPlot"=>TRUE,"DrawLine"=>TRUE,"LineSurrounding"=>-20]);
35 |
36 | /* Turn on shadow processing */
37 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
38 |
39 | /* Write a label */
40 | $myPicture->writeLabel(["Frontend #1","Frontend #2","Frontend #3"],[1],["DrawVerticalLine" => TRUE, "forStackedChart" => TRUE]);
41 |
42 | /* Write the chart legend */
43 | $myPicture->drawLegend(480,210,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
44 |
45 | /* Render the picture (choose the best way) */
46 | $myPicture->autoOutput("temp/example.drawLabel.stacked.png");
47 |
48 |
--------------------------------------------------------------------------------
/examples/example.drawLine.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawLine() - Basis",["Color"=>new pColor(255)]);
26 |
27 | /* Turn on shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
29 |
30 | /* Draw some lines */
31 | for($i=1;$i<=100;$i=$i+4)
32 | {
33 | /* new pColor() == get random color */
34 | $myPicture->drawLine($i+5, 215, $i*7+5, 30, ["Color"=>new pColor(),"Ticks"=>rand(0,4)]);
35 | }
36 |
37 | /* Draw an horizontal dashed line with extra weight */
38 | $myPicture->drawLine(370,160,650,160,["Color"=>new pColor(0),"Ticks"=>4,"Weight"=>3]);
39 |
40 | /* Another example of extra weight */
41 | $myPicture->drawLine(370,180,650,200,["Color"=>new pColor(255),"Ticks"=>15,"Weight"=>1]);
42 |
43 | /* Render the picture (choose the best way) */
44 | $myPicture->autoOutput("temp/example.drawLine.png");
45 |
46 |
--------------------------------------------------------------------------------
/examples/example.drawLineChart.simple.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([-4,VOID,VOID,12,8,3],"Probe 1");
16 | $myPicture->myData->addPoints([3,12,15,8,5,-5],"Probe 2");
17 | $myPicture->myData->addPoints([2,7,5,18,19,22],"Probe 3");
18 | $myPicture->myData->setSerieProperties("Probe 2", ["Ticks" => 4]);
19 | $myPicture->myData->setSerieProperties("Probe 3", ["Weight" => 2]);
20 | $myPicture->myData->setAxisName(0,"Temperatures");
21 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun"],"Labels");
22 | $myPicture->myData->setSerieDescription("Labels","Months");
23 | $myPicture->myData->setAbscissa("Labels");
24 |
25 | /* Turn off Anti-aliasing */
26 | $myPicture->setAntialias(FALSE);
27 |
28 | /* Add a border to the picture */
29 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
30 |
31 | /* Write the chart title */
32 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>11]);
33 | $myPicture->drawText(150,35,"Average temperature",["FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE]);
34 |
35 | /* Set the default font */
36 | $myPicture->setFontProperties(["FontSize"=>7]);
37 |
38 | /* Define the chart area */
39 | $myPicture->setGraphArea(60,40,650,200);
40 |
41 | /* Draw the scale */
42 | $myPicture->drawScale(["XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
43 |
44 | /* Turn on Anti-aliasing */
45 | $myPicture->setAntialias(TRUE);
46 |
47 | /* Draw the line chart */
48 | (new pCharts($myPicture))->drawLineChart();
49 |
50 | /* Write the chart legend */
51 | $myPicture->drawLegend(540,20,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
52 |
53 | /* Render the picture (choose the best way) */
54 | $myPicture->autoOutput("temp/example.drawLineChart.simple.png");
55 |
56 |
--------------------------------------------------------------------------------
/examples/example.drawMedian.php:
--------------------------------------------------------------------------------
1 | myData = new Examples\pDataExt();
14 |
15 | $Points = [];
16 | /* Populate the pData object */
17 | for($i=0;$i<=20;$i++) {
18 | $Points[] = rand(10,30)+$i;
19 | }
20 | $myPicture->myData->addPoints($Points,"Probe 1");
21 | $myPicture->myData->setAxisName(0,"Temperatures");
22 | $myPicture->myData->setAbscissaName("Samples");
23 |
24 | /* Turn off Anti-aliasing */
25 | $myPicture->setAntialias(FALSE);
26 |
27 | /* Add a border to the picture */
28 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
29 |
30 | /* Write the chart title */
31 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>11]);
32 | $myPicture->drawText(150,35,"Average temperature",["FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE]);
33 |
34 | /* Set the default font */
35 | $myPicture->setFontProperties(["FontSize"=>7]);
36 |
37 | /* Define the chart area */
38 | $myPicture->setGraphArea(60,40,650,200);
39 |
40 | /* Draw the scale */
41 | $myPicture->drawScale(["XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
42 |
43 | /* Turn on Anti-aliasing */
44 | $myPicture->setAntialias(TRUE);
45 |
46 | /* Draw the line of best fit */
47 | $Median = $myPicture->myData->getSerieMedian("Probe 1");
48 | $myPicture->drawThreshold([$Median],["WriteCaption"=>TRUE,"Caption"=>"Median value"]);
49 |
50 | /* Turn on shadows */
51 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
52 |
53 | /* Draw the line chart */
54 | (new pCharts($myPicture))->drawPlotChart();
55 |
56 | /* Write the chart legend */
57 | $myPicture->drawLegend(580,20,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
58 |
59 | /* Render the picture (choose the best way) */
60 | $myPicture->autoOutput("temp/example.median.png");
61 |
62 |
--------------------------------------------------------------------------------
/examples/example.drawPlotChart.simple.php:
--------------------------------------------------------------------------------
1 | myData->addPoints($Points_1,"Probe 1");
23 | $myPicture->myData->addPoints($Points_2,"Probe 2");
24 | $myPicture->myData->setSerieProperties("Probe 1", ["Shape" => SERIE_SHAPE_FILLEDTRIANGLE, "Weight" => 2]);
25 | $myPicture->myData->setSerieProperties("Probe 2", ["Shape" => SERIE_SHAPE_FILLEDSQUARE]);
26 | $myPicture->myData->setAxisName(0,"Temperatures");
27 |
28 | /* Turn off Anti-aliasing */
29 | $myPicture->setAntialias(FALSE);
30 |
31 | /* Add a border to the picture */
32 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
33 |
34 | /* Write the chart title */
35 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>11]);
36 | $myPicture->drawText(150,35,"Average temperature",["FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE]);
37 |
38 | /* Set the default font */
39 | $myPicture->setFontProperties(["FontSize"=>7]);
40 |
41 | /* Define the chart area */
42 | $myPicture->setGraphArea(60,40,650,200);
43 |
44 | /* Draw the scale */
45 | $myPicture->drawScale(["XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
46 |
47 | /* Turn on Anti-aliasing */
48 | $myPicture->setAntialias(TRUE);
49 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
50 |
51 | /* Draw the line chart */
52 | (new pCharts($myPicture))->drawPlotChart();
53 |
54 | /* Write the chart legend */
55 | $myPicture->drawLegend(580,20,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
56 |
57 | /* Render the picture (choose the best way) */
58 | $myPicture->autoOutput("temp/example.drawPlotChart.simple.png");
59 |
60 |
--------------------------------------------------------------------------------
/examples/example.drawPolygon.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawPolygon - Draw polygons",["Color"=>new pColor(255)]);
26 |
27 | /* Enable shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>new pColor(0,0,0,10)]);
29 |
30 | /* Create some filling thresholds */
31 | $Threshold = [
32 | array("MinX"=>100,"MaxX"=>60, "Color"=>new pColor(200,200,200,50)),
33 | array("MinX"=>140,"MaxX"=>100,"Color"=>new pColor(220,220,220,50)),
34 | array("MinX"=>180,"MaxX"=>140,"Color"=>new pColor(240,240,240,50))
35 | ];
36 | /* Draw some polygons */
37 | $Step = 8;
38 | $White = ["Threshold"=>$Threshold,"Color"=>new pColor(255),"BorderColor"=>new pColor(0)];
39 |
40 | for($i=1;$i<=4;$i++)
41 | {
42 | $Points = [];
43 | for($j=0;$j<=360;$j=$j+(360/$Step))
44 | {
45 | $Points[] = cos(deg2rad($j))*50+($i*140);
46 | $Points[] = sin(deg2rad($j))*50+120;
47 | }
48 | $myPicture->drawPolygon($Points,$White);
49 | $Step = $Step * 2;
50 | }
51 |
52 | /* Render the picture (choose the best way) */
53 | $myPicture->autoOutput("temp/example.drawPolygon.png");
54 |
55 |
--------------------------------------------------------------------------------
/examples/example.drawRectangle.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawRectangle() - Transparency & colors",["Color"=>new pColor(255)]);
26 |
27 | /* Enable shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
29 |
30 | /* Draw rectangles */
31 | $myPicture->drawRectangle(20,60,400,170, ["Color"=>new pColor(181,209,27,100)]);
32 | $myPicture->drawRectangle(30,30,200,200, ["Color"=>new pColor(209,134,27,30)]);
33 | $myPicture->drawRectangle(480,50,650,80, ["Color"=>new pColor(209,31,27,100)]);
34 | $myPicture->drawRectangle(480,90,650,120, ["Color"=>new pColor(209,125,27,100)]);
35 | $myPicture->drawRectangle(480,130,650,160,["Color"=>new pColor(209,198,27,100),"Ticks"=>2]);
36 | $myPicture->drawRectangle(480,170,650,200,["Color"=>new pColor(134,209,27,100),"Ticks"=>2]);
37 |
38 | /* Render the picture (choose the best way) */
39 | $myPicture->autoOutput("temp/example.drawRectangle.png");
40 |
41 |
--------------------------------------------------------------------------------
/examples/example.drawRoundedRectangle.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawRoundedRectangle() - Transparency & colors",["Color"=>new pColor(255)]);
26 |
27 | /* Enable shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
29 |
30 | /* Draw rounded rectangles */
31 | $myPicture->drawRoundedRectangle(20,60,400,170,10, ["Color"=>new pColor(181,209,27,100)]);
32 | $myPicture->drawRoundedRectangle(30,30,200,200,10, ["Color"=>new pColor(209,134,27,30)]);
33 | $myPicture->drawRoundedRectangle(480,50,650,80,5, ["Color"=>new pColor(209,31,27,100)]);
34 | $myPicture->drawRoundedRectangle(480,90,650,120,5, ["Color"=>new pColor(209,125,27,100)]);
35 | $myPicture->drawRoundedRectangle(480,130,650,160,5,["Color"=>new pColor(209,198,27,100)]);
36 | $myPicture->drawRoundedRectangle(480,170,650,200,5,["Color"=>new pColor(134,209,27,100)]);
37 |
38 | /* Render the picture (choose the best way) */
39 | $myPicture->autoOutput("temp/example.drawRoundedRectangle.png");
40 |
41 |
--------------------------------------------------------------------------------
/examples/example.drawScale.floating.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([8,10,24,25,25,24,23,22,20,12,10],"Temperature");
15 | $myPicture->myData->setAxisName(0,"Temperatures");
16 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"],"Labels");
17 | $myPicture->myData->setSerieDescription("Labels","Months");
18 | $myPicture->myData->setAbscissa("Labels");
19 |
20 | /* Draw the background */
21 | $myPicture->drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
22 |
23 | /* Overlay with a gradient */
24 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
25 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
26 |
27 | /* Add a border to the picture */
28 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
29 |
30 | /* Write the picture title */
31 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
32 | $myPicture->drawText(10,15,"drawScale() - draw the X-Y scales",["Color"=>new pColor(255)]);
33 |
34 | /* Set the default font */
35 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>11]);
36 |
37 | /* Write the chart title */
38 | $myPicture->setGraphArea(60,50,660,200);
39 | $myPicture->drawText(350,55,"My chart title",["FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE]);
40 |
41 | /* Set the default font */
42 | $myPicture->setFontProperties(["FontSize"=>7]);
43 |
44 | /* Draw the scale */
45 | $myPicture->drawScale(["XMargin"=>15,"YMargin"=>15,"Floating"=>TRUE,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
46 |
47 | /* Render the picture (choose the best way) */
48 | $myPicture->autoOutput("temp/example.drawScale.floating.png");
49 |
50 |
--------------------------------------------------------------------------------
/examples/example.drawScale.manual.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([24,-25,26,25,25],"Temperature");
15 | $myPicture->myData->setAxisName(0,"Temperatures");
16 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun"],"Labels");
17 | $myPicture->myData->setSerieDescription("Labels","Months");
18 | $myPicture->myData->setAbscissa("Labels");
19 |
20 | /* Draw the background */
21 | $myPicture->drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
22 |
23 | /* Overlay with a gradient */
24 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
25 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
26 |
27 | /* Add a border to the picture */
28 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
29 |
30 | /* Write the picture title */
31 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
32 | $myPicture->drawText(10,15,"drawScale() - draw the X-Y scales",["Color"=>new pColor(255)]);
33 |
34 | /* Set the default font */
35 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>11]);
36 |
37 | /* Write the chart title */
38 | $myPicture->setGraphArea(60,60,660,190);
39 | $myPicture->drawText(350,55,"My chart title",["FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE]);
40 | $myPicture->drawFilledRectangle(60,60,660,190,["Color"=>new pColor(255,255,255,10),"Surrounding"=>-200]);
41 |
42 | /* Set the default font */
43 | $myPicture->setFontProperties(["FontSize"=>7]);
44 |
45 | /* Draw the scale */
46 | $AxisBoundaries = array(0=>["Min"=>0,"Max"=>100]);
47 | $myPicture->drawScale(["Mode"=>SCALE_MODE_MANUAL,"ManualScale"=>$AxisBoundaries,"DrawSubTicks"=>TRUE,"DrawArrows"=>TRUE,"ArrowSize"=>6]);
48 |
49 | /* Render the picture (choose the best way) */
50 | $myPicture->autoOutput("temp/example.drawScale.png");
51 |
52 |
--------------------------------------------------------------------------------
/examples/example.drawScale.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([24,-25,26,25,25],"Temperature");
15 | $myPicture->myData->setAxisName(0,"Temperatures");
16 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun"],"Labels");
17 | $myPicture->myData->setSerieDescription("Labels","Months");
18 | $myPicture->myData->setAbscissa("Labels", ["Name" => "Months"]);
19 |
20 | /* Draw the background */
21 | $myPicture->drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
22 |
23 | /* Overlay with a gradient */
24 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
25 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
26 |
27 | /* Add a border to the picture */
28 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
29 |
30 | /* Write the picture title */
31 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
32 | $myPicture->drawText(10,15,"drawScale() - draw the X-Y scales",["Color"=>new pColor(255)]);
33 |
34 | /* Set the default font */
35 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>11]);
36 |
37 | /* Write the chart title */
38 | $myPicture->setGraphArea(60,60,660,190);
39 | $myPicture->drawText(350,55,"My chart title",["FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE]);
40 | $myPicture->drawFilledRectangle(60,60,660,190,["Color"=>new pColor(255,255,255,10),"Surrounding"=>-200]);
41 |
42 | /* Set the default font */
43 | $myPicture->setFontProperties(["FontSize"=>7]);
44 |
45 | /* Draw the scale */
46 | $myPicture->drawScale(["DrawSubTicks"=>TRUE,"DrawArrows"=>TRUE,"ArrowSize"=>6]);
47 |
48 | /* Render the picture (choose the best way) */
49 | $myPicture->autoOutput("temp/example.drawScale.png");
50 |
51 |
--------------------------------------------------------------------------------
/examples/example.drawScale.reverse.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([24,13,14],"Temperature");
15 | $myPicture->myData->setAxisName(0,"Temperatures");
16 | $myPicture->myData->addPoints(["Sample #1","Sample #2","Sample #3"],"Labels");
17 | $myPicture->myData->setAbscissa("Labels");
18 |
19 | /* Draw the background */
20 | $myPicture->drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
21 |
22 | /* Overlay with a gradient */
23 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
24 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
25 |
26 | /* Add a border to the picture */
27 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
28 |
29 | /* Write the picture title */
30 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
31 | $myPicture->drawText(10,15,"drawScale() - draw the X-Y scales",["Color"=>new pColor(255)]);
32 |
33 | /* Set the default font */
34 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
35 |
36 | /* Draw the scale */
37 | $myPicture->setGraphArea(60,90,660,210);
38 | $myPicture->drawScale(["AutoAxisLabels"=>FALSE,"Pos"=>SCALE_POS_TOPBOTTOM]);
39 |
40 | /* Write the chart title */
41 | $myPicture->setFontProperties(["FontSize"=>11]);
42 | $myPicture->drawText(360,55,"My chart title",["FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE]);
43 | $myPicture->drawFilledRectangle(60,90,660,210,["Color"=>new pColor(255,255,255,10),"Surrounding"=>-200]);
44 |
45 | /* Render the picture (choose the best way) */
46 | $myPicture->autoOutput("temp/example.drawScale.reverse.png");
47 |
48 |
--------------------------------------------------------------------------------
/examples/example.drawScatterLineChart.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.drawScatterLineChart.php
--------------------------------------------------------------------------------
/examples/example.drawScatterPlotChart.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.drawScatterPlotChart.php
--------------------------------------------------------------------------------
/examples/example.drawScatterScale.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.drawScatterScale.php
--------------------------------------------------------------------------------
/examples/example.drawScatterSplineChart.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.drawScatterSplineChart.php
--------------------------------------------------------------------------------
/examples/example.drawSimple.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([2,7,5,18,19,22,23,25,22,12,10,10],"DEFCA");
16 | $myPicture->myData->setAxisProperties(0, ["Name" => "$ Incomes", "Display" => AXIS_FORMAT_CURRENCY]);
17 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"],"Labels");
18 | $myPicture->myData->setSerieDescription("Labels","Months");
19 | $myPicture->myData->setAbscissa("Labels");
20 | $myPicture->myData->setPalette("DEFCA",new pColor(55,91,127));
21 |
22 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(220), "EndColor"=>new pColor(255)]);
23 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(220)]);
24 |
25 | /* Write the picture title */
26 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>9]);
27 | $myPicture->drawText(60,35,"2k9 Average Incomes",["FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMLEFT]);
28 |
29 | /* Do some cosmetic and draw the chart */
30 | $myPicture->setGraphArea(60,40,670,190);
31 | $myPicture->drawFilledRectangle(60,40,670,190,["Color"=>new pColor(255,255,255,10),"Surrounding"=>-200]);
32 | $myPicture->drawScale(["GridColor"=>new pColor(180,180,180,50)]);
33 | $myPicture->setFontProperties(["FontSize"=>7]);
34 |
35 | /* Create the pCharts object */
36 | $pCharts = new pCharts($myPicture);
37 |
38 | /* Draw a spline chart on top */
39 | $pCharts->drawFilledSplineChart();
40 |
41 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>new pColor(0,0,0,10)]);
42 |
43 | $pCharts->drawSplineChart();
44 |
45 | $myPicture->setShadow(FALSE);
46 |
47 | /* Write the chart legend */
48 | $myPicture->drawLegend(643,210,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
49 |
50 | /* Render the picture (choose the best way) */
51 | $myPicture->autoOutput("temp/example.drawSimple.png");
52 |
53 |
--------------------------------------------------------------------------------
/examples/example.drawSpline.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawSpline() - for smooth line drawing",["Color"=>new pColor(255)]);
26 |
27 | /* Enable shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
29 |
30 | /* Draw a spline */
31 | $SplineSettings = ["Color"=>new pColor(255,255,255),"ShowControl"=>TRUE];
32 | $Coordinates = array([40,80],[280,60],[340,166],[590,120]);
33 | $myPicture->drawSpline($Coordinates,$SplineSettings);
34 |
35 | /* Draw a spline */
36 | $SplineSettings = ["Color"=>new pColor(255,255,255),"ShowControl"=>TRUE,"Ticks"=>4];
37 | $Coordinates = array([250,50],[250,180],[350,180],[350,50]);
38 | $myPicture->drawSpline($Coordinates,$SplineSettings);
39 |
40 | /* Render the picture (choose the best way) */
41 | $myPicture->autoOutput("temp/example.drawSpline.png");
42 |
43 |
--------------------------------------------------------------------------------
/examples/example.drawSplineChart.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/example.drawSplineChart.php
--------------------------------------------------------------------------------
/examples/example.drawStackedAreaChart.normalized.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([4,0,0,12,8,3,0,12,8],"Frontend #1");
16 | $myPicture->myData->addPoints([3,12,15,8,5,5,12,15,8],"Frontend #2");
17 | $myPicture->myData->addPoints([2,7,5,18,19,22,7,5,18],"Frontend #3");
18 | $myPicture->myData->setAxisName(0,"Average Usage");
19 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept"],"Labels");
20 | $myPicture->myData->setSerieDescription("Labels","Months");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Normalize the data series to 100% */
24 | $myPicture->myData->normalize(100,"%");
25 |
26 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
27 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240), "EndColor"=>new pColor(180,180,180,20)]);
28 |
29 | /* Set the default font properties */
30 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
31 |
32 | /* Draw the scale and the chart */
33 | $myPicture->setGraphArea(60,20,680,190);
34 | $myPicture->drawScale(["XMargin"=>1,"DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL_START0]);
35 |
36 | /* Turn on shadow processing */
37 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
38 |
39 | /* Draw the stacked area chart */
40 | $pCharts = new pCharts($myPicture);
41 | $pCharts->drawStackedAreaChart(["DrawPlot"=>TRUE,"DrawLine"=>TRUE,"LineSurrounding"=>-20]);
42 |
43 | /* Write the chart legend */
44 | $myPicture->drawLegend(480,210,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
45 |
46 | /* Render the picture (choose the best way) */
47 | $myPicture->autoOutput("temp/example.drawStackedAreaChart.normalized.png");
48 |
49 |
--------------------------------------------------------------------------------
/examples/example.drawStackedAreaChart.simple.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([4,1,0,12,8,4,0,12,8],"Frontend #1");
16 | $myPicture->myData->addPoints([3,12,15,8,VOID,VOID,12,15,8],"Frontend #2");
17 | $myPicture->myData->addPoints([4,4,4,4,4,4,4,4,4],"Frontend #3");
18 | $myPicture->myData->setAxisName(0,"Average Usage");
19 | $myPicture->myData->addPoints(["January","February","March","April","May","June","July","August","September"],"Labels");
20 | $myPicture->myData->setSerieDescription("Labels","Months");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
24 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240), "EndColor"=>new pColor(180,180,180,20)]);
25 |
26 | /* Set the default font properties */
27 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
28 |
29 | /* Draw the scale and the chart */
30 | $myPicture->setGraphArea(60,20,680,190);
31 | $myPicture->drawScale(["XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL_START0]);
32 |
33 | $pCharts = new pCharts($myPicture);
34 | $pCharts->drawStackedAreaChart(["DrawPlot"=>TRUE,"DrawLine"=>TRUE,"LineSurrounding"=>-20]);
35 |
36 | /* Turn on shadow processing */
37 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
38 |
39 | /* Write the chart legend */
40 | $myPicture->drawLegend(480,210,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
41 |
42 | /* Render the picture (choose the best way) */
43 | $myPicture->autoOutput("temp/example.drawStackedAreaChart.simple.png");
44 |
45 |
--------------------------------------------------------------------------------
/examples/example.drawStackedBarChart.border.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([4,VOID,VOID,12,8,3],"Frontend #1");
16 | $myPicture->myData->addPoints([3,12,15,8,5,5],"Frontend #2");
17 | $myPicture->myData->addPoints([2,7,5,18,19,22],"Frontend #3");
18 | $myPicture->myData->setAxisName(0,"Average Usage");
19 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun"],"Labels");
20 | $myPicture->myData->setSerieDescription("Labels","Months");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
24 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240), "EndColor"=>new pColor(180,180,180,20)]);
25 |
26 | /* Set the default font properties */
27 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
28 |
29 | /* Draw the scale and the chart */
30 | $myPicture->setGraphArea(60,20,680,190);
31 | $myPicture->drawScale(["DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL_START0]);
32 | $myPicture->setShadow(FALSE);
33 |
34 | (new pCharts($myPicture))->drawStackedBarChart(["Surrounding"=>-15,"InnerSurrounding"=>15]);
35 |
36 | /* Write a label */
37 | $myPicture->writeLabel(["Frontend #1","Frontend #2","Frontend #3"],[1],["DrawVerticalLine"=>TRUE,"forStackedChart" => TRUE]);
38 |
39 | /* Write the chart legend */
40 | $myPicture->drawLegend(480,210,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
41 |
42 | /* Render the picture (choose the best way) */
43 | $myPicture->autoOutput("temp/example.drawStackedBarChart.shaded.png");
44 |
45 |
--------------------------------------------------------------------------------
/examples/example.drawStackedBarChart.can.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([-4,VOID,VOID,12,8,3],"Frontend #1");
16 | $myPicture->myData->addPoints([3,12,15,8,5,-5],"Frontend #2");
17 | $myPicture->myData->addPoints([2,7,5,18,19,22],"Frontend #3");
18 | $myPicture->myData->setAxisName(0,"Average Usage");
19 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun"],"Labels");
20 | $myPicture->myData->setSerieDescription("Labels","Months");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Normalize all the data series to 100% */
24 | $myPicture->myData->normalize(100,"%");
25 |
26 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
27 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240), "EndColor"=>new pColor(180,180,180,20)]);
28 |
29 | /* Set the default font properties */
30 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>6]);
31 |
32 | /* Draw the scale and the chart */
33 | $myPicture->setGraphArea(60,20,680,190);
34 | $myPicture->drawScale(["DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL]);
35 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
36 |
37 | (new pCharts($myPicture))->drawStackedBarChart(["DisplayValues"=>TRUE,"DisplayType"=>DISPLAY_AUTO,"Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"Surrounding"=>30]);
38 |
39 | /* This one is useless as drawLegend would disable shadow while it draws */
40 | $myPicture->setShadow(FALSE);
41 |
42 | /* Write the chart legend */
43 | $myPicture->drawLegend(480,210,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
44 |
45 | /* Render the picture (choose the best way) */
46 | $myPicture->autoOutput("temp/example.drawStackedBarChart.can.png");
47 |
48 |
--------------------------------------------------------------------------------
/examples/example.drawStackedBarChart.pyramid.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([20,40,65,100,70,55,40,22,12],"Male");
16 | $myPicture->myData->addPoints([-22,-44,-61,-123,-74,-60,-52,-34,-21],"Female");
17 | $myPicture->myData->addPoints(["0-10","10-20","20-30","30-40","40-50","50-60","60-70","70-80","80-90"],"Labels");
18 | $myPicture->myData->setSerieDescription("Labels","Ages");
19 | $myPicture->myData->setAbscissa("Labels");
20 | $myPicture->myData->setAxisProperties(0, [
21 | "Name" => "Community members",
22 | "Display" => AXIS_FORMAT_CUSTOM,
23 | "Format" => function($Value){
24 | return abs($Value);
25 | }
26 | ]);
27 |
28 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
29 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240), "EndColor"=>new pColor(180,180,180,20)]);
30 |
31 | /* Set the default font properties */
32 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
33 |
34 | /* Draw the scale and the chart */
35 | $myPicture->setGraphArea(60,20,680,190);
36 | $myPicture->drawScale(["DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL]);
37 |
38 | (new pCharts($myPicture))->drawStackedBarChart(["DisplayValues"=>TRUE,"DisplayType"=>DISPLAY_AUTO,"Gradient"=>TRUE,"Surrounding"=>-20,"InnerSurrounding"=>20]);
39 |
40 | /* Write the chart legend */
41 | $myPicture->drawLegend(600,210,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
42 |
43 | /* Render the picture (choose the best way) */
44 | $myPicture->autoOutput("temp/example.drawStackedBarChart.pyramid.png");
45 |
46 |
--------------------------------------------------------------------------------
/examples/example.drawStackedBarChart.rounded.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([-7,-8,-15,-20,-18,-12,8,-19,9,16,-20,8,10,-10,-14,-20,8,-9,-19],"Probe 3");
16 | $myPicture->myData->addPoints([19,0,-8,8,-8,12,-19,-10,5,12,-20,-8,10,-11,-12,8,-17,-14,0],"Probe 4");
17 | $myPicture->myData->setAxisName(0,"Temperatures");
18 | $myPicture->myData->addPoints([4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],"Time");
19 | $myPicture->myData->setSerieDescription("Time","Hour of the day");
20 | $myPicture->myData->setAbscissa("Time", ["Unit" => "h"]);
21 |
22 | /* Draw the background */
23 | $myPicture->drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
24 |
25 | /* Overlay with a gradient */
26 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
27 |
28 | /* Set the default font properties */
29 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
30 |
31 | /* Draw the scale */
32 | $myPicture->setGraphArea(60,30,650,190);
33 | $myPicture->drawScale(["CycleBackground"=>TRUE,"DrawSubTicks"=>TRUE,"GridColor"=>new pColor(0,0,0,10),"Mode"=>SCALE_MODE_ADDALL]);
34 |
35 | /* Draw some thresholds */
36 | $myPicture->drawThreshold([-40],["WriteCaption"=>TRUE,"Color"=>new pColor(0),"Ticks"=>4]);
37 | $myPicture->drawThreshold([28],["WriteCaption"=>TRUE,"Color"=>new pColor(0),"Ticks"=>4]);
38 |
39 | /* Draw the chart */
40 | (new pCharts($myPicture))->drawStackedBarChart(["Rounded"=>TRUE,"DisplayValues"=>TRUE,"DisplayType"=>DISPLAY_AUTO,"DisplaySize"=>6,"BorderColor"=>new pColor(255)]);
41 |
42 | /* Write the chart legend */
43 | $myPicture->drawLegend(570,212,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
44 |
45 | /* Render the picture (choose the best way) */
46 | $myPicture->autoOutput("temp/example.drawStackedBarChart.rounded.png");
47 |
48 |
--------------------------------------------------------------------------------
/examples/example.drawStackedBarChart.shaded.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([-4,VOID,VOID,12,8,3],"Frontend #1");
16 | $myPicture->myData->addPoints([3,12,15,8,5,-5],"Frontend #2");
17 | $myPicture->myData->addPoints([2,7,5,18,19,22],"Frontend #3");
18 | $myPicture->myData->setAxisName(0,"Average Usage");
19 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun"],"Labels");
20 | $myPicture->myData->setSerieDescription("Labels","Months");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Normalize all the data series to 100% */
24 | $myPicture->myData->normalize(100,"%");
25 |
26 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
27 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(240), "EndColor"=>new pColor(180,180,180,20)]);
28 |
29 | /* Set the default font properties */
30 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
31 |
32 | /* Draw the scale and the chart */
33 | $myPicture->setGraphArea(60,20,680,190);
34 | $myPicture->drawScale(["DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL]);
35 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
36 |
37 | /* Draw the chart */
38 | (new pCharts($myPicture))->drawStackedBarChart(["DisplayValues"=>TRUE,"DisplayType"=>DISPLAY_AUTO,"Gradient"=>TRUE,"Surrounding"=>30,"InnerSurrounding"=>20]);
39 |
40 | $myPicture->setShadow(FALSE);
41 |
42 | /* Write the chart legend */
43 | $myPicture->drawLegend(480,210,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
44 |
45 | /* Render the picture (choose the best way) */
46 | $myPicture->autoOutput("temp/example.drawStackedBarChart.shaded.png");
47 |
48 |
--------------------------------------------------------------------------------
/examples/example.drawStepChart.simple.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([VOID,VOID,VOID,2,6,3],"Probe 1");
16 | $myPicture->myData->addPoints([13,12,15,18,15,10],"Probe 2");
17 | $myPicture->myData->setAxisName(0,"Temperatures");
18 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun"],"Labels");
19 | $myPicture->myData->setSerieDescription("Labels","Months");
20 | $myPicture->myData->setAbscissa("Labels");
21 |
22 | /* Turn off Anti-aliasing */
23 | $myPicture->setAntialias(FALSE);
24 |
25 | /* Draw the border */
26 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
27 |
28 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
29 |
30 | /* Define the chart area */
31 | $myPicture->setGraphArea(60,30,650,190);
32 |
33 | /* Draw the scale */
34 | $myPicture->drawScale(["XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
35 |
36 | /* Draw the step chart */
37 | (new pCharts($myPicture))->drawStepChart();
38 |
39 | /* Write the chart legend */
40 | $myPicture->drawLegend(590,17,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
41 |
42 | /* Render the picture (choose the best way) */
43 | $myPicture->autoOutput("temp/example.drawStepChart.simple.png");
44 |
45 |
--------------------------------------------------------------------------------
/examples/example.drawStockChart.median.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([35,28,17,27,12,12,20,15,20,28],"Open");
18 | $myPicture->myData->addPoints([20,17,25,20,25,23,16,29,26,17],"Close");
19 | $myPicture->myData->addPoints([10,11,14,11,9,4,3,7,9,5],"Min");
20 | $myPicture->myData->addPoints([37,32,33,29,29,25,22,34,29,31],"Max");
21 | $myPicture->myData->addPoints([30,20,21,24,22,18,18,24,22,24],"Median");
22 | $myPicture->myData->setAxisProperties(0,["Display" => AXIS_FORMAT_CURRENCY, "Format" => "$"]);
23 |
24 | $myPicture->myData->addPoints(["Dec 13","Dec 14","Dec 15","Dec 16","Dec 17", "Dec 20","Dec 21","Dec 22","Dec 23","Dec 24"],"Time");
25 | $myPicture->myData->setAbscissa("Time", ["Name" => "Time"]);
26 |
27 | /* Turn off Anti-aliasing */
28 | $myPicture->setAntialias(FALSE);
29 |
30 | /* Draw the border */
31 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
32 |
33 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
34 |
35 | /* Define the chart area */
36 | $myPicture->setGraphArea(60,30,650,190);
37 |
38 | /* Draw the scale */
39 | $myPicture->drawScale(["GridColor"=>new pColor(200),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
40 |
41 | /* Create the pStock object */
42 | $mystockChart = new pStock($myPicture);
43 |
44 | /* Draw the stock chart */
45 | $mystockChart->drawStockChart(["BoxUpColor"=>new pColor(255),"BoxDownColor"=>new pColor(0),"SerieMedian"=>"Median"]);
46 |
47 | /* Render the picture (choose the best way) */
48 | $myPicture->autoOutput("temp/example.drawStockChart.median.png");
49 |
50 |
--------------------------------------------------------------------------------
/examples/example.drawStockChart.simple.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([35,28,17,27,12,12,20,15,20,28],"Open");
19 | $myPicture->myData->addPoints([20,17,25,20,25,23,16,29,26,17],"Close");
20 | $myPicture->myData->addPoints([10,11,14,11,9,4,3,7,9,5],"Min");
21 | $myPicture->myData->addPoints([37,32,33,29,29,25,22,34,29,31],"Max");
22 | $myPicture->myData->setAxisProperties(0,["Display" => AXIS_FORMAT_CURRENCY, "Format" => "$"]);
23 |
24 | $myPicture->myData->addPoints(["Dec 13","Dec 14","Dec 15","Dec 16","Dec 17", "Dec 20","Dec 21","Dec 22","Dec 23","Dec 24"],"Time");
25 | $myPicture->myData->setAbscissa("Time", ["Name" => "Time"]);
26 |
27 | /* Turn off Anti-aliasing */
28 | $myPicture->setAntialias(FALSE);
29 |
30 | /* Draw the border */
31 | $myPicture->drawRectangle(0,0,699,229,["Color"=>myColors::Black()]);
32 |
33 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
34 |
35 | /* Define the chart area */
36 | $myPicture->setGraphArea(60,30,650,190);
37 |
38 | /* Draw the scale */
39 | $myPicture->drawScale(["GridColor"=>myColors::LightGray(),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
40 |
41 | /* Create the pStock object */
42 | $mystockChart = new pStock($myPicture);
43 |
44 | /* Draw the stock chart */
45 | $mystockChart->drawStockChart(["BoxUpColor"=>myColors::White(),"BoxDownColor"=>myColors::Black()]);
46 |
47 | /* http://php.net/manual/en/function.imagefilter.php */
48 | $myPicture->setFilter(IMG_FILTER_GRAYSCALE);
49 |
50 | /* Render the picture (choose the best way) */
51 | /* Momchil: applied filters + the gray scale palette results in significantly smaller image */
52 | $myPicture->autoOutput("temp/example.drawStockChart.simple.png", 9, PNG_ALL_FILTERS);
53 |
54 |
--------------------------------------------------------------------------------
/examples/example.drawSurface.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,400,400,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
18 |
19 | /* Do a gradient overlay */
20 | $myPicture->drawGradientArea(0,0,400,400,DIRECTION_VERTICAL,["StartColor"=>new pColor(194,231,44,50), "EndColor"=>new pColor(43,107,58,50)]);
21 | $myPicture->drawGradientArea(0,0,400,20, DIRECTION_VERTICAL,["StartColor"=>new pColor(0), "EndColor"=>new pColor(50)]);
22 |
23 | /* Add a border to the picture */
24 | $myPicture->drawRectangle(0,0,399,399,["Color"=>new pColor(0,0,0)]);
25 |
26 | /* Write the picture title */
27 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
28 | $myPicture->drawText(10,15,"pSurface() :: 2D surface charts",["Color"=>new pColor(255)]);
29 |
30 | /* Define the charting area */
31 | $myPicture->setGraphArea(20,40,380,380);
32 | $myPicture->drawFilledRectangle(20,40,380,380,["Color"=>new pColor(255,255,255,20),"Surrounding"=>-200]);
33 |
34 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1]);
35 |
36 | /* Create the surface object */
37 | $mySurface = new pSurface($myPicture);
38 |
39 | /* Set the grid size */
40 | $mySurface->setGrid(20,20);
41 |
42 | /* Write the axis labels */
43 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
44 | $mySurface->writeXLabels();
45 | $mySurface->writeYLabels();
46 |
47 | /* Add random values */
48 | for($i=0; $i<=50; $i++) {
49 | $mySurface->addPoint(rand(0,20),rand(0,20),rand(0,100));
50 | }
51 |
52 | /* Compute the missing points */
53 | $mySurface->computeMissing();
54 |
55 | /* Draw the surface chart */
56 | $mySurface->drawSurface(["Border"=>TRUE,"Surrounding"=>40]);
57 |
58 | /* Render the picture (choose the best way) */
59 | $myPicture->autoOutput("temp/example.surface.png");
60 |
61 |
--------------------------------------------------------------------------------
/examples/example.drawSurface.simple.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,210,100,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
18 |
19 | /* Do a gradient overlay */
20 | $myPicture->drawGradientArea(0,0,210,100,DIRECTION_VERTICAL,["StartColor"=>new pColor(194,231,44,50), "EndColor"=>new pColor(43,107,58,50)]);
21 | $myPicture->drawGradientArea(0,0,210,20, DIRECTION_VERTICAL,["StartColor"=>new pColor(0), "EndColor"=>new pColor(50)]);
22 |
23 | /* Add a border to the picture */
24 | $myPicture->drawRectangle(0,0,209,99,["Color"=>new pColor(0)]);
25 |
26 | /* Write the picture title */
27 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>5]);
28 | $myPicture->drawText(10,15,"pSurface() :: Surface charts",["Color"=>new pColor(255)]);
29 |
30 | /* Define the charting area */
31 | $myPicture->setGraphArea(50,60,180,80);
32 | $myPicture->drawFilledRectangle(50,60,180,80,["Color"=>new pColor(255,255,255,20),"Surrounding"=>-200]);
33 |
34 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1]);
35 |
36 | /* Create the surface object */
37 | $mySurface = new pSurface($myPicture);
38 |
39 | /* Set the grid size */
40 | $mySurface->setGrid(9,1);
41 |
42 | /* Write the axis labels */
43 | $myPicture->setFontProperties(["FontName"=>"fonts/Signika-Regular.ttf","FontSize"=>7]);
44 | $mySurface->writeXLabels(["Angle"=>45,"Labels"=>["Run 1","Run 2","Run 3","Run 4","Run 5","Run 6","Run 7","Run 8","Run 9","Run 10"]]);
45 | $mySurface->writeYLabels(["Labels"=>["Probe 1","Probe 2"]]);
46 |
47 | /* Add random values */
48 | for($i=0; $i<10; $i++) {
49 | $mySurface->addPoint($i,rand(0,1),rand(0,100));
50 | }
51 |
52 | /* Draw the surface chart */
53 | $mySurface->drawSurface(["Border"=>TRUE,"Surrounding"=>40]);
54 |
55 | /* Render the picture (choose the best way) */
56 | $myPicture->autoOutput("temp/example.surface.simple.png");
57 |
58 |
--------------------------------------------------------------------------------
/examples/example.drawText.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL, ["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"drawText() - add some text to your charts",["Color"=>new pColor(255)]);
26 |
27 | /* Enable shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,20)]);
29 |
30 | /* Write some text */
31 | $myPicture->setFontProperties(["FontName"=>"fonts/Gayathri-Regular.ttf","FontSize"=>20]);
32 |
33 | $myPicture->drawText(60,115,"10 degree text",["Color"=>new pColor(255),"Angle"=>10]);
34 | $myPicture->drawText(220,130,"Simple text", ["Color"=>new pColor(0),"Angle"=>0,"FontSize"=>30]);
35 | $myPicture->drawText(500,170,"Vertical Text",["Color"=>new pColor(200,100,0),"Angle"=>90,"FontSize"=>14]);
36 |
37 | /* Write some text */
38 | $myPicture->setFontProperties(["FontName"=>"fonts/Signika-Regular.ttf","FontSize"=>6]);
39 | $myPicture->drawText(220,160,"Encapsulated text",["DrawBox"=>TRUE,"BoxRounded"=>TRUE,"Color"=>new pColor(0),"Angle"=>0,"FontSize"=>10]);
40 |
41 | /* Write some text */
42 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>6]);
43 | $myPicture->drawText(220,195,"Text in a box",["DrawBox"=>TRUE,"Color"=>new pColor(0),"Angle"=>0,"FontSize"=>10]);
44 |
45 | /* Render the picture (choose the best way) */
46 | $myPicture->autoOutput("temp/example.drawText.png");
47 |
48 |
--------------------------------------------------------------------------------
/examples/example.drawingObjects.php:
--------------------------------------------------------------------------------
1 | setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>14]);
15 |
16 | /* Create the background */
17 | $myPicture->drawGradientArea(0,0,500,230,DIRECTION_HORIZONTAL,myColors::myGreenGradient());
18 | $myPicture->drawFilledRectangle(500,0,700,230,["Color"=>myColors::LightGreen($Alpha=100)]);
19 |
20 | /* Enable shadow computing on a (+1,+1) basis */
21 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>myColors::Black($Alpha=20)]);
22 |
23 | /* Draw the left area */
24 | $myPicture->drawRoundedFilledRectangle(0,0,20,230,10,["Color"=>myColors::LightGreen()]);
25 | $myPicture->drawText(10,220,"My first chart",["Color"=>myColors::White(),"Angle"=>90,"Align"=>TEXT_ALIGN_MIDDLELEFT]);
26 |
27 | /* Draw the right area */
28 | $myPicture->drawFilledRectangle(510,10,689,219,["Color"=>myColors::LighterGreen($Alpha=100),"Surrounding"=>20,"Ticks"=>2]);
29 |
30 | /* Write the legend */
31 | $myPicture->drawText(600,30,"Weather data",["Color"=>myColors::White(),"Align"=>TEXT_ALIGN_MIDDLEMIDDLE]);
32 | $TextSettings = ["Color"=>myColors::DarkGreen($Alpha=100),"Align"=>TEXT_ALIGN_TOPLEFT,"FontSize"=>9];
33 | $myPicture->drawText(516,45,"The data shown here has been",$TextSettings);
34 | $myPicture->drawText(516,60,"collected from European locations",$TextSettings);
35 | $myPicture->drawText(516,75,"by the French NAVI system.",$TextSettings);
36 | $myPicture->drawFromPNG(540,90,"examples/resources/blocnote.png");
37 |
38 | /* Disable shadow computing */
39 | $myPicture->setShadow(FALSE);
40 |
41 | /* Draw the picture border */
42 | $myPicture->drawRectangle(0,0,699,229,["Color"=>myColors::LightGreen()]);
43 |
44 | /* Render the picture (choose the best way) */
45 | $myPicture->autoOutput("temp/example.drawingObjects.png");
46 |
47 |
--------------------------------------------------------------------------------
/examples/example.normalize.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([-4,VOID,VOID,12,8,3],"Frontend #1");
16 | $myPicture->myData->addPoints([3,12,15,8,5,-5],"Frontend #2");
17 | $myPicture->myData->addPoints([2,7,5,18,19,22],"Frontend #3");
18 | $myPicture->myData->setAxisName(0,"Average Usage");
19 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun"],"Labels");
20 | $myPicture->myData->setSerieDescription("Labels","Months");
21 | $myPicture->myData->setAbscissa("Labels");
22 |
23 | /* Normalize the data series to 100% */
24 | $myPicture->myData->normalize(100,"%");
25 |
26 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(240), "EndColor"=>new pColor(180)]);
27 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL, ["StartColor"=>new pColor(240,240,240,20), "EndColor"=>new pColor(180,180,180,20)]);
28 |
29 | /* Set the default font properties */
30 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>7]);
31 |
32 | /* Draw the scale and the chart */
33 | $myPicture->setGraphArea(60,20,680,190);
34 | $myPicture->drawScale(["DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL]);
35 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
36 |
37 | /* Draw the chart */
38 | (new pCharts($myPicture))->drawStackedBarChart(["DisplayValues"=>TRUE,"DisplayType"=>DISPLAY_AUTO,"Rounded"=>FALSE,"Surrounding"=>60]);
39 |
40 | $myPicture->setShadow(FALSE);
41 |
42 | /* Write the chart legend */
43 | $myPicture->drawLegend(480,210,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
44 |
45 | /* Render the picture (choose the best way) */
46 | $myPicture->autoOutput("temp/example.normalize.png");
47 |
48 |
--------------------------------------------------------------------------------
/examples/example.polar.values.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([10,20,30,40,50,60,70,80,90],"ScoreA");
18 | $myPicture->myData->addPoints([20,40,50,30,10,30,40,50,60],"ScoreB");
19 | $myPicture->myData->setSerieDescription("ScoreA","Coverage A");
20 | $myPicture->myData->setSerieDescription("ScoreB","Coverage B");
21 |
22 | /* Define the abscissa serie */
23 | $myPicture->myData->addPoints([40,80,120,160,200,240,280,320,360],"Coord");
24 | $myPicture->myData->setAbscissa("Coord");
25 |
26 | $myPicture->drawGradientArea(0,0,300,300,DIRECTION_VERTICAL, ["StartColor"=>new pColor(200),"EndColor"=>new pColor(240)]);
27 | $myPicture->drawGradientArea(0,0,300,20, DIRECTION_HORIZONTAL,["StartColor"=>new pColor(30),"EndColor"=>new pColor(100)]);
28 | $myPicture->drawLine(0,20,300,20,["Color"=>new pColor(255)]);
29 |
30 | /* Add a border to the picture */
31 | $myPicture->drawRectangle(0,0,299,299,["Color"=>new pColor(0)]);
32 |
33 | /* Write the picture title */
34 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
35 | $myPicture->drawText(10,15,"pRadar - Draw radar charts",["Color"=>new pColor(255)]);
36 |
37 | /* Set the default font properties */
38 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>8,"Color"=>new pColor(80)]);
39 |
40 | /* Enable shadow computing */
41 | $myPicture->setShadow(FALSE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
42 |
43 | /* Create the pRadar object */
44 | $splitChart = new pRadar($myPicture);
45 |
46 | /* Draw a radar chart */
47 | $myPicture->setGraphArea(10,25,290,290);
48 | $splitChart->drawPolar([
49 | "DrawPoly"=>TRUE,
50 | "WriteValues"=>TRUE,
51 | "ValueFontSize"=>8,
52 | "Layout"=>RADAR_LAYOUT_CIRCLE,
53 | "BackgroundGradient"=>["StartColor"=>new pColor(255),"EndColor"=>new pColor(207,227,125,50)]
54 | ]);
55 |
56 | /* Render the picture (choose the best way) */
57 | $myPicture->autoOutput("temp/example.polar.values.png");
58 |
59 |
--------------------------------------------------------------------------------
/examples/example.pyramid.php:
--------------------------------------------------------------------------------
1 | new pColor(0),"NoFill" => TRUE];
16 |
17 | $myPyramid->drawPyramid($X = 100, $Y = 600, $Base = 400, $Height = 200, $Segments = 5, $Settings);
18 |
19 | $palette_light = [
20 | [239,210,121,100],
21 | [149,203,233,100],
22 | [2,71,105,100],
23 | [175,215,117,100],
24 | [44,87,0,100],
25 | [222,157,127,100]
26 | ];
27 |
28 | $myPicture->myData->loadPalette($palette_light, $overwrite=TRUE);
29 |
30 | $Settings = ["NoFill" => FALSE];
31 |
32 | $myPyramid->drawReversePyramid($X = 600, $Y = 600, $Base = 400, $Height = 200, $Segments = 3, $Settings);
33 |
34 | $Settings = ["NoFill" => FALSE];
35 | $myPyramid->draw3DPyramid($X = 1100, $Y = 600, $Base = 400, $Height = 200, $Segments = 4, $Settings);
36 |
37 | /* Render the picture (choose the best way) */
38 | $myPicture->autoOutput("temp/example.pyramid.png");
39 |
40 |
--------------------------------------------------------------------------------
/examples/example.radar.fixedmax.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([1,5,6,1,5,7,3,6,5,4,1,0],"ScoreA");
18 | $myPicture->myData->setSerieDescription("ScoreA","Application A");
19 | $myPicture->myData->setPalette("ScoreA",new pColor(150,5,217));
20 |
21 | /* Define the abscissa serie */
22 | $myPicture->myData->addPoints([1,2,3,4,5,6,7,8,9,10,11,12],"Time");
23 | $myPicture->myData->setAbscissa("Time");
24 |
25 | /* Draw a solid background */
26 | $myPicture->drawFilledRectangle(0,0,300,300,["Color"=>new pColor(179,217,91), "Dash"=>TRUE, "DashColor"=>new pColor(199,237,111)]);
27 |
28 | /* Overlay some gradient areas */
29 | $myPicture->drawGradientArea(0,0,300,300,DIRECTION_VERTICAL, ["StartColor"=>new pColor(194,231,44,50),"EndColor"=>new pColor(43,107,58,50)]);
30 | $myPicture->drawGradientArea(0,0,300,20, DIRECTION_HORIZONTAL,["StartColor"=>new pColor(30), "EndColor"=>new pColor(100)]);
31 |
32 | /* Add a border to the picture */
33 | $myPicture->drawRectangle(0,0,299,299,["Color"=>new pColor(0)]);
34 |
35 | /* Write the picture title */
36 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
37 | $myPicture->drawText(10,15,"pRadar - Draw radar charts",["Color"=>new pColor(255)]);
38 |
39 | /* Set the default font properties */
40 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>10,"Color"=>new pColor(80)]);
41 |
42 | /* Enable shadow computing */
43 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>new pColor(0,0,0,10)]);
44 |
45 | /* Create the pRadar object */
46 | $splitChart = new pRadar($myPicture);
47 |
48 | /* Draw a radar chart */
49 | $myPicture->setGraphArea(10,25,290,290);
50 | $splitChart->drawRadar([
51 | "FixedMax"=>10,
52 | "AxisRotation"=>-60,
53 | "Layout"=>RADAR_LAYOUT_STAR,
54 | "BackgroundGradient"=>["StartColor"=>new pColor(255),"EndColor"=>new pColor(207,227,125,50)]
55 | ]);
56 |
57 | /* Render the picture (choose the best way) */
58 | $myPicture->autoOutput("temp/example.fixedmax.png");
59 |
60 |
--------------------------------------------------------------------------------
/examples/example.radar.labels.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([4,4,10,10,4,4,15,15,4,4,10,10,4,4,15,15,4,4,10,10,4,4,15,15],"ScoreA");
18 | $myPicture->myData->setSerieDescription("ScoreA","Application A");
19 | $myPicture->myData->setPalette("ScoreA", new pColor(150,5,217));
20 |
21 | /* Define the abscissa serie */
22 | $myPicture->myData->addPoints([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],"Time");
23 | $myPicture->myData->setAbscissa("Time");
24 |
25 | $myPicture->drawGradientArea(0,0,300,300,DIRECTION_VERTICAL, ["StartColor"=>new pColor(200),"EndColor"=>new pColor(240)]);
26 | $myPicture->drawGradientArea(0,0,300,20, DIRECTION_HORIZONTAL,["StartColor"=>new pColor(30), "EndColor"=>new pColor(100)]);
27 | $myPicture->drawLine(0,20,300,20,["Color" => new pColor(255)]);
28 |
29 | /* Add a border to the picture */
30 | $myPicture->drawRectangle(0,0,299,299,["Color" => new pColor(0)]);
31 |
32 | /* Write the picture title */
33 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
34 | $myPicture->drawText(10,15,"pRadar - Draw radar charts",["Color"=>new pColor(255)]);
35 |
36 | /* Set the default font properties */
37 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>10,"Color"=>new pColor(80)]);
38 |
39 | /* Enable shadow computing */
40 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color" => new pColor(0,0,0,10)]);
41 |
42 | /* Create the pRadar object */
43 | $SplitChart = new pRadar($myPicture);
44 |
45 | /* Draw a radar chart */
46 | $myPicture->setGraphArea(10,25,290,290);
47 | $SplitChart->drawRadar([
48 | "SkipLabels"=>3,
49 | "LabelMiddle"=>TRUE,
50 | "Layout"=>RADAR_LAYOUT_STAR,
51 | "BackgroundGradient"=>["StartColor"=>new pColor(255),"EndColor"=>new pColor(207,227,125,50)]
52 | ]);
53 |
54 | /* Render the picture (choose the best way) */
55 | $myPicture->autoOutput("temp/example.radar.labels.png");
56 |
57 |
--------------------------------------------------------------------------------
/examples/example.radar.values.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([8,4,6,4,2,7],"Score");
18 | $myPicture->myData->setSerieDescription("Score","Application A");
19 | $myPicture->myData->setPalette("Score",new pColor(157,196,22));
20 |
21 | /* Define the abscissa serie */
22 | $myPicture->myData->addPoints(["Speed","Weight","Cost","Size","Ease","Utility"],"Families");
23 | $myPicture->myData->setAbscissa("Families");
24 |
25 | $myPicture->drawGradientArea(0,0,300,300,DIRECTION_VERTICAL, ["StartColor"=>new pColor(200),"EndColor"=>new pColor(240)]);
26 | $myPicture->drawGradientArea(0,0,300,20, DIRECTION_HORIZONTAL,["StartColor"=>new pColor(30), "EndColor"=>new pColor(100)]);
27 | $myPicture->drawLine(0,20,300,20,["Color"=>new pColor(255)]);
28 |
29 | /* Add a border to the picture */
30 | $myPicture->drawRectangle(0,0,299,299,["Color"=>new pColor(0)]);
31 |
32 | /* Write the picture title */
33 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
34 | $myPicture->drawText(10,15,"pRadar - Draw radar charts",["Color"=>new pColor(255)]);
35 |
36 | /* Set the default font properties */
37 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>10,"Color"=>new pColor(80)]);
38 |
39 | /* Enable shadow computing */
40 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>new pColor(0,0,0,10)]);
41 |
42 | /* Create the pRadar object */
43 | $SplitChart = new pRadar($myPicture);
44 |
45 | /* Draw a radar chart */
46 | $myPicture->setGraphArea(10,25,290,290);
47 | $SplitChart->drawRadar([
48 | "DrawPoly"=>TRUE,
49 | "WriteValues"=>TRUE,
50 | "ValueFontSize"=>8,
51 | "Layout"=>RADAR_LAYOUT_CIRCLE,
52 | "BackgroundGradient"=>["StartColor"=>new pColor(255),"EndColor"=>new pColor(207,227,125,50)],
53 | ]);
54 |
55 | /* Render the picture (choose the best way) */
56 | $myPicture->autoOutput("temp/example.radar.values.png");
57 |
58 |
--------------------------------------------------------------------------------
/examples/example.setShadow.php:
--------------------------------------------------------------------------------
1 | drawFilledRectangle(0,0,700,230,["Color"=>new pColor(170,183,87), "Dash"=>TRUE, "DashColor"=>new pColor(190,203,107)]);
15 |
16 | /* Overlay with a gradient */
17 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,["StartColor"=>new pColor(219,231,139,50),"EndColor"=>new pColor(1,138,68,50)]);
18 | $myPicture->drawGradientArea(0,0,700,20, DIRECTION_VERTICAL,["StartColor"=>new pColor(0,0,0,80),"EndColor"=>new pColor(50,50,50,80)]);
19 |
20 | /* Add a border to the picture */
21 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
22 |
23 | /* Write the picture title */
24 | $myPicture->setFontProperties(["FontName"=>"fonts/PressStart2P-Regular.ttf","FontSize"=>6]);
25 | $myPicture->drawText(10,15,"setShadow() - Add shadows",["Color"=>new pColor(255)]);
26 |
27 | /* Enable shadow computing */
28 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>new pColor(0,0,0,20)]);
29 |
30 | /* Draw a filled circle */
31 | $myPicture->drawFilledCircle(90,120,30,["Color"=>new pColor(201,230,40,100),"Surrounding"=>30]);
32 |
33 | /* Draw a filled rectangle */
34 | $myPicture->drawFilledRectangle(160,90,280,150,["Color"=>new pColor(231,197,40,100),"Surrounding"=>30]);
35 |
36 | /* Draw a filled rounded rectangle */
37 | $myPicture->drawRoundedFilledRectangle(320,90,440,150,5,["Color"=>new pColor(231,102,40,100),"Surrounding"=>70]);
38 |
39 | /* Render the picture (choose the best way) */
40 | $myPicture->autoOutput("temp/example.setShadow.png");
41 |
42 |
--------------------------------------------------------------------------------
/examples/example.transparent.background.php:
--------------------------------------------------------------------------------
1 | drawRoundedFilledRectangle(10,25,70,55,5, ["Color"=>new pColor(209,31,27,50), "Surrounding"=>30]);
15 | $myPicture->drawRoundedFilledRectangle(10,85,70,115,5, ["Color"=>new pColor(209,125,27,50),"Surrounding"=>30]);
16 | $myPicture->drawRoundedFilledRectangle(10,135,70,165,5,["Color"=>new pColor(209,198,27,50),"Surrounding"=>30]);
17 | $myPicture->drawRoundedFilledRectangle(10,185,70,215,5,["Color"=>new pColor(134,209,27,50),"Surrounding"=>30]);
18 |
19 | /* Enable shadow computing */
20 | $myPicture->setShadow(TRUE,["X"=>2,"Y"=>2,"Color"=>new pColor(0,0,0,20)]);
21 |
22 | /* Draw a rounded filled rectangle */
23 | $myPicture->drawRoundedFilledRectangle(100,20,680,210,20,["Color"=>new pColor(209,198,27,100),"Surrounding"=>30,"Radius"=>20]);
24 |
25 | /* Render the picture (choose the best way) */
26 | $myPicture->autoOutput("temp/example.transparent.background.png");
27 |
28 |
--------------------------------------------------------------------------------
/examples/example.writeBounds.php:
--------------------------------------------------------------------------------
1 | myData->addPoints([2,7,5,18,VOID,12,10,15,8,5,6,9],"Help Desk");
16 | $myPicture->myData->setAxisName(0,"Incidents");
17 | $myPicture->myData->addPoints(["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"],"Labels");
18 | $myPicture->myData->setSerieDescription("Labels","Months");
19 | $myPicture->myData->setAbscissa("Labels");
20 |
21 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL, ["StartColor"=>new pColor(100), "EndColor"=>new pColor(50)]);
22 | $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,["StartColor"=>new pColor(100,100,100,20), "EndColor"=>new pColor(50,50,50,20)]);
23 | $myPicture->drawGradientArea(0,0,60,230, DIRECTION_HORIZONTAL,["StartColor"=>new pColor(0), "EndColor"=>new pColor(50)]);
24 |
25 | /* Do some cosmetics */
26 | $myPicture->setShadow(TRUE,["X"=>1,"Y"=>1,"Color"=>new pColor(0,0,0,10)]);
27 | $myPicture->drawLine(60,0,60,230,["Color"=>new pColor(70)]);
28 | $myPicture->drawRectangle(0,0,699,229,["Color"=>new pColor(0)]);
29 | $myPicture->setFontProperties(["FontName"=>"fonts/Cairo-Regular.ttf","FontSize"=>11]);
30 | $myPicture->drawText(35,115,"Recorded cases",["Color"=>new pColor(255),"FontSize"=>20,"Angle"=>90,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE]);
31 |
32 | /* Draw a spline chart */
33 | $myPicture->setGraphArea(100,30,680,190);
34 | $myPicture->drawFilledRectangle(100,30,680,190,["Color"=>new pColor(255,255,255,20)]);
35 | $myPicture->setFontProperties(["Color"=>new pColor(255),"FontSize"=>7]);
36 | $myPicture->drawScale(["AxisColor"=>new pColor(255),"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE]);
37 | (new pCharts($myPicture))->drawSplineChart();
38 |
39 | /* Write the data bounds */
40 | $myPicture->writeBounds();
41 | $myPicture->setShadow(FALSE);
42 |
43 | /* Write the chart legend */
44 | $myPicture->drawLegend(630,215,["Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL]);
45 |
46 | /* Render the picture (choose the best way) */
47 | $myPicture->autoOutput("temp/example.writeBounds.png");
48 |
49 |
--------------------------------------------------------------------------------
/examples/fetch.src.php:
--------------------------------------------------------------------------------
1 | new pChart\pColor(240,240,240,$Alpha), "EndColor"=>new pChart\pColor(180,180,180,$Alpha)];
45 | }
46 |
47 | public static function myGreenGradient(float $Alpha = 100)
48 | {
49 | return ["StartColor"=>new pChart\pColor(217,250,116,$Alpha), "EndColor"=>new pChart\pColor(181,209,27,$Alpha)];
50 | }
51 |
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/examples/resources/accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/accept.png
--------------------------------------------------------------------------------
/examples/resources/application_form.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/application_form.png
--------------------------------------------------------------------------------
/examples/resources/application_view_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/application_view_list.png
--------------------------------------------------------------------------------
/examples/resources/application_view_tile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/application_view_tile.png
--------------------------------------------------------------------------------
/examples/resources/background.console.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/background.console.png
--------------------------------------------------------------------------------
/examples/resources/blocnote.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/blocnote.png
--------------------------------------------------------------------------------
/examples/resources/chart_bar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/chart_bar.png
--------------------------------------------------------------------------------
/examples/resources/chart_bar_edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/chart_bar_edit.png
--------------------------------------------------------------------------------
/examples/resources/chart_curve.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/chart_curve.png
--------------------------------------------------------------------------------
/examples/resources/chart_line.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/chart_line.png
--------------------------------------------------------------------------------
/examples/resources/cog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/cog.png
--------------------------------------------------------------------------------
/examples/resources/color_swatch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/color_swatch.png
--------------------------------------------------------------------------------
/examples/resources/comment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/comment.png
--------------------------------------------------------------------------------
/examples/resources/computer.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/computer.gif
--------------------------------------------------------------------------------
/examples/resources/dash-explorer-blank.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/dash-explorer-blank.png
--------------------------------------------------------------------------------
/examples/resources/dash-explorer-last.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/dash-explorer-last.png
--------------------------------------------------------------------------------
/examples/resources/dash-explorer-noleaf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/dash-explorer-noleaf.png
--------------------------------------------------------------------------------
/examples/resources/dash-explorer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/dash-explorer.png
--------------------------------------------------------------------------------
/examples/resources/dash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/dash.png
--------------------------------------------------------------------------------
/examples/resources/database_table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/database_table.png
--------------------------------------------------------------------------------
/examples/resources/folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/folder.png
--------------------------------------------------------------------------------
/examples/resources/hologram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/hologram.png
--------------------------------------------------------------------------------
/examples/resources/landscape1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/landscape1.jpg
--------------------------------------------------------------------------------
/examples/resources/landscape2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/landscape2.jpg
--------------------------------------------------------------------------------
/examples/resources/layout_edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/layout_edit.png
--------------------------------------------------------------------------------
/examples/resources/page_edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/page_edit.png
--------------------------------------------------------------------------------
/examples/resources/paintcan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/paintcan.png
--------------------------------------------------------------------------------
/examples/resources/serie1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/serie1.png
--------------------------------------------------------------------------------
/examples/resources/serie2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/serie2.png
--------------------------------------------------------------------------------
/examples/resources/shape_flip_vertical.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/shape_flip_vertical.png
--------------------------------------------------------------------------------
/examples/resources/tab.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/tab.png
--------------------------------------------------------------------------------
/examples/resources/vector.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/vector.png
--------------------------------------------------------------------------------
/examples/resources/wait.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/wait.gif
--------------------------------------------------------------------------------
/examples/resources/wand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/wand.png
--------------------------------------------------------------------------------
/examples/resources/wrench.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/examples/resources/wrench.png
--------------------------------------------------------------------------------
/examples/sandbox/helper.class.php:
--------------------------------------------------------------------------------
1 | Constants = get_defined_constants(true)["user"];
10 | }
11 |
12 | public function code2src(array $code)
13 | {
14 | $src = "<?php\r\n\r\n";
15 | $src .= implode("\r\n", $code);
16 | return $src."\r\n?>\r\n";
17 | }
18 |
19 | public function hexToColorObj(string $Hex, $alpha = NULL)
20 | {
21 | list($R, $G, $B) = $this->getRGB($Hex);
22 |
23 | if (is_null($alpha)){
24 | if (($R == $G) && ($G == $B)){
25 | $ret = 'new pColor('.$R.')';
26 | } else {
27 | $ret = 'new pColor('.$R.','.$G.','.$B.')';
28 | }
29 | } else {
30 | $ret = 'new pColor('.$R.','.$G.','.$B.','.$alpha.')';
31 | }
32 |
33 | return $ret;
34 | }
35 |
36 | public function getRGB(string $Hex)
37 | {
38 | if (strlen($Hex) != 7){
39 | return [0,0,0];
40 | }
41 |
42 | // strip the #
43 | $Hex = substr($Hex, 1);
44 |
45 | $R = hexdec($Hex[0].$Hex[1]);
46 | $G = hexdec($Hex[2].$Hex[3]);
47 | $B = hexdec($Hex[4].$Hex[5]);
48 |
49 | return [$R,$G,$B];
50 | }
51 |
52 | public function dumpArray($Name, $Values)
53 | {
54 | if ($Values == []){
55 | return '$'.$Name.' = [];';
56 | }
57 |
58 | $Result = '$'.$Name.' = [';
59 | foreach ($Values as $Key => $Value){
60 | $Result .= chr(39).$Key.chr(39).'=>'.$this->translate($Value).', ';
61 | }
62 |
63 | return substr($Result, 0, -2)."];";
64 | }
65 |
66 | public function translate($Value)
67 | {
68 | if ($Value == ""){
69 | return "VOID";
70 | }
71 |
72 | $pos = array_search($Value, $this->Constants);
73 | return ($pos !== FALSE) ? $pos : $Value;
74 | }
75 |
76 | public function stringify($Values)
77 | {
78 | array_walk($Values, array($this, 'toString'));
79 |
80 | return implode(",", $Values);
81 | }
82 |
83 | public function toString(&$Value)
84 | {
85 | $Value = (is_numeric($Value) || $Value == "VOID") ? $Value : chr(34).$Value.chr(34);
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/fonts/Abel-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/fonts/Abel-Regular.ttf
--------------------------------------------------------------------------------
/fonts/Cairo-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/fonts/Cairo-Regular.ttf
--------------------------------------------------------------------------------
/fonts/Dosis-Light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/fonts/Dosis-Light.ttf
--------------------------------------------------------------------------------
/fonts/Gayathri-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/fonts/Gayathri-Regular.ttf
--------------------------------------------------------------------------------
/fonts/PressStart2P-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/fonts/PressStart2P-Regular.ttf
--------------------------------------------------------------------------------
/fonts/Signika-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bozhinov/pChart2.0-for-PHP7/75a4ac6f8085e0668e8570654669faf22cba1d8d/fonts/Signika-Regular.ttf
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 | = 32) {
18 | $bstream[] = [0, 5];
19 | # Used to be $len - 32 but that resulted
20 | # in AK at the end of the decoded string
21 | $bstream[] = [($len - 31), 11];
22 | } else {
23 | $bstream[] = [$len, 5];
24 | }
25 |
26 | foreach($data as $ord){
27 | $bstream[] = [$ord, 8];
28 | }
29 |
30 | return $bstream;
31 | }
32 | }
--------------------------------------------------------------------------------
/pChart/Barcodes/Aztec/Token.php:
--------------------------------------------------------------------------------
1 | mode = $mode;
15 | $this->shiftByteCount = $binaryBytes;
16 | $this->bitCount += $bitCount;
17 | }
18 |
19 | public function getMode()
20 | {
21 | return $this->mode;
22 | }
23 |
24 | public function getShiftByteCount()
25 | {
26 | return $this->shiftByteCount;
27 | }
28 |
29 | public function count()
30 | {
31 | return $this->bitCount;
32 | }
33 |
34 | public function getHistory()
35 | {
36 | return $this->history;
37 | }
38 |
39 | public function add($value, $bits)
40 | {
41 | $this->bitCount += $bits;
42 | $this->history[] = [$value, $bits];
43 | }
44 |
45 | public function endBinaryShift()
46 | {
47 | $this->shiftByteCount = 0;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/pChart/Barcodes/Linear/Codabar.php:
--------------------------------------------------------------------------------
1 | '11111221',
11 | '1' => '11112211',
12 | '2' => '11121121',
13 | '3' => '22111111',
14 | '4' => '11211211',
15 | '5' => '21111211',
16 | '6' => '12111121',
17 | '7' => '12112111',
18 | '8' => '12211111',
19 | '9' => '21121111',
20 | '-' => '11122111',
21 | '$' => '11221111',
22 | ':' => '21112121',
23 | '/' => '21211121',
24 | '.' => '21212111',
25 | '+' => '11222221',
26 | 'A' => '11221211',
27 | 'B' => '12121121',
28 | 'C' => '11121221',
29 | 'D' => '11122211'
30 | ];
31 |
32 | public function encode(string $code, array $opts)
33 | {
34 | $orig = $code;
35 | if (!preg_match('/^[0-9A-Da-d*.\/:+$-]+$/', $code)){
36 | throw pException::InvalidInput("Text can not be encoded");
37 | }
38 | $code = 'A'.strtoupper($code).'A';
39 |
40 | $len = strlen($code);
41 | $blocks = [];
42 | for ($i = 0; $i < $len; ++$i) {
43 | $seq = $this->chars[$code[$i]];
44 | for ($j = 0; $j < 8; ++$j) {
45 | $t = (($j % 2) == 0);
46 | $blocks[] = [$t, $seq[$j], 1];
47 | }
48 | }
49 |
50 | return [
51 | [
52 | 'm' => $blocks,
53 | 'l' => [$orig]
54 | ]
55 | ];
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/pChart/Barcodes/Linear/Code11.php:
--------------------------------------------------------------------------------
1 | $max_p) {
18 | $p = 1;
19 | }
20 | }
21 |
22 | return $check %= 11;
23 | }
24 |
25 | public function encode(string $code, array $opts)
26 | {
27 | if (!preg_match('/^[\d-]+$/', $code)){
28 | throw pException::InvalidInput("Text can not be encoded");
29 | }
30 |
31 | $chr = [
32 | '0' => '111121',
33 | '1' => '211121',
34 | '2' => '121121',
35 | '3' => '221111',
36 | '4' => '112121',
37 | '5' => '212111',
38 | '6' => '122111',
39 | '7' => '111221',
40 | '8' => '211211',
41 | '9' => '211111',
42 | '-' => '112111',
43 | 'S' => '112211'
44 | ];
45 |
46 | $orig = " ".$code." ";
47 | $code = str_split($code);
48 | $count = count($code);
49 |
50 | // calculate check digit C
51 | $check = $this->calc_check_digit($code, 10);
52 | if ($check == 10) {
53 | $check = '-';
54 | }
55 |
56 | $code[] = $check;
57 | if ($count > 10) {
58 | // calculate check digit K
59 | $check = $this->calc_check_digit($code, 9);
60 | $code []= $check;
61 | $orig .= " ";
62 | }
63 |
64 | array_unshift($code, 'S');
65 | array_push($code, 'S');
66 |
67 | $block = [];
68 | foreach($code as $i){
69 | for ($j = 0; $j < 6; ++$j) {
70 | $t = (($j % 2) == 0); // bar : space
71 | $block[] = [$t, $chr[$i][$j], 1];
72 | }
73 | }
74 |
75 | return [
76 | [
77 | 'm' => $block,
78 | 'l' => [$orig]
79 | ]
80 | ];
81 | }
82 | }
--------------------------------------------------------------------------------
/pChart/Barcodes/Linear/ITF.php:
--------------------------------------------------------------------------------
1 | [1, 1, 2, 2, 1],
21 | '1' => [2, 1, 1, 1, 2],
22 | '2' => [1, 2, 1, 1, 2],
23 | '3' => [2, 2, 1, 1, 1],
24 | '4' => [1, 1, 2, 1, 2],
25 | '5' => [2, 1, 2, 1, 1],
26 | '6' => [1, 2, 2, 1, 1],
27 | '7' => [1, 1, 1, 2, 2],
28 | '8' => [2, 1, 1, 2, 1],
29 | '9' => [1, 2, 1, 2, 1]
30 | ];
31 |
32 | /* Quiet zone, start. */
33 | $blocks = [
34 | ['m' => [
35 | [0, 10, 0],
36 | [1, 1, 1],
37 | [0, 1, 1],
38 | [1, 1, 1],
39 | [0, 1, 1]
40 | ]]
41 | ];
42 |
43 | /* Data. */
44 | foreach(str_split($data, 2) as $a) {
45 | $b1 = $itf_alphabet[$a[0]];
46 | $b2 = $itf_alphabet[$a[1]];
47 | $m = [];
48 | for($i = 0; $i < 5; $i++) {
49 | $m[] = [1, 1, $b1[$i]];
50 | $m[] = [0, 1, $b2[$i]];
51 | }
52 | $blocks[] = [
53 | 'm' => $m,
54 | 'l' => [$a]
55 | ];
56 | }
57 |
58 | /* End, quiet zone. */
59 | $blocks[] = [
60 | 'm' => [
61 | [1, 1, 2],
62 | [0, 1, 1],
63 | [1, 1, 1],
64 | [0, 10, 0]
65 | ]
66 | ];
67 |
68 | /* Return code. */
69 | return $blocks;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/pChart/Barcodes/Linear/MSI.php:
--------------------------------------------------------------------------------
1 | [1,1,1,1],
19 | '1' => [1,1,1,2],
20 | '2' => [1,1,2,1],
21 | '3' => [1,1,2,2],
22 | '4' => [1,2,1,1],
23 | '5' => [1,2,1,2],
24 | '6' => [1,2,2,1],
25 | '7' => [1,2,2,2],
26 | '8' => [2,1,1,1],
27 | '9' => [2,1,1,2],
28 | 'A' => [2,1,2,1],
29 | 'B' => [2,1,2,2],
30 | 'C' => [2,2,1,1],
31 | 'D' => [2,2,1,2],
32 | 'E' => [2,2,2,1],
33 | 'F' => [2,2,2,2]
34 | ];
35 |
36 | $code = str_split($code);
37 |
38 | if ($opts['mode'] == "+") {
39 | // add checksum
40 | $p = 2;
41 | $check = 0;
42 | foreach(array_reverse($code) as $i){
43 | $check += (hexdec($i) * $p);
44 | ++$p;
45 | if ($p > 7) {
46 | $p = 2;
47 | }
48 | }
49 | $check %= 11;
50 | if ($check > 0) {
51 | $check = 11 - $check;
52 | }
53 | $code[] = $check;
54 | }
55 |
56 | $block = [
57 | [1, 2, 1], // left guard
58 | [0, 1, 1]
59 | ];
60 |
61 | foreach($code as $i){
62 | foreach($chr[$i] as $chr_a){
63 | $block[] = [1, $chr_a, 1];
64 | $block[] = [0, ($chr_a & 1) + 1, 1];
65 | }
66 | }
67 |
68 | $block[] = [1, 1, 1]; // right guard
69 | $block[] = [0, 2, 1];
70 | $block[] = [1, 1, 1];
71 |
72 | return [
73 | [
74 | 'm' => $block,
75 | 'l' => [$orig]
76 | ]
77 | ];
78 | }
79 | }
--------------------------------------------------------------------------------
/pChart/Barcodes/Linear/Pharmacode.php:
--------------------------------------------------------------------------------
1 | pharmacode2t(intval($code));
19 | } else {
20 | $block = $this->pharmacode(intval($code));
21 | }
22 |
23 | return [
24 | [
25 | 'm' => $block,
26 | 'l' => [$orig]
27 | ]
28 | ];
29 | }
30 |
31 | private function pharmacode($code)
32 | {
33 | $block = [];
34 |
35 | while ($code > 0) {
36 | if (($code % 2) == 0) {
37 | $w = 3;
38 | $code -= 2;
39 | } else {
40 | $w = 1;
41 | $code -= 1;
42 | }
43 | $code /= 2;
44 |
45 | $block[] = [1, $w, 1];
46 | $block[] = [0, 2, 1];
47 | }
48 |
49 | array_pop($block);
50 |
51 | return array_reverse($block);
52 | }
53 |
54 | private function pharmacode2t($code)
55 | {
56 | $block = [];
57 | do {
58 | $c = $code % 3;
59 | if ($c == 0){
60 | $rev = 3;
61 | $h = 2;
62 | } else {
63 | $rev = $c;
64 | $h = 1;
65 | }
66 | $code = ($code - $rev) / 3;
67 | $block[] = [0, 1, 1, 2, 0];
68 | $block[] = [1, 1, 1, $h, $c % 2];
69 |
70 | } while ($code != 0);
71 |
72 | return array_reverse($block);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/pChart/Barcodes/Linear/Postnet.php:
--------------------------------------------------------------------------------
1 | [1, 1, 2, 2, 2],
16 | 1 => [2, 2, 2, 1, 1],
17 | 2 => [2, 2, 1, 2, 1],
18 | 3 => [2, 2, 1, 1, 2],
19 | 4 => [2, 1, 2, 2, 1],
20 | 5 => [2, 1, 2, 1, 2],
21 | 6 => [2, 1, 1, 2, 2],
22 | 7 => [1, 2, 2, 2, 1],
23 | 8 => [1, 2, 2, 1, 2],
24 | 9 => [1, 2, 1, 2, 2]
25 | ];
26 | } else {
27 | $barlen = [
28 | 0 => [2, 2, 1, 1, 1],
29 | 1 => [1, 1, 1, 2, 2],
30 | 2 => [1, 1, 2, 1, 2],
31 | 3 => [1, 1, 2, 2, 1],
32 | 4 => [1, 2, 1, 1, 2],
33 | 5 => [1, 2, 1, 2, 1],
34 | 6 => [1, 2, 2, 1, 1],
35 | 7 => [2, 1, 1, 1, 2],
36 | 8 => [2, 1, 1, 2, 1],
37 | 9 => [2, 1, 2, 1, 1]
38 | ];
39 | }
40 |
41 | $code = str_replace('-', '', $code);
42 | $code = str_replace(' ', '', $code);
43 |
44 | if (
45 | # https://en.wikipedia.org/wiki/POSTNET
46 | (!in_array(strlen($code), [5, 6, 9, 11])) ||
47 | (!preg_match('/^[\d]+$/', $code))
48 | ) {
49 | throw pException::InvalidInput("Text can not be encoded by Postnet");
50 | }
51 |
52 | // calculate checksum
53 | $code = str_split($code);
54 | $sum = array_sum($code);
55 |
56 | $chkd = ($sum % 10);
57 | if ($chkd > 0) {
58 | $chkd = (10 - $chkd);
59 | }
60 | $code[] = $chkd;
61 |
62 | // start bar
63 | $block = [
64 | [1, 1, 1, 2, 0],
65 | [0, 1, 1, 2, 0]
66 | ];
67 |
68 | foreach($code as $i){
69 | for ($j = 0; $j < 5; ++$j) {
70 | $h = $barlen[$i][$j];
71 | $block[] = [1, 1, 1, $h, $h % 2];
72 | $block[] = [0, 1, 1, 2, 0];
73 | }
74 | }
75 | // end bar
76 | $block[] = [1, 1, 1, 2, 0];
77 |
78 | return [
79 | [
80 | 'm' => $block,
81 | 'l' => [$orig]
82 | ]
83 | ];
84 | }
85 | }
--------------------------------------------------------------------------------
/pChart/Barcodes/Linear/UPC.php:
--------------------------------------------------------------------------------
1 | upc_a_encode($code);
20 | case "upce":
21 | var_dump($this->upc_e_encode($code));
22 | die();
23 | return $this->upc_e_encode($code);
24 | case "ean13nopad":
25 | return $this->ean_13_encode($code, ' ');
26 | case "ean13pad":
27 | case "ean13":
28 | return $this->ean_13_encode($code, '>');
29 | case "ean8":
30 | return $this->ean_8_encode($code);
31 | default:
32 | throw pException::InvalidInput("Unknown UPS encode method");
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/pChart/Barcodes/PDF417/EncoderByte.php:
--------------------------------------------------------------------------------
1 | encodeChunk64($chunk);
37 | } else {
38 | $cws = $this->encodeChunk86($chunk);
39 | }
40 | } else {
41 | // incomplete chunk
42 | $cws = $chunk;
43 | }
44 |
45 | $codeWords = array_merge($codeWords, $cws);
46 | }
47 |
48 | return $codeWords;
49 | }
50 |
51 | /**
52 | * Takes a chunk of 6 bytes and encodes it to 5 code words.
53 | * The calculation consists of switching from base 256 to base 900.
54 | * BC math is used to perform large number arithmetic.
55 | */
56 | private function encodeChunk86($chunk)
57 | {
58 | $sum = "0";
59 | for ($i = 0; $i < 6; $i++) {
60 | $val = bcmul(bcpow(256, $i), $chunk[5 - $i]);
61 | $sum = bcadd($sum, $val);
62 | }
63 |
64 | $cws = [];
65 | while(bccomp($sum, 0) > 0) {
66 | $cws[] = intval(bcmod($sum, 900));
67 | $sum = bcdiv($sum, 900, 0); // Integer division
68 | }
69 |
70 | return array_reverse($cws);
71 | }
72 |
73 | private function encodeChunk64($chunk)
74 | {
75 | $sum = 0;
76 | for ($i = 0; $i < 6; $i++) {
77 | $sum += pow(256, $i) * $chunk[5 - $i];
78 | }
79 |
80 | $cws = [];
81 | while($sum > 0) {
82 | $cws[] = intval($sum % 900);
83 | $sum = intval($sum / 900);
84 | }
85 |
86 | return array_reverse($cws);
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/pChart/Barcodes/PDF417/EncoderNumber.php:
--------------------------------------------------------------------------------
1 | encodeChunk($chunk));
37 | }
38 |
39 | return $codeWords;
40 | }
41 |
42 | private function encodeChunk($chunk)
43 | {
44 | $chunk = "1" . $chunk;
45 |
46 | $cws = [];
47 | while(bccomp($chunk, 0) > 0) {
48 | $cws[] = intval(bcmod($chunk, 900));
49 | $chunk = bcdiv($chunk, 900, 0); // Integer division
50 | }
51 |
52 | return array_reverse($cws);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/pChart/Barcodes/pConf.php:
--------------------------------------------------------------------------------
1 | options += array_replace_recursive($defaults, $opts);
24 | $this->set_color('bgColor', 255);
25 | $this->set_color('color', 0);
26 | }
27 |
28 | public function set_color(string $value, int $default)
29 | {
30 | if (!isset($this->options['palette'][$value])) {
31 | $this->options['palette'][$value] = new pColor($default);
32 | } else {
33 | if (!($this->options['palette'][$value] instanceof pColor)) {
34 | throw pException::InvalidInput("Invalid value for $value. Expected a pColor object.");
35 | }
36 | }
37 | }
38 |
39 | public function check_text_valid($text)
40 | {
41 | if($text == '\0' || $text == '') {
42 | throw pException::InvalidInput("Invalid value for text");
43 | }
44 | }
45 |
46 | public function check_ranges(array $conf)
47 | {
48 | foreach($conf as $c){
49 | $ret = $this->options[$c[0]];
50 | if (!is_numeric($ret) || $ret < $c[1] || $ret > $c[2]) {
51 | throw pException::InvalidInput("Invalid value for ".$c[0]);
52 | }
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/pChart/pColorGradient.php:
--------------------------------------------------------------------------------
1 | StartColor = $Start;
25 | $this->EndColor = $End;
26 | }
27 |
28 | private function getOffsets()
29 | {
30 | list($eR, $eG, $eB, $eA) = $this->EndColor->get();
31 | list($sR, $sG, $sB, $sA) = $this->StartColor->get();
32 |
33 | return ["R" => ($eR - $sR), "G" => ($eG - $sG), "B" => ($eB - $sB), "Alpha" => ($eA - $sA)];
34 | }
35 |
36 | public function findStep()
37 | {
38 | $this->Offsets = $this->getOffsets();
39 |
40 | list($oR, $oG, $oB, ) = array_values($this->Offsets);
41 |
42 | return max(abs($oR), abs($oG), abs($oB), 1);
43 | }
44 |
45 | public function setSegments(int $Segments)
46 | {
47 | if (is_null($this->Offsets)){
48 | $this->Offsets = $this->getOffsets();
49 | }
50 | $this->Segments = $Segments;
51 | }
52 |
53 | public function moveNext()
54 | {
55 | $this->StartColor->Slide($this->Offsets, 1/$this->Segments);
56 | }
57 |
58 | public function getStep(float $j = 1)
59 | {
60 | return $this->StartColor->newOne()->Slide($this->Offsets, abs($j)/$this->Segments);
61 | }
62 |
63 | public function isGradient()
64 | {
65 | return ($this->StartColor != $this->EndColor);
66 | }
67 |
68 | public function getLatest()
69 | {
70 | return $this->StartColor;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/php.webserver.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | php -c php.ini -S 127.0.0.1:8888
--------------------------------------------------------------------------------