Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenaka Moorthi <benaka.moorthi@gmail.com>2013-08-14 10:40:21 +0400
committerBenaka Moorthi <benaka.moorthi@gmail.com>2013-08-14 10:40:21 +0400
commitc732114df3576faf297e38a7bf04ff9092947905 (patch)
tree93706c39d2a84f8f54a0554c79a4e5e43aaac89b /core/Visualization
parentb33ce4ca0942167e058d02006a94ababbb949bac (diff)
Refs #4041, removed Visualizations\Chart\* classes and moved Visualization\Chart to CoreVisualizations plugin and removed graph_width/graph_height visualization properties in favor of CSS solution.
Diffstat (limited to 'core/Visualization')
-rw-r--r--core/Visualization/Chart.php187
-rw-r--r--core/Visualization/Chart/Evolution.php43
-rw-r--r--core/Visualization/Chart/Pie.php54
-rw-r--r--core/Visualization/Chart/VerticalBar.php45
4 files changed, 0 insertions, 329 deletions
diff --git a/core/Visualization/Chart.php b/core/Visualization/Chart.php
deleted file mode 100644
index b580f78e1c..0000000000
--- a/core/Visualization/Chart.php
+++ /dev/null
@@ -1,187 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- * @category Piwik
- * @package Piwik
- */
-namespace Piwik\Visualization;
-
-use Piwik\Piwik;
-use Piwik\Common;
-use Piwik\View\ViewInterface;
-
-/**
- * Generates the data in the Open Flash Chart format, from the given data.
- *
- * @package Piwik
- * @subpackage Piwik_Visualization
- */
-abstract class Chart implements ViewInterface
-{
-
- // the data kept here conforms to the jqplot data layout
- // @see http://www.jqplot.com/docs/files/jqPlotOptions-txt.html
- protected $series = array();
- protected $data = array();
- protected $axes = array();
- protected $tooltip = array();
- protected $seriesPicker = array();
-
- // other attributes (not directly used for jqplot)
- protected $maxValue;
- protected $yUnit = '';
- protected $displayPercentageInTooltip = true;
- protected $xSteps = 2;
-
- /**
- * Whether to show every x-axis tick or only every other one.
- */
- protected $showAllTicks = false;
-
- public function setAxisXLabels(&$xLabels)
- {
- $this->axes['xaxis']['ticks'] = & $xLabels;
- }
-
- public function setAxisXOnClick(&$onClick)
- {
- $this->axes['xaxis']['onclick'] = & $onClick;
- }
-
- public function setAxisYValues(&$values)
- {
- foreach ($values as $label => &$data) {
- $this->series[] = array(
- // unsanitize here is safe since data gets outputted as JSON, not HTML
- // NOTE: this is a quick fix for a double-encode issue. if this file is refactored,
- // this fix can probably be removed (or at least made more understandable).
- 'label' => Common::unsanitizeInputValue($label),
- 'internalLabel' => $label
- );
-
- array_walk($data, create_function('&$v', '$v = (float)$v;'));
- $this->data[] = & $data;
- }
- }
-
- protected function addTooltipToValue($seriesIndex, $valueIndex, $tooltipTitle, $tooltipText)
- {
- $this->tooltip[$seriesIndex][$valueIndex] = array($tooltipTitle, $tooltipText);
- }
-
- public function setAxisYUnit($yUnit)
- {
- $yUnits = array();
- for ($i = 0; $i < count($this->data); $i++) {
- $yUnits[] = $yUnit;
- }
- $this->setAxisYUnits($yUnits);
- }
-
- public function setAxisYUnits($yUnits)
- {
- // generate an axis config for each unit
- $axesIds = array();
- // associate each series with the appropriate axis
- $seriesAxes = array();
- // units for tooltips
- $seriesUnits = array();
- foreach ($yUnits as $unit) {
- // handle axes ids: first y[]axis, then y[2]axis, y[3]axis...
- $nextAxisId = empty($axesIds) ? '' : count($axesIds) + 1;
-
- $unit = $unit ? $unit : '';
- if (!isset($axesIds[$unit])) {
- $axesIds[$unit] = array('id' => $nextAxisId, 'unit' => $unit);
- $seriesAxes[] = 'y' . $nextAxisId . 'axis';
- } else {
- // reuse existing axis
- $seriesAxes[] = 'y' . $axesIds[$unit]['id'] . 'axis';
- }
- $seriesUnits[] = $unit;
- }
-
- // generate jqplot axes config
- foreach ($axesIds as $axis) {
- $axisKey = 'y' . $axis['id'] . 'axis';
- $this->axes[$axisKey]['tickOptions']['formatString'] = '%s' . $axis['unit'];
- }
-
- $this->tooltip['yUnits'] = $seriesUnits;
-
- // add axis config to series
- foreach ($seriesAxes as $i => $axisName) {
- $this->series[$i]['yaxis'] = $axisName;
- }
- }
-
- public function setAxisYLabels($labels)
- {
- foreach ($this->series as &$series) {
- $label = $series['internalLabel'];
- if (isset($labels[$label])) {
- $series['label'] = $labels[$label];
- }
- }
- }
-
- public function setSelectableColumns($selectableColumns, $multiSelect = true)
- {
- $this->seriesPicker['selectableColumns'] = $selectableColumns;
- $this->seriesPicker['multiSelect'] = $multiSelect;
- }
-
- public function setDisplayPercentageInTooltip($display)
- {
- $this->displayPercentageInTooltip = $display;
- }
-
- public function setXSteps($steps)
- {
- $this->xSteps = $steps;
- }
-
- /**
- * Show every x-axis tick instead of just every other one.
- */
- public function showAllTicks()
- {
- $this->showAllTicks = true;
- }
-
- public function render()
- {
- Piwik::overrideCacheControlHeaders();
-
- // See http://www.jqplot.com/docs/files/jqPlotOptions-txt.html
- $data = array(
- 'params' => array(
- 'axes' => &$this->axes,
- 'series' => &$this->series
- ),
- 'data' => &$this->data,
- 'tooltip' => &$this->tooltip,
- 'seriesPicker' => &$this->seriesPicker
- );
-
- Piwik_PostEvent('Visualization_Chart.render', array(&$data));
- return Common::json_encode($data);
- }
-
- public function customizeChartProperties()
- {
- // x axis labels with steps
- if (isset($this->axes['xaxis']['ticks'])) {
- foreach ($this->axes['xaxis']['ticks'] as $i => &$xLabel) {
- $this->axes['xaxis']['labels'][$i] = $xLabel;
- if (!$this->showAllTicks && ($i % $this->xSteps) != 0) {
- $xLabel = ' ';
- }
- }
- }
- }
-}
diff --git a/core/Visualization/Chart/Evolution.php b/core/Visualization/Chart/Evolution.php
deleted file mode 100644
index 0ad55acb40..0000000000
--- a/core/Visualization/Chart/Evolution.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- * @category Piwik
- * @package Piwik
- */
-
-namespace Piwik\Visualization\Chart;
-
-use Piwik\Visualization\Chart;
-
-/**
- * Customize the Evolution chart style
- *
- * @package Piwik
- * @subpackage Piwik_Visualization
- */
-class Evolution extends Chart
-{
- const SERIES_COLOR_COUNT = 8;
-
- public function customizeChartProperties()
- {
- parent::customizeChartProperties();
-
- // if one column is a percentage we set the grid accordingly
- // note: it is invalid to plot a percentage dataset along with a numeric dataset
- if ($this->yUnit == '%'
- && $this->maxValue > 90
- ) {
- $this->axes['yaxis']['ticks'] = array(0, 50, 100);
- }
- }
-
- public function setSelectableRows($selectableRows)
- {
- $this->seriesPicker['selectableRows'] = $selectableRows;
- }
-} \ No newline at end of file
diff --git a/core/Visualization/Chart/Pie.php b/core/Visualization/Chart/Pie.php
deleted file mode 100644
index e0f4a37857..0000000000
--- a/core/Visualization/Chart/Pie.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- * @category Piwik
- * @package Piwik
- */
-
-namespace Piwik\Visualization\Chart;
-
-use Piwik\Visualization\Chart;
-
-/**
- * Customize & set values for the Flash Pie chart
- *
- * @package Piwik
- * @subpackage Piwik_Visualization
- */
-class Pie extends Chart
-{
- function customizeChartProperties()
- {
- if (count($this->data) == 0) {
- return;
- }
-
- // make sure we only have one series
- $series = & $this->series[0];
- $this->series = array(&$series);
-
- $data = & $this->data[0];
- $this->data = array(&$data);
-
- // we never plot empty pie slices (eg. visits by server time pie chart)
- foreach ($data as $i => $value) {
- if ($value <= 0) {
- unset($data[$i]);
- unset($this->axes['xaxis']['ticks'][$i]);
- }
- }
- $data = array_values($data);
- $this->axes['xaxis']['ticks'] = array_values($this->axes['xaxis']['ticks']);
-
- // prepare percentages for tooltip
- $sum = array_sum($data);
- foreach ($data as $i => $value) {
- $value = (float)$value;
- $this->tooltip['percentages'][0][$i] = round(100 * $value / $sum);
- }
- }
-}
diff --git a/core/Visualization/Chart/VerticalBar.php b/core/Visualization/Chart/VerticalBar.php
deleted file mode 100644
index c6ec8f08d3..0000000000
--- a/core/Visualization/Chart/VerticalBar.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- * @category Piwik
- * @package Piwik
- */
-
-namespace Piwik\Visualization\Chart;
-
-use Piwik\Visualization\Chart;
-
-/**
- * Customize & set values for the Vertical bar chart
- *
- * @package Piwik
- * @subpackage Piwik_Visualization
- */
-class VerticalBar extends Chart
-{
- public function customizeChartProperties()
- {
- parent::customizeChartProperties();
-
- if ($this->displayPercentageInTooltip) {
- foreach ($this->data as $seriesIndex => &$series) {
- $sum = array_sum($series);
-
- foreach ($series as $valueIndex => $value) {
- $value = (float)$value;
-
- $percentage = 0;
- if ($sum > 0) {
- $percentage = round(100 * $value / $sum);
- }
-
- $this->tooltip['percentages'][$seriesIndex][$valueIndex] = $percentage;
- }
- }
- }
- }
-}