##// END OF EJS Templates
ChartViewer: added logaxes charts
Marek Rosa -
r2279:344c3d3c2742
parent child
Show More
@@ -0,0 +1,81
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "charts.h"
22 #include "qchart.h"
23 #include "qbarseries.h"
24 #include "qbarset.h"
25 #include "qlogvalueaxis.h"
26 #include "qbarcategoryaxis.h"
27
28 class BarCategoryAxisXLogY: public Chart
29 {
30 public:
31 QString name() { return "AxisX"; }
32 QString category() { return QObject::tr("Axis"); }
33 QString subCategory() { return "BarCategoryAxis"; }
34
35 QChart *createChart(const DataTable &table)
36 {
37 QChart *chart = new QChart();
38 chart->setTitle(" BarCateogry X , LogValue Y");
39
40 QString name("Series ");
41 QBarSeries *series = new QBarSeries(chart);
42 QLogValueAxis *logvalueaxis = new QLogValueAxis();
43 logvalueaxis->setBase(2);
44 QBarCategoryAxis *barcategory = new QBarCategoryAxis();
45 for (int i(0); i < table.count(); i++) {
46 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
47 foreach (Data data, table[i])
48 *set << data.first.y();
49 series->append(set);
50 }
51 chart->addSeries(series);
52
53 int count = series->barSets().first()->count();
54
55
56 for (int i = 0; i < count; i++) {
57 barcategory->append("BarSet " + QString::number(i));
58 }
59
60 chart->setAxisY(logvalueaxis, series);
61 chart->setAxisX(barcategory, series);
62
63 return chart;
64 }
65 };
66
67 class BarCategoryAxisXLogYTitle: public BarCategoryAxisXLogY
68 {
69 QString name() { return "AxisX Title"; }
70 QChart *createChart(const DataTable &table)
71 {
72 QChart *chart = BarCategoryAxisXLogY::createChart(table);
73 chart->axisX()->setTitleText("Axis X");
74 chart->axisY()->setTitleText("Axis Y");
75 chart->setTitle(" BarCateogry X , LogValue Y, title");
76 return chart;
77 }
78 };
79
80 DECLARE_CHART(BarCategoryAxisXLogY);
81 DECLARE_CHART(BarCategoryAxisXLogYTitle);
@@ -0,0 +1,81
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "charts.h"
22 #include "qchart.h"
23 #include "qhorizontalbarseries.h"
24 #include "qbarset.h"
25 #include "qlogvalueaxis.h"
26 #include "qbarcategoryaxis.h"
27
28 class BarCategoryAxisYLogX: public Chart
29 {
30 public:
31 QString name() { return "AxisY"; }
32 QString category() { return QObject::tr("Axis"); }
33 QString subCategory() { return "BarCategoryAxis"; }
34
35 QChart *createChart(const DataTable &table)
36 {
37 QChart *chart = new QChart();
38 chart->setTitle(" LogValue X , BarCateogry Y");
39
40 QString name("Series ");
41 QHorizontalBarSeries *series = new QHorizontalBarSeries(chart);
42 QLogValueAxis *logvalueaxis = new QLogValueAxis();
43 logvalueaxis->setBase(2);
44 QBarCategoryAxis *barcategory = new QBarCategoryAxis();
45 for (int i(0); i < table.count(); i++) {
46 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
47 foreach (Data data, table[i])
48 *set << data.first.y();
49 series->append(set);
50 }
51 chart->addSeries(series);
52
53 int count = series->barSets().first()->count();
54
55
56 for (int i = 0; i < count; i++) {
57 barcategory->append("BarSet " + QString::number(i));
58 }
59
60 chart->setAxisX(logvalueaxis, series);
61 chart->setAxisY(barcategory, series);
62
63 return chart;
64 }
65 };
66
67 class BarCategoryAxisYLogXTitle: public BarCategoryAxisYLogX
68 {
69 QString name() { return "AxisX Title"; }
70 QChart *createChart(const DataTable &table)
71 {
72 QChart *chart = BarCategoryAxisYLogX::createChart(table);
73 chart->axisX()->setTitleText("Axis X");
74 chart->axisY()->setTitleText("Axis Y");
75 chart->setTitle(" LogValue X , BarCateogry Y, title");
76 return chart;
77 }
78 };
79
80 DECLARE_CHART(BarCategoryAxisYLogX);
81 DECLARE_CHART(BarCategoryAxisYLogXTitle);
@@ -0,0 +1,76
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "charts.h"
22 #include "qchart.h"
23 #include "qlineseries.h"
24 #include "qlogvalueaxis.h"
25 #include "qcategoryaxis.h"
26
27 class LogValueAxisX: public Chart
28 {
29 public:
30 QString name() { return "LogValueAxisX"; }
31 QString category() { return QObject::tr("Axis"); }
32 QString subCategory() { return QObject::tr("Log"); }
33
34 QChart *createChart(const DataTable &table)
35 {
36 QChart *chart = new QChart();
37 chart->setTitle("LogValue X , Value Y");
38
39 QString name("Series ");
40 int nameIndex = 0;
41 foreach (DataList list, table) {
42 QLineSeries *series = new QLineSeries(chart);
43 foreach (Data data, list)
44 series->append(data.first);
45 series->setName(name + QString::number(nameIndex));
46 nameIndex++;
47 chart->addSeries(series);
48 }
49
50 chart->createDefaultAxes();
51 QLogValueAxis *axis = new QLogValueAxis();
52 axis->setBase(1.2);
53 foreach (QAbstractSeries *series, chart->series())
54 chart->setAxisX(axis, series);
55
56 return chart;
57 }
58 };
59
60 class LogValueAxisTitleX: public LogValueAxisX
61 {
62 public:
63 QString name() { return "LogValueAxisXTitle"; }
64
65 QChart *createChart(const DataTable &table)
66 {
67 QChart *chart = LogValueAxisX::createChart(table);
68 chart->axisX()->setTitleText("Axis X");
69 chart->axisY()->setTitleText("Axis Y");
70 chart->setTitle("Log Value X , Value Y, title");
71 return chart;
72 }
73 };
74
75 DECLARE_CHART(LogValueAxisX);
76 DECLARE_CHART(LogValueAxisTitleX);
@@ -0,0 +1,76
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "charts.h"
22 #include "qchart.h"
23 #include "qlineseries.h"
24 #include "qlogvalueaxis.h"
25 #include "qcategoryaxis.h"
26
27 class LogValueAxisY: public Chart
28 {
29 public:
30 QString name() { return "LogValueAxisY"; }
31 QString category() { return QObject::tr("Axis"); }
32 QString subCategory() { return QObject::tr("Log"); }
33
34 QChart *createChart(const DataTable &table)
35 {
36 QChart *chart = new QChart();
37 chart->setTitle("Value X , LogValue Y");
38
39 QString name("Series ");
40 int nameIndex = 0;
41 foreach (DataList list, table) {
42 QLineSeries *series = new QLineSeries(chart);
43 foreach (Data data, list)
44 series->append(data.first);
45 series->setName(name + QString::number(nameIndex));
46 nameIndex++;
47 chart->addSeries(series);
48 }
49
50 chart->createDefaultAxes();
51 QLogValueAxis *axis = new QLogValueAxis();
52 axis->setBase(2);
53 foreach (QAbstractSeries *series, chart->series())
54 chart->setAxisY(axis, series);
55
56 return chart;
57 }
58 };
59
60 class LogValueAxisTitleY: public LogValueAxisY
61 {
62 public:
63 QString name() { return "LogValueAxisYTitle"; }
64
65 QChart *createChart(const DataTable &table)
66 {
67 QChart *chart = LogValueAxisY::createChart(table);
68 chart->axisX()->setTitleText("Axis X");
69 chart->axisY()->setTitleText("Axis Y");
70 chart->setTitle("Value X , Log Value Y, title");
71 return chart;
72 }
73 };
74
75 DECLARE_CHART(LogValueAxisY);
76 DECLARE_CHART(LogValueAxisTitleY);
@@ -1,32 +1,36
1 1 INCLUDEPATH += $$PWD
2 2 DEPENDPATH += $$PWD
3 3 SOURCES += \
4 4 $$PWD/font/font.cpp \
5 5 $$PWD/xyseries/linechart.cpp \
6 6 $$PWD/xyseries/scatterchart.cpp \
7 7 $$PWD/xyseries/splinechart.cpp \
8 8 $$PWD/xyseries/areachart.cpp \
9 9 $$PWD/barseries/verticalstackedbarchart.cpp \
10 10 $$PWD/barseries/horizontalstackedbarchart.cpp \
11 11 $$PWD/barseries/verticalbarchart.cpp \
12 12 $$PWD/barseries/horizontalbarchart.cpp \
13 13 $$PWD/barseries/horizontalpercentbarchart.cpp \
14 14 $$PWD/barseries/verticalpercentbarchart.cpp \
15 15 $$PWD/pieseries/piechart.cpp \
16 16 $$PWD/pieseries/donutchart.cpp \
17 17 $$PWD/axis/valueaxis.cpp \
18 $$PWD/axis/logvalueaxisx.cpp \
19 $$PWD/axis/logvalueaxisy.cpp \
18 20 $$PWD/axis/categoryaxis.cpp \
19 21 $$PWD/axis/barcategoryaxisx.cpp \
20 22 $$PWD/axis/barcategoryaxisy.cpp \
23 $$PWD/axis/barcategoryaxisxlogy.cpp \
24 $$PWD/axis/barcategoryaxisylogx.cpp \
21 25 $$PWD/multiaxis/multivalueaxis.cpp \
22 26 $$PWD/multiaxis/multivalueaxis2.cpp \
23 27 $$PWD/multiaxis/multivalueaxis3.cpp \
24 28 $$PWD/multiaxis/multivalueaxis4.cpp \
25 29 $$PWD/multiaxis/multivaluebaraxis.cpp \
26 30 $$PWD/size/sizecharts.cpp
27 31
28 32 !linux-arm*: {
29 33 SOURCES += \
30 34 $$PWD/axis/datetimeaxisx.cpp \
31 35 $$PWD/axis/datetimeaxisy.cpp
32 36 }
@@ -1,94 +1,94
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "barchartitem_p.h"
22 22 #include "bar_p.h"
23 23 #include "qabstractbarseries_p.h"
24 24 #include "qbarset.h"
25 25 #include "qbarset_p.h"
26 26
27 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28
29 29 BarChartItem::BarChartItem(QAbstractBarSeries *series, QGraphicsItem* item) :
30 30 AbstractBarChartItem(series, item)
31 31 {
32 32 }
33 33
34 34 QVector<QRectF> BarChartItem::calculateLayout()
35 35 {
36 36 QVector<QRectF> layout;
37 37
38 38 // Use temporary qreals for accuracy
39 39 qreal categoryCount = m_series->d_func()->categoryCount();
40 40 qreal setCount = m_series->count();
41 41 bool barsVisible = m_series->isVisible();
42 42
43 43 // Domain:
44 44 qreal width = geometry().width();
45 45 qreal height = geometry().height();
46 46 qreal rangeY = m_domainMaxY - m_domainMinY;
47 47 qreal rangeX = m_domainMaxX - m_domainMinX;
48 48 qreal scaleY = (height / rangeY);
49 49 qreal scaleX = (width / rangeX);
50 50 qreal rectWidth = (scaleX / setCount) * m_series->d_func()->barWidth();
51 51
52 52 int itemIndex(0);
53 53 for (int category = 0; category < categoryCount; category++) {
54 54 qreal yPos = height + scaleY * m_domainMinY + geometry().top();
55 55 for (int set = 0; set < setCount; set++) {
56 56 QBarSetPrivate *barSet = m_series->d_func()->barsetAt(set)->d_ptr.data();
57 57
58 58 qreal xPos = (barSet->pos(category) - m_domainMinX) * scaleX + geometry().left();
59 59 xPos -= setCount * rectWidth / 2;
60 60 xPos += set * rectWidth;
61 61
62 62 qreal rectHeight = barSet->value(category) * scaleY;
63 63 Bar *bar = m_bars.at(itemIndex);
64 64
65 65 QRectF rect(xPos, yPos - rectHeight, rectWidth, rectHeight);
66 66 layout.append(rect);
67 67 bar->setPen(barSet->m_pen);
68 68 bar->setBrush(barSet->m_brush);
69 if (qFuzzyCompare(rectHeight, 0))
69 if (qFuzzyIsNull(rectHeight))
70 70 bar->setVisible(false);
71 71 else
72 72 bar->setVisible(barsVisible);
73 73
74 74 QGraphicsSimpleTextItem *label = m_labels.at(itemIndex);
75 75
76 if (!qFuzzyCompare(barSet->value(category), 0))
76 if (!qFuzzyIsNull(barSet->value(category)))
77 77 label->setText(QString::number(barSet->value(category)));
78 78 else
79 79 label->setText(QString(""));
80 80
81 81 label->setPos(xPos + (rect.width() / 2 - label->boundingRect().width() / 2),
82 82 yPos - rectHeight / 2 - label->boundingRect().height() / 2);
83 83 label->setFont(barSet->m_labelFont);
84 84 label->setBrush(barSet->m_labelBrush);
85 85
86 86 itemIndex++;
87 87 }
88 88 }
89 89 return layout;
90 90 }
91 91
92 92 #include "moc_barchartitem_p.cpp"
93 93
94 94 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,100 +1,100
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "percentbarchartitem_p.h"
22 22 #include "bar_p.h"
23 23 #include "qabstractbarseries_p.h"
24 24 #include "qbarset.h"
25 25 #include "qbarset_p.h"
26 26
27 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28
29 29 PercentBarChartItem::PercentBarChartItem(QAbstractBarSeries *series, QGraphicsItem* item) :
30 30 AbstractBarChartItem(series, item)
31 31 {
32 32 }
33 33
34 34 QVector<QRectF> PercentBarChartItem::calculateLayout()
35 35 {
36 36 QVector<QRectF> layout;
37 37
38 38 // Use temporary qreals for accuracy
39 39 qreal categoryCount = m_series->d_func()->categoryCount();
40 40 qreal setCount = m_series->count();
41 41 bool barsVisible = m_series->isVisible();
42 42
43 43 // Domain:
44 44 qreal width = geometry().width();
45 45 qreal height = geometry().height();
46 46 qreal rangeY = m_domainMaxY - m_domainMinY;
47 47 qreal rangeX = m_domainMaxX - m_domainMinX;
48 48 qreal scaleY = (height / rangeY);
49 49 qreal scaleX = (width / rangeX);
50 50 qreal rectWidth = scaleX * m_series->d_func()->barWidth();
51 51
52 52 int itemIndex(0);
53 53 for (int category = 0; category < categoryCount; category++) {
54 54 qreal colSum = m_series->d_func()->categorySum(category);
55 55 qreal percentage = (100 / colSum);
56 56 qreal yPos = height + scaleY * m_domainMinY + geometry().top();
57 57 for (int set = 0; set < setCount; set++) {
58 58 QBarSetPrivate *barSet = m_series->d_func()->barsetAt(set)->d_ptr.data();
59 59
60 60 qreal xPos = (barSet->pos(category) - m_domainMinX) * scaleX + geometry().left() - rectWidth / 2;
61 61
62 62 qreal rectHeight = barSet->value(category) * percentage * scaleY;
63 63 Bar *bar = m_bars.at(itemIndex);
64 64 bar->setPen(barSet->m_pen);
65 65 bar->setBrush(barSet->m_brush);
66 if (qFuzzyCompare(rectHeight, 0))
66 if (qFuzzyIsNull(rectHeight))
67 67 bar->setVisible(false);
68 68 else
69 69 bar->setVisible(barsVisible);
70 70
71 71 QRectF rect(xPos, yPos - rectHeight, rectWidth, rectHeight);
72 72 layout.append(rect);
73 73
74 74 QGraphicsSimpleTextItem *label = m_labels.at(itemIndex);
75 75
76 if (!qFuzzyCompare(m_series->d_func()->valueAt(set, category), 0)) {
76 if (!qFuzzyIsNull(m_series->d_func()->valueAt(set, category))) {
77 77 int p = m_series->d_func()->percentageAt(set, category) * 100;
78 78 QString vString(QString::number(p));
79 79 vString.truncate(3);
80 80 vString.append("%");
81 81 label->setText(vString);
82 82 } else {
83 83 label->setText(QString(""));
84 84 }
85 85
86 86 label->setPos(xPos + (rect.width() / 2 - label->boundingRect().width() / 2),
87 87 yPos - rectHeight / 2 - label->boundingRect().height() / 2);
88 88 label->setFont(barSet->m_labelFont);
89 89 label->setBrush(barSet->m_labelBrush);
90 90
91 91 itemIndex++;
92 92 yPos -= rectHeight;
93 93 }
94 94 }
95 95 return layout;
96 96 }
97 97
98 98 #include "moc_percentbarchartitem_p.cpp"
99 99
100 100 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,102 +1,102
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "stackedbarchartitem_p.h"
22 22 #include "bar_p.h"
23 23 #include "qbarset_p.h"
24 24 #include "qabstractbarseries_p.h"
25 25 #include "qbarset.h"
26 26
27 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28
29 29 StackedBarChartItem::StackedBarChartItem(QAbstractBarSeries *series, QGraphicsItem* item) :
30 30 AbstractBarChartItem(series, item)
31 31 {
32 32 }
33 33
34 34 QVector<QRectF> StackedBarChartItem::calculateLayout()
35 35 {
36 36 QVector<QRectF> layout;
37 37 // Use temporary qreals for accuracy
38 38 qreal categoryCount = m_series->d_func()->categoryCount();
39 39 qreal setCount = m_series->count();
40 40 bool barsVisible = m_series->isVisible();
41 41
42 42 // Domain:
43 43 qreal width = geometry().width();
44 44 qreal height = geometry().height();
45 45 qreal rangeY = m_domainMaxY - m_domainMinY;
46 46 qreal rangeX = m_domainMaxX - m_domainMinX;
47 47 qreal scaleY = (height / rangeY);
48 48 qreal scaleX = (width / rangeX);
49 49 qreal rectWidth = scaleX * m_series->d_func()->barWidth();
50 50
51 51 int itemIndex(0);
52 52 for (int category = 0; category < categoryCount; category++) {
53 53 qreal yMax = height + scaleY * m_domainMinY + geometry().top();
54 54 qreal yMin = height + scaleY * m_domainMinY + geometry().top();
55 55 for (int set = 0; set < setCount; set++) {
56 56 QBarSetPrivate *barSet = m_series->d_func()->barsetAt(set)->d_ptr.data();
57 57
58 58 qreal xPos = (barSet->pos(category) - m_domainMinX) * scaleX + geometry().left() - rectWidth / 2;
59 59
60 60 qreal rectHeight = barSet->value(category) * scaleY;
61 61 Bar *bar = m_bars.at(itemIndex);
62 62 bar->setPen(barSet->m_pen);
63 63 bar->setBrush(barSet->m_brush);
64 if (qFuzzyCompare(rectHeight, 0))
64 if (qFuzzyIsNull(rectHeight))
65 65 bar->setVisible(false);
66 66 else
67 67 bar->setVisible(barsVisible);
68 68
69 69 QGraphicsSimpleTextItem *label = m_labels.at(itemIndex);
70 70
71 if (!qFuzzyCompare(barSet->value(category), 0))
71 if (!qFuzzyIsNull(barSet->value(category)))
72 72 label->setText(QString::number(barSet->value(category)));
73 73 else
74 74 label->setText(QString(""));
75 75
76 76 label->setFont(barSet->m_labelFont);
77 77 label->setBrush(barSet->m_labelBrush);
78 78
79 79 if (rectHeight < 0) {
80 80 QRectF rect(xPos, yMax - rectHeight, rectWidth, rectHeight);
81 81 layout.append(rect);
82 82 label->setPos(xPos + (rect.width() / 2 - label->boundingRect().width() / 2),
83 83 yMax - rectHeight / 2 - label->boundingRect().height() / 2);
84 84 yMax -= rectHeight;
85 85 } else {
86 86 QRectF rect(xPos, yMin - rectHeight, rectWidth, rectHeight);
87 87 layout.append(rect);
88 88 label->setPos(xPos + (rect.width() / 2 - label->boundingRect().width() / 2),
89 89 yMin - rectHeight / 2 - label->boundingRect().height() / 2);
90 90 yMin -= rectHeight;
91 91 }
92 92
93 93 itemIndex++;
94 94 }
95 95 }
96 96
97 97 return layout;
98 98 }
99 99
100 100 #include "moc_stackedbarchartitem_p.cpp"
101 101
102 102 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now