Graph: ezcGraphChartElementDateAxis
[ ]
[ Gallery ]
[ ]
[ ]
[ ]
[ ]
Class: ezcGraphChartElementDateAxis
|
Class to represent date axis. [
source]
Axis elements represent the axis in a bar, line or radar chart. They are chart elements (ezcGraphChartElement) extending from ezcGraphChartElementAxis, where additional formatting options can be found. You should generally use the axis, which matches your input data best, so that the automatic chart layouting works best. Aavailable axis types are:
- ezcGraphChartElementDateAxis
- ezcGraphChartElementLabeledAxis
- ezcGraphChartElementLogarithmicalAxis
- ezcGraphChartElementNumericAxis
Date axis will try to find a "nice" interval based on the values on the x axis. If non numeric values are given, ezcGraphChartElementDateAxis will convert them to timestamps using PHPs strtotime function.
It is always possible to set start date, end date and the interval manually by yourself.
The $dateFormat option provides an additional way of formatting the labels used on the axis. The options from the parent class $formatString and $labelCallback do still apply.
You may use a date axis like in the following example:
1. $graph = new ezcGraphLineChart();
2. $graph->options->fillLines = 210;
3. $graph->title = 'Concurrent requests';
4. $graph->legend = false;
5.
6. $graph->xAxis = new ezcGraphChartElementDateAxis();
7.
8. // Add data
9. $graph->data['Machine 1'] = new ezcGraphArrayDataSet( array(
10. '8:00' => 3241,
11. '8:13' => 934,
12. '8:24' => 1201,
13. '8:27' => 1752,
14. '8:51' => 123,
15. ) );
16. $graph->data['Machine 2'] = new ezcGraphArrayDataSet( array(
17. '8:05' => 623,
18. '8:12' => 2103,
19. '8:33' => 543,
20. '8:43' => 2034,
21. '8:59' => 3410,
22. ) );
23.
24. $graph->data['Machine 1']->symbol = ezcGraph::BULLET;
25. $graph->data['Machine 2']->symbol = ezcGraph::BULLET;
26.
27. $graph->render( 400, 150, 'tutorial_axis_datetime.svg' );
Parents
ezcBaseOptions
|
--ezcGraphChartElement
|
--ezcGraphChartElementAxis
|
--ezcGraphChartElementDateAxis
Constants
DECADE
= 315360000
|
|
MAJOR_COUNT
= 10
|
Constant used for calculation of automatic definition of major scaling steps |
MONTH
= 2629800
|
|
YEAR
= 31536000
|
|
Properties
|
string |
read/write
|
$dateFormat
Format of date string Like http://php.net/date |
|
float |
read/write
|
$endDate
End date used to display on axis. |
|
float |
read/write
|
$interval
Time interval between steps on axis. |
|
float |
read/write
|
$startDate
Starting date used to display on axis. |
Member Variables
|
protected int |
$maxValue
= false
Maximum inserted date |
|
protected int |
$minValue
= false
Minimum inserted date |
|
protected array |
$predefinedIntervals
= array( // Second 1 => 'H:i.s', // Ten seconds 10 => 'H:i.s', // Thirty seconds 30 => 'H:i.s', // Minute 60 => 'H:i', // Ten minutes 600 => 'H:i', // Half an hour 1800 => 'H:i', // Hour 3600 => 'H:i', // Four hours 14400 => 'H:i', // Six hours 21600 => 'H:i', // Half a day 43200 => 'd.m a', // Day 86400 => 'd.m', // Week 604800 => 'W', // Month self::MONTH => 'M y', // Year self::YEAR => 'Y', // Decade self::DECADE => 'Y', )
Nice time intervals to used if there is no user defined interval |
Inherited Member Variables
From
ezcGraphChartElementAxis:
From
ezcBaseOptions:
Method Summary
Inherited Methods
From
ezcGraphChartElementAxis :
From
ezcGraphChartElement :
From
ezcBaseOptions :
Methods
addData
void addData(
$values )
Add data for this axis
Parameters
| Name |
Type |
Description |
$values |
array |
Value which will be displayed on this axis |
Redefinition of
calculateAxisBoundings
void calculateAxisBoundings(
)
Calculate axis bounding values on base of the assigned values
Redefinition of
calculateInterval
void calculateInterval(
int
$min, int
$max )
Calculate nice time interval
Use the best fitting time interval defined in class property array predefinedIntervals.
Parameters
| Name |
Type |
Description |
$min |
int |
Start time |
$max |
int |
End time |
calculateLowerNiceDate
int calculateLowerNiceDate(
int
$min, int
$interval )
Calculate lower nice date
Calculates a date which is earlier or equal to the given date, and is divisible by the given interval.
Parameters
| Name |
Type |
Description |
$min |
int |
Date |
$interval |
int |
Interval |
calculateMaximum
void calculateMaximum(
mixed
$min, mixed
$max )
Calculate end date
Use calculateLowerNiceDate to get a date later or equal date then the maximum date to use it as the end date for the axis depending on the selected interval.
Parameters
| Name |
Type |
Description |
$min |
mixed |
Minimum date |
$max |
mixed |
Maximum date |
calculateMinimum
void calculateMinimum(
mixed
$min, mixed
$max )
Calculate start date
Use calculateLowerNiceDate to get a date earlier or equal date then the minimum date to use it as the start date for the axis depending on the selected interval.
Parameters
| Name |
Type |
Description |
$min |
mixed |
Minimum date |
$max |
mixed |
Maximum date |
ensureTimestamp
int ensureTimestamp(
mixed
$value )
Ensure proper timestamp
Takes a mixed value from datasets, like timestamps, or strings describing some time and converts it to a timestamp.
Parameters
| Name |
Type |
Description |
$value |
mixed |
|
getCoordinate
float getCoordinate(
float
$value )
Get coordinate for a dedicated value on the chart
Parameters
| Name |
Type |
Description |
$value |
float |
Value to determine position for |
Redefinition of
getLabel
string getLabel(
integer
$step )
Get label for a dedicated step on the axis
Parameters
| Name |
Type |
Description |
$step |
integer |
Number of step |
Redefinition of
getLabelFromTimestamp
string getLabelFromTimestamp(
int
$time, int
$step )
Get label for timestamp
Parameters
| Name |
Type |
Description |
$time |
int |
|
$step |
int |
|
getMajorStepCount
integer getMajorStepCount(
)
Return count of major steps
Redefinition of
getMinorStepCount
integer getMinorStepCount(
)
Return count of minor steps
Redefinition of
getSteps
array( getSteps(
)
Return array of steps on this axis
Redefinition of
isZeroStep
bool isZeroStep(
int
$step )
Is zero step
Returns true if the given step is the one on the initial axis position
Parameters
| Name |
Type |
Description |
$step |
int |
Number of step |
Redefinition of
Last updated: Mon, 21 Dec 2009