diff --git a/mpop_dataviz/barchartlayout.cpp b/mpop_dataviz/barchartlayout.cpp index 123498e..3d6ae67 100644 --- a/mpop_dataviz/barchartlayout.cpp +++ b/mpop_dataviz/barchartlayout.cpp @@ -53,6 +53,7 @@ void BarChartLayout::setStartPosition(const QPointF &pos) void BarChartLayout::moveObjectsToLayout(qint64 currentTime) { // TODO: never ever iterate over size of line vector + // TODO: if (_isLogarithmicY) {} const qreal DISTANCE_BETWEEN_BARS = _barsHeight / 3.7; const qreal WIDTH_OF_EACH_COLUMN = DISTANCE_BETWEEN_BARS * 3; const qreal DISTANCE_BETWEEN_COLUMN = DISTANCE_BETWEEN_BARS / 2; @@ -73,15 +74,17 @@ void BarChartLayout::moveObjectsToLayout(qint64 currentTime) { int biggestRow = *std::max_element(_rowsValues.begin(), _rowsValues.end()); qreal columnSize = biggestRow / 5; - qreal offsetX = ((WIDTH_OF_EACH_COLUMN * columnSize) + ((DISTANCE_BETWEEN_BARS * 2) + - DISTANCE_BETWEEN_COLUMN) * (int(columnSize) - 1)) / 2; - qreal offsetY = ((_barsHeight * (_rowsValues.size() - 1)) + - (DISTANCE_BETWEEN_ROW * (_rowsValues.size() - 1))) / 2; + qreal offsetX = ( + (WIDTH_OF_EACH_COLUMN * columnSize) + + ((DISTANCE_BETWEEN_BARS * 2) + DISTANCE_BETWEEN_COLUMN) * + (int(columnSize) - 1) + ) / 2; + qreal offsetY = ( + (_barsHeight * (_rowsValues.size() - 1)) + + (DISTANCE_BETWEEN_ROW * (_rowsValues.size() - 1))) / 2; for (int rowIndex = 0; rowIndex < _rowsValues.size(); rowIndex++) { - int columnIndex = 0; - // Each bar in the bar chart is a column // We group lines by groups of 5 for (int barIndex = 0; barIndex < _rowsValues.at(rowIndex); barIndex++) { @@ -101,9 +104,8 @@ void BarChartLayout::moveObjectsToLayout(qint64 currentTime) { if (moduloFive == 4) { x = ((barIndex - 2) * DISTANCE_BETWEEN_BARS) - (DISTANCE_BETWEEN_BARS / 2) + columnOffset; rotation = -73; - // Increase the size of the fifth bar to fit to user story proportion + // Increase the size of every fifth bar line->setSize(_barsWidth, _barsHeight * 1.25); - columnIndex += 1; } diff --git a/mpop_dataviz/barchartlayout.h b/mpop_dataviz/barchartlayout.h index 37bfdc2..4456430 100644 --- a/mpop_dataviz/barchartlayout.h +++ b/mpop_dataviz/barchartlayout.h @@ -31,7 +31,6 @@ class BarChartLayout : public Layout _rowsValues.end(), 0); } - void updateBarsPosition(qint64 currentTime) override; void showSceneObject(qint64 currentTime) override; @@ -40,6 +39,7 @@ class BarChartLayout : public Layout void setStartPosition(const QPointF &pos); void setDistanceBetweenRows(qreal rowSpace) { _spaceBetweenRows = rowSpace; } + void setLogarithmicY(bool isLogarithmicY); private: QList _rowsValues; QSharedPointer _groupTweenAnimator; @@ -47,6 +47,7 @@ class BarChartLayout : public Layout QVector _horizontalLines; bool _centered = false; + bool _isLogarithmicY = false; qreal _x, _y = 0.0; qreal _spaceBetweenRows = 0.018; diff --git a/mpop_dataviz/layout.h b/mpop_dataviz/layout.h index 534b1a7..160c89a 100644 --- a/mpop_dataviz/layout.h +++ b/mpop_dataviz/layout.h @@ -18,13 +18,13 @@ class Layout virtual ~Layout(); /** - * @brief Adds some prisoner lines to this layour. + * @brief Adds some prisoner lines to this layout. * @param prisonerLines */ void addBarObjects(QSharedPointer> barObjects); /** - * @brief Move the objects managed by this layout into their desired position. + * @brief Moves the objects managed by this layout into their desired position. */ virtual void moveObjectsToLayout(qint64 currentTime) = 0; diff --git a/mpop_dataviz/viewmodemanager.cpp b/mpop_dataviz/viewmodemanager.cpp index a096571..9c241c0 100644 --- a/mpop_dataviz/viewmodemanager.cpp +++ b/mpop_dataviz/viewmodemanager.cpp @@ -413,6 +413,7 @@ void ViewModeManager::moveBarsToAnswerByAgeLayout() _agesAnswerBarChart.moveObjectsToLayout(currentTime()); _userAgeAnswer.addBarObjects(myAgeVect); + _userAgeAnswer.setLogarithmicY(true); _userAgeAnswer.setBarsSize(sizeFromPixel(3.5, barHeight)); _userAgeAnswer.setBarsColor("#80E2A7"); _userAgeAnswer.setStartPosition(