Skip to content

Commit

Permalink
Final fixes for version 2.23
Browse files Browse the repository at this point in the history
  • Loading branch information
goat1000 committed Jun 22, 2016
1 parent f1c939f commit 2661a96
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
8 changes: 8 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,11 @@
Version 2.23 (22/06/2016)
------------
- Added date/time axis.
- Added callback function support to logarithmic axis.
- Added exception_throw option to disable catching exceptions.
- Fixed axis callback functions not working with associative data.
- Fixed legend display for line graphs when marker size is 0.

Version 2.22 (05/05/2016)
------------
- Added support for legend entries from structured data.
Expand Down
2 changes: 1 addition & 1 deletion README.txt
@@ -1,4 +1,4 @@
SVGGraph Library version 2.22
SVGGraph Library version 2.23
=============================

This library provides PHP classes and functions for easily creating SVG
Expand Down
2 changes: 1 addition & 1 deletion SVGGraph.php
Expand Up @@ -19,7 +19,7 @@
* For more information, please contact <graham@goat1000.com>
*/

define('SVGGRAPH_VERSION', 'SVGGraph 2.22');
define('SVGGRAPH_VERSION', 'SVGGraph 2.23');

require_once 'SVGGraphColours.php';

Expand Down
18 changes: 8 additions & 10 deletions SVGGraphAxisDateTime.php
Expand Up @@ -134,6 +134,11 @@ public function __construct($length, $max_val, $min_val, $min_space,
$start_date = new DateTime('@' . $min_val);
$end_date = new DateTime('@' . $max_val);

// set the week start day before finding divisions
if(isset($options['datetime_week_start']) &&
isset(AxisDateTime::$weekdays[$options['datetime_week_start']]))
AxisDateTime::$week_start = $options['datetime_week_start'];

if(!empty($fixed_division)) {
list($units, $count) = AxisDateTime::ParseFixedDivisions($fixed_division,
$min_val, $max_val, $length);
Expand All @@ -154,10 +159,6 @@ public function __construct($length, $max_val, $min_val, $min_space,
}

} else {
// set the week start day before finding divisions
if(isset($options['datetime_week_start']) &&
isset(AxisDateTime::$weekdays[$options['datetime_week_start']]))
AxisDateTime::$week_start = $options['datetime_week_start'];

// find a sensible division
$div = AxisDateTime::FindDivision($start_date, $end_date, $length,
Expand Down Expand Up @@ -204,7 +205,7 @@ private static function FindDivision($start, $end, $length, $min_space,
{
$max_divisions = floor($length / $min_space);
$duration_s = $end->format('U') - $start->format('U');
$avg_duration = (int)ceil($duration_s / $max_divisions);
$avg_duration = ceil($duration_s / $max_divisions);

$choice = NULL;
$divisions = 1;
Expand All @@ -224,7 +225,7 @@ private static function FindDivision($start, $end, $length, $min_space,
$div_duration = $d[1] * AxisDateTime::$unit_sizes[$d[0]];

if($div_duration >= $avg_duration) {
$divisions = (int)floor($duration_s / $div_duration);
$divisions = floor($duration_s / $div_duration);
$unit = $d[0];
$nunits = $d[1];

Expand Down Expand Up @@ -391,11 +392,8 @@ private static function EndTime($time, $unit, $n, $start)
$seconds = $seconds - ($seconds % $n) + $n - 1;
$datetime = clone $start;
$datetime->modify("+{$seconds} second");
} else {
$s = $datetime->format('s');
$newtime = $datetime->format(sprintf('H:i:%02d', $s));
$datetime->modify($newtime);
}
// if $n == 1, no modifications are required
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion SVGGraphAxisFixedDoubleEnded.php
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (C) 2013-2015 Graham Breach
* Copyright (C) 2013-2016 Graham Breach
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand Down

0 comments on commit 2661a96

Please sign in to comment.