Piecharts: Remove trailing whitespace from slice labels
[pspp] / src / output / charts / piechart.c
index 0b9153d545b76d26340532a22b9e218bb29f15c6..366e729e7cd16b4811dbbcb42b0a76f9578f7fb2 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2004, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2009, 2011 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
 #include <config.h>
 
-#include <output/charts/piechart.h>
+#include "output/charts/piechart.h"
 
 #include <stdlib.h>
 
-#include <libpspp/cast.h>
-#include <libpspp/str.h>
-#include <output/chart-item-provider.h>
+#include "libpspp/cast.h"
+#include "libpspp/str.h"
+#include "output/chart-item-provider.h"
 
 #include "gl/xalloc.h"
 
@@ -43,6 +43,11 @@ piechart_create (const char *title, const struct slice *slices, int n_slices)
       struct slice *dst = &pie->slices[i];
 
       ds_init_string (&dst->label, &src->label);
+
+      /* Chomp any whitespace from the RHS of the label.
+        Doing this ensures that those labels to the right
+        of the pie, appear right justified. */
+      ds_rtrim (&dst->label, ss_cstr (" \t"));
       dst->magnitude = src->magnitude;
     }
   pie->n_slices = n_slices;