23 #include "KDChartNormalBarDiagram_p.h" 25 #include <QModelIndex> 47 const int rowCount = compressor().modelDataRows();
48 const int colCount = compressor().modelDataColumns();
50 const qreal xMin = 0.0;
51 const qreal xMax = rowCount;
58 for (
int column = 0; column < colCount; ++column ) {
59 for (
int row = 0; row < rowCount; ++row ) {
60 const CartesianDiagramDataCompressor::CachePosition position( row, column );
61 const CartesianDiagramDataCompressor::DataPoint point = compressor().data( position );
62 const qreal value = ISNAN( point.value ) ? 0.0 : point.value;
64 QModelIndex sourceIndex = attributesModel()->mapToSource( point.index );
68 usedDepth = qMax( usedDepth, threeDAttrs.
depth() );
78 yMin = qMin( yMin, value );
79 yMax = qMax( yMax, value );
88 }
else if ( yMax < 0.0 ) {
90 }
else if ( yMin > 0.0 ) {
100 reverseMapper().clear();
107 const int rowCount = attributesModel()->rowCount(attributesModelRootIndex());
108 const int colCount = attributesModel()->columnCount(attributesModelRootIndex());
114 const qreal threeDepthMargin = ( threeDAttrs.
isEnabled() ) ? 2.5 * threeDAttrs.
depth() : 0;
118 qreal width = boundRight.x() - boundLeft.x() - threeDepthMargin;
119 qreal groupWidth = width / rowCount;
120 qreal spaceBetweenBars = 0;
121 qreal spaceBetweenGroups = 0;
126 groupWidth += barWidth;
130 if ( groupWidth < 0 )
133 if ( groupWidth * rowCount > width )
134 groupWidth = width / rowCount;
139 qreal maxLimit = rowCount * ( groupWidth + ( ( colCount - 1 ) * ba.
fixedDataValueGap() ) );
143 if ( width > maxLimit ) {
146 spaceBetweenBars = ( ( width / rowCount ) - groupWidth ) / ( colCount - 1 );
154 calculateValueAndGapWidths( rowCount, colCount, groupWidth,
155 barWidth, spaceBetweenBars, spaceBetweenGroups );
159 for (
int row = 0; row < rowCount; ++row ) {
160 qreal offset = -groupWidth / 2 + spaceBetweenGroups / 2;
163 if ( spaceBetweenBars > 0 ) {
164 if ( width > maxLimit ) {
167 offset -= ( ( width / rowCount ) - groupWidth ) / ( colCount - 1 );
170 offset += barWidth / 2;
174 for (
int column = 0; column < colCount; ++column ) {
176 const CartesianDiagramDataCompressor::CachePosition position( row, column );
177 const CartesianDiagramDataCompressor::DataPoint point = compressor().data( position );
178 const QModelIndex sourceIndex = attributesModel()->mapToSource( point.index );
179 const qreal value = point.value;
180 if ( ! point.hidden && !ISNAN( value ) ) {
185 const qreal usedDepth = threeDAttrs.
depth() / 4;
186 topPoint.setY( topPoint.y() + usedDepth + 1.0 );
189 const qreal barHeight = bottomPoint.y() - topPoint.y();
190 topPoint.setX( topPoint.x() + offset );
191 const QRectF rect( topPoint, QSizeF( barWidth, barHeight ) );
194 paintBars( ctx, sourceIndex, rect, maxDepth );
196 offset += barWidth + spaceBetweenBars;
199 m_private->paintDataValueTextsAndMarkers( ctx, lpc,
false );
KDChartEnums::PositionValue value() const
Returns an integer value corresponding to this Position.
bool useFixedDataValueGap() const
virtual const QPointF translate(const QPointF &diagramPoint) const =0
Translate the given point in value space coordinates to a position in pixel space.
AbstractCoordinatePlane * coordinatePlane() const
Set of attributes for changing the appearance of bar charts.
qreal fixedValueBlockGap() const
static const Position & South
bool useFixedBarWidth() const
qreal fixedBarWidth() const
BarDiagram defines a common bar diagram.
bool useFixedValueBlockGap() const
Stores information about painting diagrams.
A set of 3D bar attributes.
Stores the absolute target points of a Position.
static const Position & North
qreal fixedDataValueGap() const