summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <tpearson@raptorengineeringinc.com>2015-12-13 00:09:38 -0600
committerTimothy Pearson <tpearson@raptorengineeringinc.com>2016-01-11 02:15:30 -0600
commit873907039978558c1b0e99481eaa6d72131b520f (patch)
treebbdd87811508ceb3fb384962569f6e35305f372b
parent63fc2a61d44e2ea95ebab72f88ca44a6416d6979 (diff)
downloadzetacomponents-graph-radar-bound-fill.zip
zetacomponents-graph-radar-bound-fill.tar.gz
Add option to bound fill between the current dataset and the previous dataset on radar plotsradar-bound-fill
-rw-r--r--src/charts/radar.php19
-rw-r--r--src/datasets/base.php9
-rw-r--r--src/interfaces/radar_renderer.php2
-rw-r--r--src/renderer/2d.php20
4 files changed, 46 insertions, 4 deletions
diff --git a/src/charts/radar.php b/src/charts/radar.php
index b7bd820..c1f52e1 100644
--- a/src/charts/radar.php
+++ b/src/charts/radar.php
@@ -296,6 +296,7 @@ class ezcGraphRadarChart extends ezcGraphChart
// Display data
$this->elements['axis']->position = ezcGraph::TOP;
+ $prevDataSetPoints = array();
foreach ( $this->data as $datasetName => $data )
{
--$nr;
@@ -315,8 +316,11 @@ class ezcGraphRadarChart extends ezcGraphChart
$fillColor = null;
}
+ $prevDataSetBounded = $data->boundFillToPreviousDataSet;
+
// Draw lines for dataset
$lastPoint = false;
+ $lastInnerPoint = false;
foreach ( $data as $key => $value )
{
$point = new ezcGraphCoordinate(
@@ -336,6 +340,16 @@ class ezcGraphRadarChart extends ezcGraphChart
);
// */
+ if ($prevDataSetBounded && array_key_exists($key, $prevDataSetPoints)) {
+ $innerPoint = $prevDataSetPoints[$key];
+ }
+ else {
+ $innerPoint = new ezcGraphCoordinate(
+ 0,
+ 0
+ );
+ }
+
$renderer->drawRadarDataLine(
$boundings,
new ezcGraphContext( $datasetName, $key, $data->url[$key] ),
@@ -343,6 +357,8 @@ class ezcGraphRadarChart extends ezcGraphChart
clone $center,
( $lastPoint === false ? $point : $lastPoint ),
$point,
+ $innerPoint,
+ ( $lastInnerPoint === false ? $innerPoint : $lastInnerPoint ),
$nr,
$count,
$data->symbol[$key],
@@ -351,7 +367,10 @@ class ezcGraphRadarChart extends ezcGraphChart
$this->options->lineThickness
);
+ $prevDataSetPoints[$key] = $point;
+
$lastPoint = $point;
+ $lastInnerPoint = $innerPoint;
}
}
}
diff --git a/src/datasets/base.php b/src/datasets/base.php
index 219b3f9..5dc9ae6 100644
--- a/src/datasets/base.php
+++ b/src/datasets/base.php
@@ -40,6 +40,10 @@
* @property mixed $fillLine
* Interpretation depends on underlying chart type
* @see chart type fillLines option for details
+ * @property bool $boundFillToPreviousDataSet
+ * Only fill the region between the current data set
+ * and the previous data set. Only works for radar
+ * plots at this time. @see $fillLine property.
* @property int $displayType
* Display type of chart data
* @property string $url
@@ -114,6 +118,7 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable
$this->properties['highlight']->default = false;
$this->properties['fillLine'] = false;
+ $this->properties['boundFillToPreviousDataSet'] = false;
}
/**
@@ -168,6 +173,10 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable
: (int) $propertyValue );
break;
+ case 'boundFillToPreviousDataSet':
+ $this->properties[$propertyName] = $propertyValue;
+ break;
+
default:
throw new ezcBasePropertyNotFoundException( $propertyName );
break;
diff --git a/src/interfaces/radar_renderer.php b/src/interfaces/radar_renderer.php
index cb2697b..016c857 100644
--- a/src/interfaces/radar_renderer.php
+++ b/src/interfaces/radar_renderer.php
@@ -58,6 +58,8 @@ interface ezcGraphRadarRenderer
ezcGraphCoordinate $center,
ezcGraphCoordinate $start,
ezcGraphCoordinate $end,
+ ezcGraphCoordinate $fillStart,
+ ezcGraphCoordinate $fillEnd,
$dataNumber = 1,
$dataCount = 1,
$symbol = ezcGraph::NO_SYMBOL,
diff --git a/src/renderer/2d.php b/src/renderer/2d.php
index 9793e0a..3fd7812 100644
--- a/src/renderer/2d.php
+++ b/src/renderer/2d.php
@@ -884,6 +884,8 @@ class ezcGraphRenderer2d
ezcGraphCoordinate $center,
ezcGraphCoordinate $start,
ezcGraphCoordinate $end,
+ ezcGraphCoordinate $fillStart,
+ ezcGraphCoordinate $fillEnd,
$dataNumber = 1,
$dataCount = 1,
$symbol = ezcGraph::NO_SYMBOL,
@@ -905,6 +907,18 @@ class ezcGraphRenderer2d
$end->x * 2 * M_PI,
$end->y
);
+ $fillStart = $this->getCoordinateFromAngleAndRadius(
+ $boundings,
+ $center,
+ $fillStart->x * 2 * M_PI,
+ $fillStart->y
+ );
+ $fillEnd = $this->getCoordinateFromAngleAndRadius(
+ $boundings,
+ $center,
+ $fillEnd->x * 2 * M_PI,
+ $fillEnd->y
+ );
// Fill line
if ( $fillColor !== null )
@@ -913,10 +927,8 @@ class ezcGraphRenderer2d
array(
$start,
$end,
- new ezcGraphCoordinate(
- $boundings->x0 + $center->x,
- $boundings->y0 + $center->y
- ),
+ $fillStart,
+ $fillEnd
),
$fillColor,
true
OpenPOWER on IntegriCloud