[Rt-commit] rt branch, 4.2/charts, updated. rt-4.1.8-486-g264f0ab

Ruslan Zakirov ruz at bestpractical.com
Sun Jun 16 10:33:54 EDT 2013


The branch, 4.2/charts has been updated
       via  264f0ab6cbabe0cd6b0a461bf35829fc500a06fb (commit)
      from  81df450202bc4ce9cc916c1c09672ce6515e8a41 (commit)

Summary of changes:
 share/html/Search/Chart | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

- Log -----------------------------------------------------------------
commit 264f0ab6cbabe0cd6b0a461bf35829fc500a06fb
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sun Jun 16 18:31:01 2013 +0400

    make error picture(charts) less tall
    
    If you have an dashboard with e.g. 5 saved charts and 2 of them have no
    tickets the big "No tickets found" picture just takes too much space.
    
    Sadly GD doesn't allow to change height on existing objects, so
    we have to repeat whole process twice.

diff --git a/share/html/Search/Chart b/share/html/Search/Chart
index 188d7ec..aa6cb09 100644
--- a/share/html/Search/Chart
+++ b/share/html/Search/Chart
@@ -77,10 +77,26 @@ my $plot_error = sub {
         color       => $black,
         text        => $text,
         align       => "left",
+        width       => $Width - 20,
         preserve_nl => 1,
     );
     $error->set_font( $font, 16 );
-    $error->draw(0, 0);
+
+    my $text_height = ($error->get_bounds(0, 0))[3];
+
+    $plot = GD::Image->new($Width => $text_height+20);
+    $plot->colorAllocate(255, 255, 255); # background
+    $black = $plot->colorAllocate(0, 0, 0);
+
+    $error = GD::Text::Wrap->new($plot,
+        color       => $black,
+        text        => $text,
+        align       => "left",
+        width       => $Width - 20,
+        preserve_nl => 1,
+    );
+    $error->set_font( $font, 16 );
+    $error->draw(10, 10);
 
     $m->comp( 'SELF:Plot', plot => $plot, %ARGS );
 };

-----------------------------------------------------------------------


More information about the Rt-commit mailing list