Skip to content

Commit

Permalink
Added gantt_today_date option.
Browse files Browse the repository at this point in the history
  • Loading branch information
goat1000 committed Apr 29, 2022
1 parent a5ccad1 commit 6653f63
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
5 changes: 4 additions & 1 deletion AxisLog.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (C) 2013-2021 Graham Breach
* Copyright (C) 2013-2022 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 Expand Up @@ -201,6 +201,9 @@ public function getGridSubdivisions($min_space, $min_unit, $start, $fixed)
public function measureUnits($pos, $u)
{
$i = Coords::parseValue($pos);
if(!is_numeric($i['value']))
throw new \Exception("Unable to measure $u units from '{$i['value']}'");

$start_pos = $this->position($i['value']);
$end_pos = $this->position($i['value'] + $u);
return $end_pos - $start_pos;
Expand Down
8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 3.14 (02/05/2022)
------------
- Added Gantt chart.
- Added automatic graph height option.
- Added support for best-fit lines on bar and line graphs.
- Added support for using coordinates for legend position.
- Added block_position_markers option.

Version 3.13.1 (11/03/2022)
--------------
- Fixed deprecation warning messages displayed by PHP 8.1.
Expand Down
13 changes: 11 additions & 2 deletions GanttChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,19 @@ private function getDayShading()
*/
protected function getToday()
{
$today = new \DateTime();
$today = $t_i = null;
$when = $this->getOption('gantt_today_date');
if($when) {
$t_i = Graph::dateConvert($when);
if($t_i !== null)
$today = new \DateTime('@' . $t_i);
}
if($today === null) {
$today = new \DateTime();
$t_i = $today->format('U');
}

// check that today is on the chart
$t_i = $today->format('U');
$axis = $this->getAxis('x', null);
$a_len = $axis->getLength();
$start_time = $axis->value(0);
Expand Down
6 changes: 3 additions & 3 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SVGGraph Library version 3.13.1
===============================
SVGGraph Library version 3.14
=============================

This library provides PHP classes and functions for easily creating SVG
graphs from data. Version 3.0 of SVGGraph requires at least PHP 5.4 - if
Expand Down Expand Up @@ -122,7 +122,7 @@ At the moment these types of graph are supported by SVGGraph:
There are also these graphs that are really hard to describe:

FloatingBarGraph; HorizontalFloatingBarGraph; BubbleGraph;
BoxAndWhiskerGraph; PopulationPyramid; CandlestickGraph.
BoxAndWhiskerGraph; PopulationPyramid; CandlestickGraph; GanttChart.

Using SVGGraph
==============
Expand Down
2 changes: 1 addition & 1 deletion StructuredDataItem.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (C) 2019 Graham Breach
* Copyright (C) 2019-2022 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
1 change: 1 addition & 0 deletions svggraph.ini
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ gantt_today_colour = 'red'
gantt_today_opacity = 1
gantt_today_width = 2
gantt_today_dash = '3'
gantt_today_date = null
gantt_group_corner_width = 6
gantt_group_corner_height = 6
gantt_group_colour = 'fillColour/saturation(60%)/brightness(140%)'
Expand Down

0 comments on commit 6653f63

Please sign in to comment.