##// END OF EJS Templates
Polishing...
Polishing Change-Id: Ib838cf4cfe7a76aec5c7b22b000d37eee3954615 Reviewed-by: Mika Salmela <mika.salmela@digia.com>

File last commit:

r2432:53927f716a3d
r2514:479ca6adcb21
Show More
stackedbarchartitem.cpp
108 lines | 4.4 KiB | text/x-c | CppLexer
/ src / barchart / vertical / stacked / stackedbarchartitem.cpp
Jani Honkonen
Add license headers
r794 /****************************************************************************
**
Miikka Heikkinen
Fixed the copyright year 2012 -> 2013
r2432 ** Copyright (C) 2013 Digia Plc
Jani Honkonen
Add license headers
r794 ** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
sauimone
combined barpresenterbase and barpresenter. renamed barchartpresenters to barchartitems
r666 #include "stackedbarchartitem_p.h"
sauimone
renamed bar.h to bar_p.h
r118 #include "bar_p.h"
sauimone
barchart PIMPL part 2. Cleaning up leftovers in public api
r962 #include "qbarset_p.h"
sauimone
renamed barseries files to abstractbarseries
r1586 #include "qabstractbarseries_p.h"
sauimone
Added pen & brush to QBarSet
r214 #include "qbarset.h"
sauimone
added missing example files :)
r96
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactors internals...
r2273 StackedBarChartItem::StackedBarChartItem(QAbstractBarSeries *series, QGraphicsItem* item) :
AbstractBarChartItem(series, item)
sauimone
added missing example files :)
r96 {
}
Marek Rosa
Bar animations refactored
r2316 void StackedBarChartItem::initializeLayout()
{
qreal categoryCount = m_series->d_func()->categoryCount();
qreal setCount = m_series->count();
qreal barWidth = m_series->d_func()->barWidth();
m_layout.clear();
for(int category = 0; category < categoryCount; category++) {
for (int set = 0; set < setCount; set++) {
QRectF rect;
QPointF topLeft;
QPointF bottomRight;
if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) {
Marek Rosa
Negative values with log axis handled
r2356 topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, domain()->minY()), m_validData);
bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, domain()->minY()), m_validData);
Marek Rosa
Bar animations refactored
r2316 } else {
Marek Rosa
Negative values with log axis handled
r2356 topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, 0), m_validData);
bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, 0), m_validData);
Marek Rosa
Bar animations refactored
r2316 }
Marek Rosa
Negative values with log axis handled
r2356 if (!m_validData)
return;
Marek Rosa
Bar animations refactored
r2316 rect.setTopLeft(topLeft);
rect.setBottomRight(bottomRight);
m_layout.append(rect.normalized());
}
}
}
sauimone
animations to stacked and percent barchart
r694 QVector<QRectF> StackedBarChartItem::calculateLayout()
sauimone
added missing example files :)
r96 {
sauimone
animations to stacked and percent barchart
r694 QVector<QRectF> layout;
sauimone
removed categories from barseries. categories are now only on axis
r1321 // Use temporary qreals for accuracy
qreal categoryCount = m_series->d_func()->categoryCount();
Tero Ahola
Minor modifications to properties of abstract, area and bar series
r1462 qreal setCount = m_series->count();
Marek Rosa
New bar calculate layout
r2303 qreal barWidth = m_series->d_func()->barWidth();
for(int category = 0; category < categoryCount; category++) {
qreal positiveSum = 0;
qreal negativeSum = 0;
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 for (int set = 0; set < setCount; set++) {
Marek Rosa
New bar calculate layout
r2303 qreal value = m_series->barSets().at(set)->at(category);
QRectF rect;
QPointF topLeft;
QPointF bottomRight;
if (value < 0) {
Marek Rosa
Negative values with log axis handled
r2356 bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, value + negativeSum), m_validData);
Marek Rosa
BarChartItems code cleanup
r2305 if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain)
Marek Rosa
Negative values with log axis handled
r2356 topLeft = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? negativeSum : domain()->minY()), m_validData);
Marek Rosa
New bar calculate layout
r2303 else
Marek Rosa
Negative values with log axis handled
r2356 topLeft = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? negativeSum : 0), m_validData);
Marek Rosa
New bar calculate layout
r2303 negativeSum += value;
sauimone
Better support for negative values in stacked barcharts. Negative values are stacked from zero to negative direction. Positive values are stacked from zero to positive direction.
r1897 } else {
Marek Rosa
Negative values with log axis handled
r2356 topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, value + positiveSum), m_validData);
Marek Rosa
BarChartItems code cleanup
r2305 if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain)
Marek Rosa
Negative values with log axis handled
r2356 bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : domain()->minY()), m_validData);
Marek Rosa
New bar calculate layout
r2303 else
Marek Rosa
Negative values with log axis handled
r2356 bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : 0), m_validData);
Marek Rosa
New bar calculate layout
r2303 positiveSum += value;
sauimone
Better support for negative values in stacked barcharts. Negative values are stacked from zero to negative direction. Positive values are stacked from zero to positive direction.
r1897 }
Marek Rosa
Negative values with log axis handled
r2356 if (!m_validData)
return QVector<QRectF>();
Marek Rosa
New bar calculate layout
r2303 rect.setTopLeft(topLeft);
rect.setBottomRight(bottomRight);
Marek Rosa
Bar animations refactored
r2316 layout.append(rect.normalized());
sauimone
Floating values to bar charts
r263 }
sauimone
prototyping separators with stacked bars
r119 }
Marek Rosa
BarChartItems code cleanup
r2305 return layout;
sauimone
added missing example files :)
r96 }
sauimone
combined barpresenterbase and barpresenter. renamed barchartpresenters to barchartitems
r666 #include "moc_stackedbarchartitem_p.cpp"
sauimone
moved tooltip to presenter
r288
sauimone
added missing example files :)
r96 QTCOMMERCIALCHART_END_NAMESPACE