Author: kn
Date: Wed Aug 1 12:23:32 2007
New Revision: 5796
Log:
- Fixed bug #11207: Missing URL property for legend, or missing legend, may
cause PHP notice
Added:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testLineChartImageMapNoLegend.html
(with props)
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testLineChartImageMapOnlyDataPoint.html
(with props)
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testPieChartSvgLinkingNoLegend.svg
(with props)
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testPieChartSvgLinkingOnlyDataPoint.svg
(with props)
Modified:
trunk/Graph/ChangeLog
trunk/Graph/src/tools.php
trunk/Graph/tests/tools_test.php
Modified: trunk/Graph/ChangeLog
==============================================================================
--- trunk/Graph/ChangeLog [iso-8859-1] (original)
+++ trunk/Graph/ChangeLog [iso-8859-1] Wed Aug 1 12:23:32 2007
@@ -3,6 +3,8 @@
- Fixed bug #11107: Floating point inaccuracies caused missing grid in line
chart
+- Fixed bug #11207: Missing URL property for legend, or missing legend, may
+ cause PHP notice
1.1 - Monday 02 July 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Modified: trunk/Graph/src/tools.php
==============================================================================
--- trunk/Graph/src/tools.php [iso-8859-1] (original)
+++ trunk/Graph/src/tools.php [iso-8859-1] Wed Aug 1 12:23:32 2007
@@ -46,28 +46,31 @@
$imageMap = sprintf( "<map name=\"%s\">\n", $name );
// Iterate over legends elements
- foreach ( $elements['legend'] as $objectName => $polygones )
+ if ( isset( $elements['legend'] ) )
{
- $url = $elements['legend_url'][$objectName];
+ foreach ( $elements['legend'] as $objectName => $polygones )
+ {
+ $url = $elements['legend_url'][$objectName];
- if ( empty( $url ) )
- {
- continue;
- }
-
- foreach ( $polygones as $shape => $polygone )
- {
- $coordinateString = '';
- foreach ( $polygone as $coordinate )
+ if ( empty( $url ) )
{
- $coordinateString .= sprintf( '%d,%d,', $coordinate->x,
$coordinate->y );
+ continue;
}
- $imageMap .= sprintf( "\t<area shape=\"poly\" coords=\"%s\"
href=\"%s\" alt=\"%s\" />\n",
- substr( $coordinateString, 0, -1 ),
- $url,
- $objectName
- );
+ foreach ( $polygones as $shape => $polygone )
+ {
+ $coordinateString = '';
+ foreach ( $polygone as $coordinate )
+ {
+ $coordinateString .= sprintf( '%d,%d,',
$coordinate->x, $coordinate->y );
+ }
+
+ $imageMap .= sprintf( "\t<area shape=\"poly\"
coords=\"%s\" href=\"%s\" alt=\"%s\" />\n",
+ substr( $coordinateString, 0, -1 ),
+ $url,
+ $objectName
+ );
+ }
}
}
@@ -152,21 +155,24 @@
}
// Link legend elements
- foreach ( $elements['legend'] as $objectName => $ids )
+ if ( isset( $elements['legend'] ) )
{
- $url = $elements['legend_url'][$objectName];
+ foreach ( $elements['legend'] as $objectName => $ids )
+ {
+ $url = $elements['legend_url'][$objectName];
- if ( empty( $url ) )
- {
- continue;
- }
+ if ( empty( $url ) )
+ {
+ continue;
+ }
- foreach ( $ids as $id )
- {
- $element = $xpath->query( '//[EMAIL PROTECTED] = \'' . $id .
'\']' )->item( 0 );
+ foreach ( $ids as $id )
+ {
+ $element = $xpath->query( '//[EMAIL PROTECTED] = \'' . $id
. '\']' )->item( 0 );
- $element->setAttribute( 'style', $element->getAttribute(
'style' ) . ' cursor: ' . $chart->driver->options->linkCursor . ';' );
- $element->setAttribute( 'onclick', "top.location = '{$url}'" );
+ $element->setAttribute( 'style', $element->getAttribute(
'style' ) . ' cursor: ' . $chart->driver->options->linkCursor . ';' );
+ $element->setAttribute( 'onclick', "top.location =
'{$url}'" );
+ }
}
}
Added:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testLineChartImageMapNoLegend.html
==============================================================================
Binary file - no diff available.
Propchange:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testLineChartImageMapNoLegend.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testLineChartImageMapNoLegend.html
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testLineChartImageMapOnlyDataPoint.html
==============================================================================
Binary file - no diff available.
Propchange:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testLineChartImageMapOnlyDataPoint.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testLineChartImageMapOnlyDataPoint.html
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testPieChartSvgLinkingNoLegend.svg
==============================================================================
Binary file - no diff available.
Propchange:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testPieChartSvgLinkingNoLegend.svg
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testPieChartSvgLinkingNoLegend.svg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testPieChartSvgLinkingOnlyDataPoint.svg
==============================================================================
Binary file - no diff available.
Propchange:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testPieChartSvgLinkingOnlyDataPoint.svg
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
trunk/Graph/tests/data/compare/ezcGraphToolsTest_testPieChartSvgLinkingOnlyDataPoint.svg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: trunk/Graph/tests/tools_test.php
==============================================================================
--- trunk/Graph/tests/tools_test.php [iso-8859-1] (original)
+++ trunk/Graph/tests/tools_test.php [iso-8859-1] Wed Aug 1 12:23:32 2007
@@ -129,6 +129,61 @@
);
}
+ public function testLineChartImageMapOnlyDataPoint()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+ $htmlFilename = $this->tempDir . __FUNCTION__ . '.html';
+
+ $chart = new ezcGraphLineChart();
+ $chart->palette = new ezcGraphPaletteBlack();
+ $chart->options->fillLines = 200;
+
+ $chart->data['Line 1'] = new ezcGraphArrayDataSet( array( 'sample 1'
=> 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' =>
1) );
+ $chart->data['Line 2'] = new ezcGraphArrayDataSet( array( 'sample 1'
=> 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' =>
613) );
+
+ $chart->data['Line 2']->url['sample 3'] =
'http://example.org/line_2/sample_3';
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font->path = $this->basePath . 'font.ttf';
+
+ $chart->render( 500, 200, $filename );
+
+ file_put_contents( $htmlFilename, ezcGraphTools::createImageMap(
$chart ) );
+
+ $this->compare(
+ $htmlFilename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ .
'.html'
+ );
+ }
+
+ public function testLineChartImageMapNoLegend()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+ $htmlFilename = $this->tempDir . __FUNCTION__ . '.html';
+
+ $chart = new ezcGraphLineChart();
+ $chart->legend = false;
+ $chart->palette = new ezcGraphPaletteBlack();
+ $chart->options->fillLines = 200;
+
+ $chart->data['Line 1'] = new ezcGraphArrayDataSet( array( 'sample 1'
=> 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' =>
1) );
+ $chart->data['Line 2'] = new ezcGraphArrayDataSet( array( 'sample 1'
=> 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' =>
613) );
+
+ $chart->data['Line 2']->url['sample 3'] =
'http://example.org/line_2/sample_3';
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font->path = $this->basePath . 'font.ttf';
+
+ $chart->render( 500, 200, $filename );
+
+ file_put_contents( $htmlFilename, ezcGraphTools::createImageMap(
$chart ) );
+
+ $this->compare(
+ $htmlFilename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ .
'.html'
+ );
+ }
+
public function testImageMapWithWrongDriver()
{
$filename = $this->tempDir . __FUNCTION__ . '.png';
@@ -196,24 +251,20 @@
);
}
- public function testPieChartSvgLinkingCustomCursor()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.svg';
-
- $chart = new ezcGraphPieChart();
- $chart->data['sample'] = new ezcGraphArrayDataSet( array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- ) );
-
- $chart->data['sample']->url = 'http://example.org/browsers';
- $chart->data['sample']->url['Mozilla'] =
'http://example.org/browsers/mozilla';
- $chart->data['sample']->highlight['Opera'] = true;
-
- $chart->driver->options->linkCursor = 'crosshair';
+ public function testPieChartSvgLinkingOnlyDataPoint()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphPieChart();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ ) );
+
+ $chart->data['sample']->url['Mozilla'] =
'http://example.org/browsers/mozilla';
$chart->render( 500, 200, $filename );
@@ -225,19 +276,22 @@
);
}
- public function testLineChartSvgLinking()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.svg';
-
- $chart = new ezcGraphLineChart();
- $chart->palette = new ezcGraphPaletteBlack();
- $chart->options->fillLines = 200;
-
- $chart->data['Line 1'] = new ezcGraphArrayDataSet( array( 'sample 1'
=> 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' =>
1) );
- $chart->data['Line 2'] = new ezcGraphArrayDataSet( array( 'sample 1'
=> 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' =>
613) );
-
- $chart->data['Line 1']->url = 'http://example.org/line_1';
- $chart->data['Line 2']->url['sample 3'] =
'http://example.org/line_2/sample_3';
+ public function testPieChartSvgLinkingNoLegend()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphPieChart();
+ $chart->legend = false;
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ ) );
+
+ $chart->data['sample']->url['Mozilla'] =
'http://example.org/browsers/mozilla';
+ $chart->data['sample']->highlight['Opera'] = true;
$chart->render( 500, 200, $filename );
@@ -249,6 +303,59 @@
);
}
+ public function testPieChartSvgLinkingCustomCursor()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphPieChart();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ ) );
+
+ $chart->data['sample']->url = 'http://example.org/browsers';
+ $chart->data['sample']->url['Mozilla'] =
'http://example.org/browsers/mozilla';
+ $chart->data['sample']->highlight['Opera'] = true;
+
+ $chart->driver->options->linkCursor = 'crosshair';
+
+ $chart->render( 500, 200, $filename );
+
+ ezcGraphTools::linkSvgElements( $chart );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ .
'.svg'
+ );
+ }
+
+ public function testLineChartSvgLinking()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphLineChart();
+ $chart->palette = new ezcGraphPaletteBlack();
+ $chart->options->fillLines = 200;
+
+ $chart->data['Line 1'] = new ezcGraphArrayDataSet( array( 'sample 1'
=> 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' =>
1) );
+ $chart->data['Line 2'] = new ezcGraphArrayDataSet( array( 'sample 1'
=> 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' =>
613) );
+
+ $chart->data['Line 1']->url = 'http://example.org/line_1';
+ $chart->data['Line 2']->url['sample 3'] =
'http://example.org/line_2/sample_3';
+
+ $chart->render( 500, 200, $filename );
+
+ ezcGraphTools::linkSvgElements( $chart );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ .
'.svg'
+ );
+ }
+
public function testSvgLinkingWithWrongDriver()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components