[Libreoffice-commits] core.git: chart2/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Sat May 24 04:12:56 PDT 2014


 chart2/source/view/charttypes/GL3DBarChart.cxx |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

New commits:
commit 10c14f13a7bc314ccff41c60c7e1d6fdaae19450
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat May 24 13:05:12 2014 +0200

    improve the bar and text positioning
    
    Keep a bit of space to the border and move the text a bit away from the
    chart area. This makes it look much better in my opinion.
    
    Change-Id: I1eee505e8361cbc0e3ca859d74a96af880451198

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index efd27af..6d0b6d7 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -87,7 +87,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
     for (boost::ptr_vector<VDataSeries>::const_iterator itr = rDataSeriesContainer.begin(),
             itrEnd = rDataSeriesContainer.end(); itr != itrEnd; ++itr)
     {
-        nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY);
+        nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY) + nBarDistanceY;
 
         const VDataSeries& rDataSeries = *itr;
         sal_Int32 nPointCount = rDataSeries.getTotalPointCount();
@@ -104,10 +104,10 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
             maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++));
             opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
             glm::vec3 aTopLeft, aTopRight, aBottomRight;
-            aTopLeft.x = 0.0f;
-            aTopLeft.y = nYPos;
-            aTopRight.x = calculateTextWidth(aSeriesName) * -1.0;
-            aTopRight.y = nYPos;
+            aTopLeft.x = -nBarDistanceY;
+            aTopLeft.y = nYPos + 0.25 * nBarSizeY;
+            aTopRight.x = calculateTextWidth(aSeriesName) * -1.0 - nBarDistanceY;
+            aTopRight.y = nYPos + 0.25 * nBarSizeY;
             aBottomRight = aTopRight;
             aBottomRight.y += TEXT_HEIGHT;
             p->setPosition(aTopLeft, aTopRight, aBottomRight);
@@ -122,7 +122,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
             }
 
             float nVal = rDataSeries.getYValue(nIndex);
-            float nXPos = nIndex * (nBarSizeX + nBarDistanceX);
+            float nXPos = nIndex * (nBarSizeX + nBarDistanceX) + nBarDistanceX;
 
 
             glm::mat4 aScaleMatrix = glm::scale(nBarSizeX, nBarSizeY, nVal);
@@ -165,7 +165,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
     opengl3D::Rectangle* pRect = static_cast<opengl3D::Rectangle*>(&maShapes.back());
     glm::vec3 aTopLeft;
     glm::vec3 aTopRight = aTopLeft;
-    aTopRight.x = nXEnd;
+    aTopRight.x = nXEnd + 2 * nBarDistanceX;
     glm::vec3 aBottomRight = aTopRight;
     aBottomRight.y = nYPos;
     pRect->setPosition(aTopLeft, aTopRight, aBottomRight);
@@ -184,11 +184,11 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
         maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++));
         opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
         aTopLeft.x = nXPos + TEXT_HEIGHT;
-        aTopLeft.y = nYPos + calculateTextWidth(aCats[i]);
+        aTopLeft.y = nYPos + calculateTextWidth(aCats[i]) + 0.5 * nBarDistanceY;
         aTopRight = aTopLeft;
-        aTopRight.y = nYPos;
+        aTopRight.y = nYPos + 0.5* nBarDistanceY;
         aBottomRight.x = nXPos;
-        aBottomRight.y = nYPos;
+        aBottomRight.y = nYPos + 0.5 * nBarDistanceY;
         p->setPosition(aTopLeft, aTopRight, aBottomRight);
     }
 }


More information about the Libreoffice-commits mailing list