diff options
-rw-r--r-- | src/axis/date.php | 2 | ||||
-rw-r--r-- | tests/data/compare/ezcGraphDateAxisTest_testMonthInterval3.svg | 2 | ||||
-rw-r--r-- | tests/date_axis_test.php | 24 |
3 files changed, 27 insertions, 1 deletions
diff --git a/src/axis/date.php b/src/axis/date.php index de02613..ce7d6b6 100644 --- a/src/axis/date.php +++ b/src/axis/date.php @@ -426,7 +426,7 @@ class ezcGraphChartElementDateAxis extends ezcGraphChartElementAxis */ public function getMajorStepCount() { - return (int) ( ( $this->properties['endDate'] - $this->startDate ) / $this->interval ); + return (int) ceil( ( $this->properties['endDate'] - $this->startDate ) / $this->interval ); } /** diff --git a/tests/data/compare/ezcGraphDateAxisTest_testMonthInterval3.svg b/tests/data/compare/ezcGraphDateAxisTest_testMonthInterval3.svg new file mode 100644 index 0000000..db4e32a --- /dev/null +++ b/tests/data/compare/ezcGraphDateAxisTest_testMonthInterval3.svg @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="500" height="200" version="1.0" id="ezcGraph"><defs/><g id="ezcGraphChart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 0.0000,200.0000 L 0.0000,0.0000 L 500.0000,0.0000 L 500.0000,200.0000 L 0.0000,200.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_1"/><path d=" M 0.0000,200.0000 L 0.0000,0.0000 L 100.0000,0.0000 L 100.0000,200.0000 L 0.0000,200.0000 z " style="fill: #000000; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_2"/><path d=" M 2.0000,9.0000 L 9.0000,2.0000 L 16.0000,9.0000 L 9.0000,16.0000 L 2.0000,9.0000 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_3"/><path d=" M 100.0000,180.0000 L 500.0000,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_5"/><path d=" M 492.0000,184.0000 L 500.0000,180.0000 L 492.0000,176.0000 L 492.0000,184.0000 z " style="fill: #2e3436; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_6"/><path d=" M 140.0000,200.0000 L 140.0000,0.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_7"/><path d=" M 137.5000,5.0000 L 140.0000,0.0000 L 142.5000,5.0000 L 137.5000,5.0000 z " style="fill: #2e3436; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_8"/><path d=" M 245.6000,20.0000 L 245.6000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_10"/><path d=" M 246.6667,177.0000 L 246.6667,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_11"/><path d=" M 354.4000,20.0000 L 354.4000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_13"/><path d=" M 353.3333,177.0000 L 353.3333,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_14"/><path d=" M 460.0000,20.0000 L 460.0000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_16"/><path d=" M 460.0000,177.0000 L 460.0000,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_17"/><path d=" M 140.0000,180.0000 L 460.0000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_19"/><path d=" M 140.0000,180.0000 L 143.0000,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_20"/><path d=" M 140.0000,160.8000 L 460.0000,159.2000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_22"/><path d=" M 140.0000,160.0000 L 141.0000,160.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_23"/><path d=" M 140.0000,140.0000 L 460.0000,140.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_24"/><path d=" M 140.0000,140.0000 L 141.0000,140.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_25"/><path d=" M 140.0000,120.8000 L 460.0000,119.2000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_26"/><path d=" M 140.0000,120.0000 L 141.0000,120.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_27"/><path d=" M 140.0000,100.0000 L 460.0000,100.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_28"/><path d=" M 140.0000,100.0000 L 143.0000,100.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_29"/><path d=" M 140.0000,80.8000 L 460.0000,79.2000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_31"/><path d=" M 140.0000,80.0000 L 141.0000,80.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_32"/><path d=" M 140.0000,60.0000 L 460.0000,60.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_33"/><path d=" M 140.0000,60.0000 L 141.0000,60.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_34"/><path d=" M 140.0000,40.8000 L 460.0000,39.2000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_35"/><path d=" M 140.0000,40.0000 L 141.0000,40.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_36"/><path d=" M 140.0000,20.0000 L 460.0000,20.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_37"/><path d=" M 140.0000,20.0000 L 143.0000,20.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_38"/><path d=" M 193.1852,37.1937 L 193.1852,37.1937" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_40"/><path d=" M 193.1852,37.1937 L 243.1111,58.2204" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_41"/><path d=" M 243.1111,58.2204 L 317.7778,76.6188" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_42"/><path d=" M 317.7778,76.6188 L 346.2222,95.0171" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_43"/><path d=" M 346.2222,95.0171 L 371.1111,126.5572" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_44"/><path d=" M 371.1111,126.5572 L 392.4444,150.2122" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_45"/><path d=" M 392.4444,150.2122 L 452.8889,176.3860" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_46"/><path d=" M 190.1852,37.1937 L 193.1852,34.1937 L 196.1852,37.1937 L 193.1852,40.1937 L 190.1852,37.1937 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_47"/><path d=" M 240.1111,58.2204 L 243.1111,55.2204 L 246.1111,58.2204 L 243.1111,61.2204 L 240.1111,58.2204 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_48"/><path d=" M 314.7778,76.6188 L 317.7778,73.6188 L 320.7778,76.6188 L 317.7778,79.6188 L 314.7778,76.6188 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_49"/><path d=" M 343.2222,95.0171 L 346.2222,92.0171 L 349.2222,95.0171 L 346.2222,98.0171 L 343.2222,95.0171 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_50"/><path d=" M 368.1111,126.5572 L 371.1111,123.5572 L 374.1111,126.5572 L 371.1111,129.5572 L 368.1111,126.5572 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_51"/><path d=" M 389.4444,150.2122 L 392.4444,147.2122 L 395.4444,150.2122 L 392.4444,153.2122 L 389.4444,150.2122 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_52"/><path d=" M 449.8889,176.3860 L 452.8889,173.3860 L 455.8889,176.3860 L 452.8889,179.3860 L 449.8889,176.3860 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_53"/><g id="ezcGraphTextBox_4"><path d=" M 16.5000,17.0000 L 16.5000,1.5000 L 84.7800,1.5000 L 84.7800,17.0000 L 16.5000,17.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_54"/><text id="ezcGraphTextBox_4_text" x="17" text-length="66.78px" y="13.9" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">some data</text></g><g id="ezcGraphTextBox_9"><path d=" M 141.5000,198.0000 L 141.5000,181.5000 L 190.7000,181.5000 L 190.7000,198.0000 L 141.5000,198.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_55"/><text id="ezcGraphTextBox_9_text" x="142" text-length="47.7px" y="194.75" style="font-size: 15px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Oct 06</text></g><g id="ezcGraphTextBox_12"><path d=" M 248.1667,198.0000 L 248.1667,181.5000 L 297.3667,181.5000 L 297.3667,198.0000 L 248.1667,198.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_56"/><text id="ezcGraphTextBox_12_text" x="248.6667" text-length="47.7px" y="194.75" style="font-size: 15px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Oct 06</text></g><g id="ezcGraphTextBox_15"><path d=" M 354.8333,198.0000 L 354.8333,181.5000 L 404.0333,181.5000 L 404.0333,198.0000 L 354.8333,198.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_57"/><text id="ezcGraphTextBox_15_text" x="355.3333" text-length="47.7px" y="194.75" style="font-size: 15px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Nov 06</text></g><g id="ezcGraphTextBox_18"><path d=" M 409.8000,198.0000 L 409.8000,181.5000 L 459.0000,181.5000 L 459.0000,198.0000 L 409.8000,198.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_58"/><text id="ezcGraphTextBox_18_text" x="410.3" text-length="47.7px" y="194.75" style="font-size: 15px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Dec 06</text></g><g id="ezcGraphTextBox_21"><path d=" M 128.2000,179.0000 L 128.2000,162.5000 L 139.0000,162.5000 L 139.0000,179.0000 L 128.2000,179.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_59"/><text id="ezcGraphTextBox_21_text" x="128.7" text-length="9.3px" y="175.75" style="font-size: 15px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">6</text></g><g id="ezcGraphTextBox_30"><path d=" M 128.2000,99.0000 L 128.2000,82.5000 L 139.0000,82.5000 L 139.0000,99.0000 L 128.2000,99.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_60"/><text id="ezcGraphTextBox_30_text" x="128.7" text-length="9.3px" y="95.75" style="font-size: 15px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">7</text></g><g id="ezcGraphTextBox_39"><path d=" M 128.2000,38.0000 L 128.2000,21.5000 L 139.0000,21.5000 L 139.0000,38.0000 L 128.2000,38.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_61"/><text id="ezcGraphTextBox_39_text" x="128.7" text-length="9.3px" y="34.75" style="font-size: 15px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">8</text></g></g></svg> diff --git a/tests/date_axis_test.php b/tests/date_axis_test.php index b4b3a97..f5a81c0 100644 --- a/tests/date_axis_test.php +++ b/tests/date_axis_test.php @@ -549,6 +549,30 @@ class ezcGraphDateAxisTest extends ezcGraphTestCase $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } + + public function testMonthInterval3() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $this->chart->data['some data'] = new ezcGraphArrayDataSet( array( + strtotime( '2006-10-16' ) => 7.78507871321, + strtotime( '2006-10-30' ) => 7.52224503765, + strtotime( '2006-11-20' ) => 7.29226557153, + strtotime( '2006-11-28' ) => 7.06228610541, + strtotime( '2006-12-05' ) => 6.66803559206, + strtotime( '2006-12-11' ) => 6.37234770705, + strtotime( '2006-12-28' ) => 6.04517453799, + ) ); + $this->chart->xAxis->endDate = strtotime( '2006-12-30' ); + $this->chart->data['some data']->symbol = ezcGraph::DIAMOND; + + $this->chart->render( 500, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } } ?> |