xref: /plugin/statdisplay/vendor/szymach/c-pchart/resources/doc/spline.md (revision 03cdebb71906645bc452782ad23f052261c2cb18)
1# Drawing a spline chart
2
3[Reference](http://wiki.pchart.net/doc.chart.drawsplinechart.html)
4
5```php
6require '/path/to/your/vendor/autoload.php';
7
8use CpChart\Data;
9use CpChart\Image;
10
11// Create and populate data
12$data = new Data();
13$data->addPoints([], "Serie1");
14
15// Create the image and set the data
16$image = new Image(700, 230, $data);
17$image->setShadow(true, ["X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20]);
18
19// 1st spline drawn in white with control points visible
20$firstCoordinates = [[40, 80], [280, 60], [340, 166], [590, 120]];
21$fistSplineSettings = ["R" => 255, "G" => 255, "B" => 255, "ShowControl" => true];
22$image->drawSpline($firstCoordinates, $fistSplineSettings);
23
24// 2nd spline dashed drawn in white with control points visible
25$secondCoordinates = [[250, 50], [250, 180], [350, 180], [350, 50]];
26$secondSplineSettings = [
27    "R" => 255,
28    "G" => 255,
29    "B"=> 255,
30    "ShowControl" => true,
31    "Ticks" => 4
32];
33$image->drawSpline($secondCoordinates, $secondSplineSettings);
34
35// Render the picture (choose the best way)
36$image->autoOutput("example.drawSpline.png");
37```
38