Boost logo

Boost-Commit :

From: pbristow_at_[hidden]
Date: 2008-01-30 11:38:03


Author: pbristow
Date: 2008-01-30 11:38:03 EST (Wed, 30 Jan 2008)
New Revision: 43021
URL: http://svn.boost.org/trac/boost/changeset/43021

Log:
Changed legend box sizing rules to avoid overflow (but fit for many is not less good :-(
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 21 +++++++++++----------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp | 13 ++++++++++++-
   2 files changed, 23 insertions(+), 11 deletions(-)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp 2008-01-30 11:38:03 EST (Wed, 30 Jan 2008)
@@ -558,13 +558,12 @@
             double spacing = (std::max)(font_size, point_size);
             // std::cout << spacing << ' ' << font_size << ' ' << point_size << std::endl;
             bool is_header = (derived().legend_header_.text() != "");
-
             //text_element legend_header_; // legend box header or title (if any).
             //text_style legend_style_;
             double longest = string_svg_length(derived().legend_header_.text(), derived().legend_style_);
             //std::cout << "\nLegend header " << longest << " svg units." << std::endl;
             derived().legend_width_ = 2 * (derived().legend_box_.margin() * derived().legend_box_.width());
- // Don't plan to write on the border, or within the 'forbidden' margin of the box.
+ // Don't plan to write on either side border, or on the 'forbidden' margins of the box.
             for(size_t i = 0; i < num_series; ++i)
             { // Find the longest text (if longer than header) in all the data series.
               std::string s = derived().series[i].title_;
@@ -574,18 +573,20 @@
                 longest = siz;
               }
             } // for
- // std::cout.flags(std::ios_base::dec); should not be needed TODO
             // std::cout << "\nLongest legend header or data descriptor " << longest << " svg units." << std::endl;
- derived().legend_width_ += longest; // Space for longest text.
+ derived().legend_width_ += longest * 0.8; // Space for longest text.
+ // Kludge factor to allow for not knowing the real length.
                                     
- // Allow for a leading space, longest text
+ // Allow width for a leading space, and trailing
+ derived().legend_width_ += spacing * 2.5;
+
             // & trailing space before box margin.
             if (derived().legend_lines_)
             { // Add for colored line marker in legend.
               derived().legend_width_ += spacing * 1.5;
             }
             if(derived().series[0].point_style_.shape() != none)
- { // Add for colored data point marker, cross, round... & space.
+ { // Add for any colored data point marker, cross, round... & space.
               derived().legend_width_ += 1.5 * derived().series[0].point_style_.size();
             }
             // else no point marker.
@@ -595,8 +596,9 @@
             // (if any) plus a text_margin_ top and bottom.
             // Add more height depending on the number of lines of text.
             derived().legend_height_ = spacing; // At top
- if (is_header) // is a legend header line.
- {
+ if ( (is_header) // is a legend header line.
+ && (derived().legend_header_.text() != "") )
+ {
               derived().legend_height_ += 2 * font_size; // text & space after.
             }
             derived().legend_height_ += num_series * spacing * 2; // Space for the data point symbols & text.
@@ -727,7 +729,6 @@
             int font_size = derived().legend_header_.style().font_size();
             int point_size = derived().series[0].point_style_.size();
             // Use whichever is the biggest of point marker and font.
-
             double spacing = (std::max)(font_size, point_size);
             // std::cerr << spacing << ' ' << font_size << ' ' << point_size << endl;
             bool is_header = (derived().legend_header_.text() != "");
@@ -751,7 +752,7 @@
               derived().legend_header_.y(legend_y_pos);
               derived().image.g(PLOT_LEGEND_TEXT).push_back(new
                 text_element(derived().legend_header_));
- legend_y_pos += 2 * spacing; // Might be 1.5?
+ legend_y_pos += 2 * spacing; // Might be 1.5? - useful if many series makes the box too tall.
             }
 
             g_ptr = &(derived().image.g(PLOT_LEGEND_POINTS));

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp 2008-01-30 11:38:03 EST (Wed, 30 Jan 2008)
@@ -417,6 +417,17 @@
     std::string symbols_; // Unicode symbol (letters, digits, squiggles etc)
     // Caution: not all Unicode symbols are output by all browsers!
     text_style symbols_style_;
+ //bool show_x_value_; // Show the X value near the point.
+ //bool show_y_value_; // Show the Y value near the point.
+ //// if both true, then shows both as a pair "1.2, 3.4"
+ //int dist; // from the point to the value.
+ //rotate_style orient_; // Orientation of the value from the point.
+ //// Note that this needs to alter the text alignment, center, left or right,
+ //// to avoid writing over the point marker.
+ //rotate_style rotation_; // Rotation of the value text string itself.
+ //// Note that this also needs to alter the text alignment, center, left or right,
+ //// to avoid writing over the point marker.
+ //text_style value_style_; // Size, font, color etc of the value.
 
     plot_point_style(const svg_color& fill = blank, const svg_color& stroke = black,
       int size = 10, point_shape shape = round, const std::string& symbols = "X")
@@ -931,7 +942,7 @@
     box_style(const svg_color& scolor = black,
       const svg_color& fcolor = white,
       double width = 1, // of border
- double margin = 2., //
+ double margin = 4., //
       bool border_on = true, // Draw a border of width.
       bool fill_on = false) // Apply fill color.
       :


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk