1# Drawing a filled step chart 2 3[Reference](http://wiki.pchart.net/doc.chart.drawfilledstepchart.html) 4 5```php 6require '/path/to/your/vendor/autoload.php'; 7 8use CpChart\Data; 9use CpChart\Image; 10 11/* Create and populate the Data object */ 12$data = new Data(); 13$data->addPoints([-4, 2, VOID, 12, 8, 3], "Probe 1"); 14$data->addPoints([3, 12, 15, 8, 5, -5], "Probe 2"); 15$data->addPoints([2, 7, 5, 18, 19, 22], "Probe 3"); 16$data->setSerieTicks("Probe 2", 4); 17$data->setAxisName(0, "Temperatures"); 18$data->addPoints(["Jan", "Feb", "Mar", "Apr", "May", "Jun"], "Labels"); 19$data->setSerieDescription("Labels", "Months"); 20$data->setAbscissa("Labels"); 21 22/* Create the Image object */ 23$image = new Image(700, 230, $data); 24 25/* Draw the background */ 26$settings = ["R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107]; 27$image->drawFilledRectangle(0, 0, 700, 230, $settings); 28 29/* Overlay with a gradient */ 30$settings = ["StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50]; 31$image->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $settings); 32$image->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, [ 33 "StartR" => 0, 34 "StartG" => 0, 35 "StartB" => 0, 36 "EndR" => 50, 37 "EndG" => 50, 38 "EndB" => 50, 39 "Alpha" => 80 40]); 41 42/* Add a border to the picture */ 43$image->drawRectangle(0, 0, 699, 229, ["R" => 0, "G" => 0, "B" => 0]); 44 45/* Write the picture title */ 46$image->setFontProperties(["FontName" => "Silkscreen.ttf", "FontSize" => 6]); 47$image->drawText(10, 13, "drawFilledStepChart() - draw a filled step chart", ["R" => 255, "G" => 255, "B" => 255]); 48 49/* Write the chart title */ 50$image->setFontProperties(["FontName" => "Forgotte.ttf", "FontSize" => 11]); 51$image->drawText(250, 55, "Average temperature", ["FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE]); 52 53/* Draw the scale and the 1st chart */ 54$image->setGraphArea(60, 60, 450, 190); 55$image->drawFilledRectangle(60, 60, 450, 190, ["R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10]); 56$image->drawScale(["DrawSubTicks" => true]); 57$image->setShadow(true, ["X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10]); 58$image->setFontProperties(["FontName" => "pf_arma_five.ttf", "FontSize" => 6]); 59$image->drawFilledStepChart(["ForceTransparency" => 40, "DisplayValues" => true, "DisplayColor" => DISPLAY_AUTO]); 60$image->setShadow(false); 61 62/* Draw the scale and the 2nd chart */ 63$image->setGraphArea(500, 60, 670, 190); 64$image->drawFilledRectangle(500, 60, 670, 190, ["R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10]); 65$image->drawScale(["Pos" => SCALE_POS_TOPBOTTOM, "DrawSubTicks" => true]); 66$image->setShadow(true, ["X" => -1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10]); 67$image->drawFilledStepChart(["ForceTransparency" => 40]); 68$image->setShadow(false); 69 70/* Write the chart legend */ 71$image->drawLegend(510, 205, ["Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL]); 72 73/* Render the picture (choose the best way) */ 74$image->autoOutput("example.drawFilledStepChart.png"); 75``` 76