welcome to the sixth chapter of PHP FPDF tutorial series.
in this chapter, i'm about to demonstrate how to make a chart in pdf document using PHP FPDF library.
this chapter only covers bar chart to represent one-dimension data series.
along this chapter, we will learn how to set positions and draw shapes in pdf.
this is a preview of what we're about to make.
first, define the chart properties.
let me explain part by part.
this is the x and y position of the chart boundary.
and this is the dimension of the chart boundary.
this is the padding between the chart boundary and the chart box.
and this is for the position and dimension of the chart box.
the x and y position of the chart box is ofsetted by chart position and respective padding.
while the chart box's size is determined from the chart's boundary size substracted by paddings.
chart data series is defined in two dimensional array with structure explained in this image.
dataMax variable contains highest value in the data series, determined by looping and comparing each data.
dataStep is to define the interval of vertical axis labels.
first, let's draw a rectangle to make the boundary visible.
to do this, use FPDF Rect() function with parameters as explained in this image.
don't forget to output the pdf file using Output().
now let's draw the chart axis, starting from the lines.
we use FPDF Line function to draw a line with parameters as explained in this image.
we need a scale factor to scale the data into bar height, i called it scale unit.
now let's draw each vertical axis labels.
now let's continue with the horizontal axis and draw the bars.
we need to equally split the box width into the number of data.
let's test it with a cell.
good, now let's loop each data series.
now let's draw the bars.
finally, add axis caption labels.
this concludes this chapter of tutorial.
please like this video if you find this tutorial helpful.
and subscribe to my channel for more tutorials update.
if you have any question or need the source code, 
feel free to ask anything in the comment section.
see you next time.
