From 7559cfadf6d81bb9e2a3ba328be314aceb816026 Mon Sep 17 00:00:00 2001 From: goat1000 Date: Wed, 3 Aug 2016 07:12:34 +0100 Subject: [PATCH] Bug fixes in 2.23.1 --- CHANGES.txt | 9 +++++++++ README.txt | 4 ++-- SVGGraphJavascript.php | 3 ++- SVGGraphMultiGraph.php | 3 ++- SVGGraphRadarGraph.php | 15 +++++++++++---- SVGGraphStructuredData.php | 7 +++++-- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 261324e..c906ca1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,12 @@ +Version 2.23.1 (03/08/2016) +-------------- +- Added datetime_key_format option. +- Fixed per-dataset stroke_width with a 0 value. +- Fixed default structure missing values with string keys when main key is 0. +- Fixed error when using datetime keys with multiple unstructured datasets. +- Fixed legend autohide not working when no other Javascript options enabled. +- Fixed error in radar graphs when given some dual-Y axis settings. + Version 2.23 (22/06/2016) ------------ - Added date/time axis. diff --git a/README.txt b/README.txt index fa371c8..2bf0447 100644 --- a/README.txt +++ b/README.txt @@ -1,5 +1,5 @@ -SVGGraph Library version 2.23 -============================= +SVGGraph Library version 2.23.1 +=============================== This library provides PHP classes and functions for easily creating SVG graphs from data. As of version 2.0, SVGGraph works with PHP 5 only - diff --git a/SVGGraphJavascript.php b/SVGGraphJavascript.php index 287213e..9a34498 100644 --- a/SVGGraphJavascript.php +++ b/SVGGraphJavascript.php @@ -1,6 +1,6 @@ AddFunction('init'); $this->AddFunction('getE'); $this->AddFunction('setattr'); + $this->AddFunction('finditem'); $this->InsertVariable('initfns', NULL, 'autoHide'); $fn = <<values = new SVGGraphStructuredData($new_data, $force_assoc, - $datetime_keys, null, false, $int_keys, null); + $datetime_keys, null, false, $int_keys, null, true); } $this->datasets = count($this->values); } diff --git a/SVGGraphRadarGraph.php b/SVGGraphRadarGraph.php index 6fe7463..382177c 100644 --- a/SVGGraphRadarGraph.php +++ b/SVGGraphRadarGraph.php @@ -629,7 +629,8 @@ protected function XAxisTextPositions(&$points, $xoff, $yoff, $angle, $inside) $position['transform'] = "rotate($angle,$rcx,$rcy)"; } // $c == -1 is particular too : XAxis text can bump YAxis texts - $y_nudge = $this->GetFirst($this->axis_font_size_v, + $y_nudge = $this->GetFirst( + $this->ArrayOption($this->axis_font_size_v, 0), $this->axis_font_size) / 2; if($c == -1 && $this->start_angle % 360 == 90) { $position['y'] -= $y_nudge; @@ -682,9 +683,15 @@ protected function YAxisTextPositions(&$points, $xoff, $yoff, $angle, $inside, $ { $positions = array(); $labels = ''; - $font_size = $this->GetFirst($this->axis_font_size_v, $this->axis_font_size); - $font_adjust = $this->GetFirst($this->axis_font_adjust_v, $this->axis_font_adjust); - $text_space = $this->GetFirst($this->axis_text_space_v, $this->axis_text_space); + $font_size = $this->GetFirst( + $this->ArrayOption($this->axis_font_size_v, $axis_no), + $this->axis_font_size); + $font_adjust = $this->GetFirst( + $this->ArrayOption($this->axis_font_adjust_v, $axis_no), + $this->axis_font_adjust); + $text_space = $this->GetFirst( + $this->ArrayOption($this->axis_text_space_v, $axis_no), + $this->axis_text_space); $c = cos($this->arad); $s = sin($this->arad); $a = $this->arad + ($s * $c > 0 ? - M_PI_2 : M_PI_2); diff --git a/SVGGraphStructuredData.php b/SVGGraphStructuredData.php index 3a7ca5e..43f6c70 100644 --- a/SVGGraphStructuredData.php +++ b/SVGGraphStructuredData.php @@ -41,7 +41,8 @@ class SVGGraphStructuredData implements Countable, ArrayAccess, Iterator { public $error = null; public function __construct(&$data, $force_assoc, $datetime_keys, - $structure, $repeated_keys, $integer_keys, $requirements) + $structure, $repeated_keys, $integer_keys, $requirements, + $rekey_done = FALSE) { if(!is_null($structure) && !empty($structure)) { // structure provided, is it valid? @@ -111,13 +112,15 @@ public function __construct(&$data, $force_assoc, $datetime_keys, // reindex the array to 0, 1, 2, ... $this->data = array_values($this->data); if($datetime_keys) { - if($this->Rekey('SVGGraphDateConvert')) { + if($rekey_done || $this->Rekey('SVGGraphDateConvert')) { $this->datetime = true; $this->assoc = false; } else { $this->error = 'Too many date/time conversion errors'; return; } + $GLOBALS['SVGGraphFieldSortField'] = $this->key_field; + usort($this->data, 'SVGGraphFieldSort'); } } elseif(!is_null($this->key_field)) { // if not associative, sort by key field