Skip to content

Commit bbf5ca1

Browse files
committed
Single files added
1 parent d153c75 commit bbf5ca1

16 files changed

+1272
-0
lines changed

gBarChart.php

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
namespace gchart;
3+
4+
5+
class gBarChart extends gChart
6+
{
7+
/**
8+
* @brief Constructor for the gBarChart
9+
*
10+
* With this constructor you can specify all the type of Bar Charts.
11+
*
12+
* @param $width Integer Width of the chart, in pixels. Default value is 200.
13+
* @param $height Integer Height of the chart, in pixels. Default value is 200.
14+
* @param $type String Chooses the type of chart. Use 'g' for grouped chart, 's' for stacked, 'o' for overlapped
15+
* @param $direction String Chooses the direction of the chart. Use 'v' for vertical, 'h' for horizontal
16+
*/
17+
public function __construct($width = 200, $height = 200, $type = 'g', $direction='v')
18+
{
19+
$this->setChartType($type, $direction);
20+
$this->setDimensions($width, $height);
21+
}
22+
protected function setChartType($type, $direction)
23+
{
24+
$this-> setProperty('cht', 'b'.$direction.$type);
25+
}
26+
public function getUrl()
27+
{
28+
$retStr = parent::getUrl();
29+
return $retStr;
30+
}
31+
/**
32+
* @brief Specifies custom values for bar widths and spacing between bars and groups.
33+
*
34+
* You can only specify one set of width values for all bars. If you don't set this, all bars will be 23 pixels wide,
35+
* which means that the end bars can be clipped if the total bar + space width is wider than the chart width.
36+
*
37+
* @param $barWidth Integer The width of the bar. You can specify widths and spacing absolutely. Default
38+
* value is 23 pixels, absolute value.
39+
* @param $spaceBetweenBars Integer Space between bars in the same group. This is a width in pixels. Default value is 4 pixels
40+
* for absolute values.
41+
* @param $spaceBetweenGroups Integer Space between bar groups in the same group. This is a width in pixels; Default value
42+
* is 8 pixels for absolute values.
43+
*/
44+
public function setBarWidth($barWidth, $spaceBetweenBars = 4,$spaceBetweenGroups = 8)
45+
{
46+
$this->setProperty('chbh', $this->encodeData(array($barWidth, $spaceBetweenBars,$spaceBetweenGroups), ','));
47+
}
48+
/**
49+
* @brief Resize values automatically
50+
*/
51+
public function setAutoBarWidth()
52+
{
53+
$this->setProperty('chbh', 'a');
54+
}
55+
/**
56+
* @brief Specify custom values for bar widths and spacing between bars and groups.
57+
*
58+
* You can specify widths and spacing absolutely or relatively, by entering one of the following values.
59+
*
60+
* @param $barScale String You can specify widths and spacing absolutely or relatively, by entering one of the following values:
61+
* - a: space_between_bars and space_between_groups are given in absolute units (or default absolute
62+
* values, if not specified). Bars will be resized so that all bars will fit in the chart.
63+
* - r: space_between_bars and space_between_groups are given in relative units (or default relative values,
64+
* if not specified) Relative units are floating point values compared to the bar width, where the bar
65+
* width is 1.0: for example, 0.5 is half the bar width, 2.0 is twice the bar width. Bars can be clipped
66+
* if the chart isn't wide enough.
67+
* Default value is 'a'
68+
* @param $spaceBetweenBars Integer Space between bars in the same group. This is a width in pixels. Default value is 4 pixels
69+
* for absolute values.
70+
* @param $spaceBetweenGroups Integer Space between bar groups in the same group. This is a width in pixels; Default value
71+
* is 8 pixels for absolute values.
72+
*/
73+
public function setBarScale($barScale = 'a', $spaceBetweenBars = '4',$spaceBetweenGroups = '8')
74+
{
75+
$this->setProperty('chbh', $this->encodeData(array($barScale, $spaceBetweenBars,$spaceBetweenGroups), ','));
76+
}
77+
/**
78+
* @brief Sets colors for each data set.
79+
*
80+
* This function allows you to specify colors for each individual slice of the chart or to specify a
81+
* color gradient. Usage:
82+
* - One color one bar: addColors(array($colorBar1, .., $colorBarN)). If there are less colors than
83+
* bars, colors will be repeated
84+
*
85+
* @param $colors Array Specifies colors using a 6-character string of hexadecimal values,
86+
* plus two optional transparency values, in the format RRGGBB[AA]
87+
*/
88+
public function addColors($colors)
89+
{
90+
$this->setProperty('chco', $this->encodeData($colors, "|"), true, ",");
91+
}
92+
}

0 commit comments

Comments
 (0)