This bar chart is split up into 2 main areas - dashboard
and chart
.
This comprises of two drop-down lists - ddlStat
and ddlYear
. They are populated using data from the graphData
object. Upon value being changed, they will call the setData()
method of the config
object.
This is in turn split into four SVGs.
scale
provides measurements at calculated intervals. These intervals are calculated based on the maximum statistic value in the graphData object. Tags inserted into the scale SVG are line and text.chart
holds the bars of the chart, the data values background lines andmean
line. Tags inserted into the chart SVG arerect
,line
andtext
.filler
is the space bottom ofscale
and left oflegend
. It is merely meant to help align the chart.legend
holds the data labels. Tags inserted aretext
.- Other notes...
- width of
chart
andlegend
should be equal. - height of
scale
andchart
should be equal. - width of
scale
andfiller
should be equal. - height of
filler
andlegend
should be equal.
- width of
The script is mainly split into two parts - graphData
and config
.
This holds the data, which is an array of objects, followed by an array of statistic types and an array of years. The latter two are meant to populate the ddlStat
and ddlYear
drop-down lists respectively.
The first array holds objects which show football players and their appearances and goals for each given year.
This is for processing data. There are methods for calculating chart height, chart width, max, mean and finally, displaying the appropriate data.
Properties will hold values for scaling of chart, width and height of chart parts, and so on.