@@ -0,0 +1,6 | |||||
|
1 | !include( ../examples.pri ) { | |||
|
2 | error( "Couldn't find the examples.pri file!" ) | |||
|
3 | } | |||
|
4 | ||||
|
5 | TARGET = horizontalpercentbarchart | |||
|
6 | SOURCES += main.cpp |
@@ -0,0 +1,95 | |||||
|
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 <QApplication> | |||
|
22 | #include <QMainWindow> | |||
|
23 | #include <QChartView> | |||
|
24 | #include <QBarSeries> | |||
|
25 | #include <QBarSet> | |||
|
26 | #include <QLegend> | |||
|
27 | #include <QBarCategoriesAxis> | |||
|
28 | #include <QHorizontalPercentBarSeries> | |||
|
29 | ||||
|
30 | QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
31 | ||||
|
32 | int main(int argc, char *argv[]) | |||
|
33 | { | |||
|
34 | QApplication a(argc, argv); | |||
|
35 | ||||
|
36 | //![1] | |||
|
37 | QBarSet *set0 = new QBarSet("Jane"); | |||
|
38 | QBarSet *set1 = new QBarSet("John"); | |||
|
39 | QBarSet *set2 = new QBarSet("Axel"); | |||
|
40 | QBarSet *set3 = new QBarSet("Mary"); | |||
|
41 | QBarSet *set4 = new QBarSet("Samantha"); | |||
|
42 | ||||
|
43 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |||
|
44 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |||
|
45 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |||
|
46 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |||
|
47 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |||
|
48 | //![1] | |||
|
49 | ||||
|
50 | //![2] | |||
|
51 | QHorizontalPercentBarSeries *series = new QHorizontalPercentBarSeries(); | |||
|
52 | series->append(set0); | |||
|
53 | series->append(set1); | |||
|
54 | series->append(set2); | |||
|
55 | series->append(set3); | |||
|
56 | series->append(set4); | |||
|
57 | ||||
|
58 | //![2] | |||
|
59 | ||||
|
60 | //![3] | |||
|
61 | QChart* chart = new QChart(); | |||
|
62 | chart->addSeries(series); | |||
|
63 | chart->setTitle("Simple horizontal stacked barchart example"); | |||
|
64 | chart->createDefaultAxes(); | |||
|
65 | chart->setAnimationOptions(QChart::SeriesAnimations); | |||
|
66 | //![3] | |||
|
67 | ||||
|
68 | //![4] | |||
|
69 | QStringList categories; | |||
|
70 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |||
|
71 | QBarCategoriesAxis* axis = new QBarCategoriesAxis(); | |||
|
72 | axis->append(categories); | |||
|
73 | chart->createDefaultAxes(); | |||
|
74 | chart->setAxisY(axis,series); | |||
|
75 | //![4] | |||
|
76 | ||||
|
77 | //![5] | |||
|
78 | chart->legend()->setVisible(true); | |||
|
79 | chart->legend()->setAlignment(Qt::AlignBottom); | |||
|
80 | //![5] | |||
|
81 | ||||
|
82 | //![6] | |||
|
83 | QChartView* chartView = new QChartView(chart); | |||
|
84 | chartView->setRenderHint(QPainter::Antialiasing); | |||
|
85 | //![6] | |||
|
86 | ||||
|
87 | //![7] | |||
|
88 | QMainWindow window; | |||
|
89 | window.setCentralWidget(chartView); | |||
|
90 | window.resize(400, 300); | |||
|
91 | window.show(); | |||
|
92 | //![7] | |||
|
93 | ||||
|
94 | return a.exec(); | |||
|
95 | } |
@@ -0,0 +1,64 | |||||
|
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 "horizontalpercentbaranimation_p.h" | |||
|
22 | #include "abstractbarchartitem_p.h" | |||
|
23 | #include <QTimer> | |||
|
24 | ||||
|
25 | Q_DECLARE_METATYPE(QVector<QRectF>) | |||
|
26 | ||||
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
28 | ||||
|
29 | HorizontalPercentBarAnimation::HorizontalPercentBarAnimation(AbstractBarChartItem *item) : | |||
|
30 | AbstractBarAnimation(item) | |||
|
31 | { | |||
|
32 | } | |||
|
33 | ||||
|
34 | HorizontalPercentBarAnimation::~HorizontalPercentBarAnimation() | |||
|
35 | { | |||
|
36 | ||||
|
37 | } | |||
|
38 | ||||
|
39 | ||||
|
40 | QVariant HorizontalPercentBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const | |||
|
41 | { | |||
|
42 | QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from); | |||
|
43 | QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to); | |||
|
44 | QVector<QRectF> result; | |||
|
45 | ||||
|
46 | Q_ASSERT(startVector.count() == endVector.count()); | |||
|
47 | ||||
|
48 | qreal xAxis = m_item->geometry().x(); | |||
|
49 | ||||
|
50 | for(int i = 0; i < startVector.count(); i++) { | |||
|
51 | qreal h = endVector[i].height(); | |||
|
52 | qreal w = endVector[i].width() * progress; | |||
|
53 | qreal x = xAxis + ((endVector[i].left() - xAxis) * progress); | |||
|
54 | qreal y = endVector[i].top(); | |||
|
55 | ||||
|
56 | QRectF value(x,y,w,h); | |||
|
57 | result << value; | |||
|
58 | } | |||
|
59 | return qVariantFromValue(result); | |||
|
60 | } | |||
|
61 | ||||
|
62 | #include "moc_horizontalpercentbaranimation_p.cpp" | |||
|
63 | ||||
|
64 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,52 | |||||
|
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 | // W A R N I N G | |||
|
22 | // ------------- | |||
|
23 | // | |||
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |||
|
25 | // implementation detail. This header file may change from version to | |||
|
26 | // version without notice, or even be removed. | |||
|
27 | // | |||
|
28 | // We mean it. | |||
|
29 | ||||
|
30 | #ifndef HORIZONTALPERCENTBARANIMATION_P_H | |||
|
31 | #define HORIZONTALPERCENTBARANIMATION_P_H | |||
|
32 | ||||
|
33 | #include "abstractbaranimation_p.h" | |||
|
34 | #include "chartanimation_p.h" | |||
|
35 | #include "abstractbarchartitem_p.h" | |||
|
36 | ||||
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
38 | ||||
|
39 | class HorizontalPercentBarAnimation : public AbstractBarAnimation | |||
|
40 | { | |||
|
41 | Q_OBJECT | |||
|
42 | public: | |||
|
43 | explicit HorizontalPercentBarAnimation(AbstractBarChartItem *item); | |||
|
44 | ~HorizontalPercentBarAnimation(); | |||
|
45 | ||||
|
46 | virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const; | |||
|
47 | ||||
|
48 | }; | |||
|
49 | ||||
|
50 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
51 | ||||
|
52 | #endif // HORIZONTALPERCENTBARANIMATION_P_H |
@@ -0,0 +1,102 | |||||
|
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 "horizontalpercentbarchartitem_p.h" | |||
|
22 | #include "qabstractbarseries_p.h" | |||
|
23 | #include "qbarset_p.h" | |||
|
24 | #include "bar_p.h" | |||
|
25 | #include <QDebug> | |||
|
26 | ||||
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
28 | ||||
|
29 | HorizontalPercentBarChartItem::HorizontalPercentBarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter) : | |||
|
30 | AbstractBarChartItem(series, presenter) | |||
|
31 | { | |||
|
32 | } | |||
|
33 | ||||
|
34 | QVector<QRectF> HorizontalPercentBarChartItem::calculateLayout() | |||
|
35 | { | |||
|
36 | QVector<QRectF> layout; | |||
|
37 | ||||
|
38 | // Use temporary qreals for accuracy | |||
|
39 | qreal categoryCount = m_series->d_func()->categoryCount(); | |||
|
40 | qreal setCount = m_series->count(); | |||
|
41 | bool barsVisible = m_series->isVisible(); | |||
|
42 | ||||
|
43 | // Domain: | |||
|
44 | qreal width = geometry().width(); | |||
|
45 | qreal height = geometry().height(); | |||
|
46 | qreal rangeY = m_domainMaxY - m_domainMinY; | |||
|
47 | qreal rangeX = m_domainMaxX - m_domainMinX; | |||
|
48 | qreal scaleY = (height / rangeY); | |||
|
49 | qreal scaleX = (width / rangeX); | |||
|
50 | qreal barHeight = scaleY * m_series->d_func()->barWidth(); // On horizontal chart barWidth of the barseries means height of the rect. | |||
|
51 | ||||
|
52 | int itemIndex(0); | |||
|
53 | for (int category = 0; category < categoryCount; category++) { | |||
|
54 | qreal colSum = m_series->d_func()->categorySum(category); | |||
|
55 | qreal percentage = (100 / colSum); | |||
|
56 | qreal xPos = rangeX * m_domainMinX + geometry().left(); | |||
|
57 | for (int set = 0; set < setCount; set++) { | |||
|
58 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); | |||
|
59 | ||||
|
60 | qreal yPos = -(barSet->pos(category) - m_domainMinY -0.5) * scaleY + m_rect.bottom() - barHeight/2; | |||
|
61 | ||||
|
62 | qreal barWidth = barSet->value(category) * percentage * scaleX; | |||
|
63 | Bar* bar = m_bars.at(itemIndex); | |||
|
64 | ||||
|
65 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); | |||
|
66 | layout.append(rect); | |||
|
67 | bar->setPen(barSet->m_pen); | |||
|
68 | bar->setBrush(barSet->m_brush); | |||
|
69 | if (qFuzzyIsNull(barHeight)) { | |||
|
70 | bar->setVisible(false); | |||
|
71 | } else { | |||
|
72 | bar->setVisible(barsVisible); | |||
|
73 | } | |||
|
74 | ||||
|
75 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |||
|
76 | ||||
|
77 | if (!qFuzzyIsNull(m_series->d_func()->valueAt(set,category))) { | |||
|
78 | int p = m_series->d_func()->percentageAt(set,category) * 100; | |||
|
79 | QString vString(QString::number(p)); | |||
|
80 | vString.truncate(3); | |||
|
81 | vString.append("%"); | |||
|
82 | label->setText(vString); | |||
|
83 | } else { | |||
|
84 | label->setText(QString("")); | |||
|
85 | } | |||
|
86 | ||||
|
87 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) | |||
|
88 | ,yPos - barHeight/2 - label->boundingRect().height()/2); | |||
|
89 | label->setFont(barSet->m_labelFont); | |||
|
90 | label->setBrush(barSet->m_labelBrush); | |||
|
91 | ||||
|
92 | itemIndex++; | |||
|
93 | xPos += barWidth; | |||
|
94 | } | |||
|
95 | } | |||
|
96 | return layout; | |||
|
97 | } | |||
|
98 | ||||
|
99 | #include "moc_horizontalpercentbarchartitem_p.cpp" | |||
|
100 | ||||
|
101 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
102 |
@@ -0,0 +1,50 | |||||
|
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 | // W A R N I N G | |||
|
22 | // ------------- | |||
|
23 | // | |||
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |||
|
25 | // implementation detail. This header file may change from version to | |||
|
26 | // version without notice, or even be removed. | |||
|
27 | // | |||
|
28 | // We mean it. | |||
|
29 | ||||
|
30 | #ifndef HORIZONTALPERCENTBARCHARTITEM_P_H | |||
|
31 | #define HORIZONTALPERCENTBARCHARTITEM_P_H | |||
|
32 | ||||
|
33 | #include "abstractbarchartitem_p.h" | |||
|
34 | #include <QGraphicsItem> | |||
|
35 | ||||
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
37 | ||||
|
38 | class HorizontalPercentBarChartItem : public AbstractBarChartItem | |||
|
39 | { | |||
|
40 | Q_OBJECT | |||
|
41 | public: | |||
|
42 | HorizontalPercentBarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter); | |||
|
43 | ||||
|
44 | private: | |||
|
45 | virtual QVector<QRectF> calculateLayout(); | |||
|
46 | }; | |||
|
47 | ||||
|
48 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
49 | ||||
|
50 | #endif // HORIZONTALPERCENTBARCHARTITEM_P_H |
@@ -0,0 +1,75 | |||||
|
1 | #include "qhorizontalpercentbarseries.h" | |||
|
2 | #include "qhorizontalpercentbarseries_p.h" | |||
|
3 | #include "horizontalpercentbarchartitem_p.h" | |||
|
4 | #include "horizontalpercentbaranimation_p.h" | |||
|
5 | ||||
|
6 | #include "chartdataset_p.h" | |||
|
7 | #include "charttheme_p.h" | |||
|
8 | ||||
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
10 | ||||
|
11 | QHorizontalPercentBarSeries::QHorizontalPercentBarSeries(QObject *parent) : | |||
|
12 | QAbstractBarSeries(*new QHorizontalPercentBarSeriesPrivate(this), parent) | |||
|
13 | { | |||
|
14 | } | |||
|
15 | ||||
|
16 | QAbstractSeries::SeriesType QHorizontalPercentBarSeries::type() const | |||
|
17 | { | |||
|
18 | return QAbstractSeries::SeriesTypeHorizontalPercentBar; | |||
|
19 | } | |||
|
20 | ||||
|
21 | ||||
|
22 | ||||
|
23 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
|
24 | ||||
|
25 | QHorizontalPercentBarSeriesPrivate::QHorizontalPercentBarSeriesPrivate(QHorizontalPercentBarSeries *q) : QAbstractBarSeriesPrivate(q) | |||
|
26 | { | |||
|
27 | ||||
|
28 | } | |||
|
29 | ||||
|
30 | void QHorizontalPercentBarSeriesPrivate::scaleDomain(Domain& domain) | |||
|
31 | { | |||
|
32 | qreal minX(domain.minX()); | |||
|
33 | qreal minY(domain.minY()); | |||
|
34 | qreal maxX(domain.maxX()); | |||
|
35 | qreal maxY(domain.maxY()); | |||
|
36 | int tickXCount(domain.tickXCount()); | |||
|
37 | int tickYCount(domain.tickYCount()); | |||
|
38 | ||||
|
39 | qreal y = categoryCount(); | |||
|
40 | minX = 0; | |||
|
41 | maxX = 100; | |||
|
42 | minY = qMin(minY, - (qreal)0.5); | |||
|
43 | maxY = qMax(maxY, y - (qreal)0.5); | |||
|
44 | tickYCount = y+1; | |||
|
45 | ||||
|
46 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |||
|
47 | } | |||
|
48 | ||||
|
49 | Chart* QHorizontalPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |||
|
50 | { | |||
|
51 | Q_Q(QHorizontalPercentBarSeries); | |||
|
52 | ||||
|
53 | HorizontalPercentBarChartItem* bar = new HorizontalPercentBarChartItem(q,presenter); | |||
|
54 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |||
|
55 | bar->setAnimator(presenter->animator()); | |||
|
56 | bar->setAnimation(new HorizontalPercentBarAnimation(bar)); | |||
|
57 | } | |||
|
58 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |||
|
59 | return bar; | |||
|
60 | } | |||
|
61 | ||||
|
62 | QAbstractAxis::AxisType QHorizontalPercentBarSeriesPrivate::defaultAxisXType() const | |||
|
63 | { | |||
|
64 | return QAbstractAxis::AxisTypeValues; | |||
|
65 | } | |||
|
66 | ||||
|
67 | QAbstractAxis::AxisType QHorizontalPercentBarSeriesPrivate::defaultAxisYType() const | |||
|
68 | { | |||
|
69 | return QAbstractAxis::AxisTypeCategories; | |||
|
70 | } | |||
|
71 | ||||
|
72 | ||||
|
73 | #include "moc_qhorizontalpercentbarseries.cpp" | |||
|
74 | ||||
|
75 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,44 | |||||
|
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 | #ifndef QHORIZONTALPERCENTBARSERIES_H | |||
|
22 | #define QHORIZONTALPERCENTBARSERIES_H | |||
|
23 | ||||
|
24 | #include <qabstractbarseries.h> | |||
|
25 | ||||
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
27 | ||||
|
28 | class QHorizontalPercentBarSeriesPrivate; | |||
|
29 | ||||
|
30 | class QTCOMMERCIALCHART_EXPORT QHorizontalPercentBarSeries : public QAbstractBarSeries | |||
|
31 | { | |||
|
32 | Q_OBJECT | |||
|
33 | public: | |||
|
34 | explicit QHorizontalPercentBarSeries(QObject *parent = 0); | |||
|
35 | QAbstractSeries::SeriesType type() const; | |||
|
36 | ||||
|
37 | private: | |||
|
38 | Q_DECLARE_PRIVATE(QHorizontalPercentBarSeries) | |||
|
39 | Q_DISABLE_COPY(QHorizontalPercentBarSeries) | |||
|
40 | }; | |||
|
41 | ||||
|
42 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
43 | ||||
|
44 | #endif // QHORIZONTALPERCENTBARSERIES_H |
@@ -0,0 +1,53 | |||||
|
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 | // W A R N I N G | |||
|
22 | // ------------- | |||
|
23 | // | |||
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |||
|
25 | // implementation detail. This header file may change from version to | |||
|
26 | // version without notice, or even be removed. | |||
|
27 | // | |||
|
28 | // We mean it. | |||
|
29 | ||||
|
30 | #ifndef QHORIZONTALPERCENTBARSERIES_P_H | |||
|
31 | #define QHORIZONTALPERCENTBARSERIES_P_H | |||
|
32 | ||||
|
33 | #include "qabstractbarseries_p.h" | |||
|
34 | #include "domain_p.h" | |||
|
35 | ||||
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
37 | ||||
|
38 | class QHorizontalPercentBarSeriesPrivate: public QAbstractBarSeriesPrivate | |||
|
39 | { | |||
|
40 | public: | |||
|
41 | QHorizontalPercentBarSeriesPrivate(QHorizontalPercentBarSeries* q); | |||
|
42 | Chart* createGraphics(ChartPresenter* presenter); | |||
|
43 | void scaleDomain(Domain& domain); | |||
|
44 | QAbstractAxis::AxisType defaultAxisXType() const; | |||
|
45 | QAbstractAxis::AxisType defaultAxisYType() const; | |||
|
46 | ||||
|
47 | private: | |||
|
48 | Q_DECLARE_PUBLIC(QHorizontalPercentBarSeries) | |||
|
49 | }; | |||
|
50 | ||||
|
51 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
52 | ||||
|
53 | #endif // QHORIZONTALPERCENTBARSERIES_P_H |
@@ -1,28 +1,29 | |||||
1 | CURRENTLY_BUILDING_COMPONENTS = "examples" |
|
1 | CURRENTLY_BUILDING_COMPONENTS = "examples" | |
2 | !include( ../config.pri ) { |
|
2 | !include( ../config.pri ) { | |
3 | error( "Couldn't find the config.pri file!" ) |
|
3 | error( "Couldn't find the config.pri file!" ) | |
4 | } |
|
4 | } | |
5 |
|
5 | |||
6 | TEMPLATE = subdirs |
|
6 | TEMPLATE = subdirs | |
7 | SUBDIRS += \ |
|
7 | SUBDIRS += \ | |
8 | areachart \ |
|
8 | areachart \ | |
9 | customchart \ |
|
9 | customchart \ | |
10 | linechart \ |
|
10 | linechart \ | |
11 | percentbarchart \ |
|
11 | percentbarchart \ | |
12 | piechart \ |
|
12 | piechart \ | |
13 | piechartdrilldown \ |
|
13 | piechartdrilldown \ | |
14 | presenterchart \ |
|
14 | presenterchart \ | |
15 | scatterchart \ |
|
15 | scatterchart \ | |
16 | scatterinteractions \ |
|
16 | scatterinteractions \ | |
17 | splinechart \ |
|
17 | splinechart \ | |
18 | stackedbarchart \ |
|
18 | stackedbarchart \ | |
19 | stackedbarchartdrilldown \ |
|
19 | stackedbarchartdrilldown \ | |
20 | zoomlinechart \ |
|
20 | zoomlinechart \ | |
21 | modeldata \ |
|
21 | modeldata \ | |
22 | barchart \ |
|
22 | barchart \ | |
23 | legend \ |
|
23 | legend \ | |
24 | barmodelmapper \ |
|
24 | barmodelmapper \ | |
25 | qmlpiechart \ |
|
25 | qmlpiechart \ | |
26 | lineandbar \ |
|
26 | lineandbar \ | |
27 | horizontalbarchart \ |
|
27 | horizontalbarchart \ | |
28 | horizontalstackedbarchart |
|
28 | horizontalstackedbarchart \ | |
|
29 | horizontalpercentbarchart |
@@ -1,32 +1,33 | |||||
1 | INCLUDEPATH += $$PWD |
|
1 | INCLUDEPATH += $$PWD | |
2 | DEPENDPATH += $$PWD |
|
2 | DEPENDPATH += $$PWD | |
3 |
|
3 | |||
4 | SOURCES += \ |
|
4 | SOURCES += \ | |
5 | $$PWD/axisanimation.cpp \ |
|
5 | $$PWD/axisanimation.cpp \ | |
6 | $$PWD/chartanimator.cpp \ |
|
6 | $$PWD/chartanimator.cpp \ | |
7 | $$PWD/xyanimation.cpp \ |
|
7 | $$PWD/xyanimation.cpp \ | |
8 | $$PWD/pieanimation.cpp \ |
|
8 | $$PWD/pieanimation.cpp \ | |
9 | $$PWD/piesliceanimation.cpp \ |
|
9 | $$PWD/piesliceanimation.cpp \ | |
10 | $$PWD/splineanimation.cpp \ |
|
10 | $$PWD/splineanimation.cpp \ | |
11 | $$PWD/baranimation.cpp \ |
|
11 | $$PWD/baranimation.cpp \ | |
12 | $$PWD/stackedbaranimation.cpp \ |
|
12 | $$PWD/stackedbaranimation.cpp \ | |
13 | $$PWD/percentbaranimation.cpp \ |
|
13 | $$PWD/percentbaranimation.cpp \ | |
14 | $$PWD/abstractbaranimation.cpp \ |
|
14 | $$PWD/abstractbaranimation.cpp \ | |
15 | $$PWD/horizontalbaranimation.cpp \ |
|
15 | $$PWD/horizontalbaranimation.cpp \ | |
16 | $$PWD/horizontalstackedbaranimation.cpp |
|
16 | $$PWD/horizontalstackedbaranimation.cpp \ | |
17 |
|
17 | $$PWD/horizontalpercentbaranimation.cpp | ||
18 |
|
18 | |||
19 | PRIVATE_HEADERS += \ |
|
19 | PRIVATE_HEADERS += \ | |
20 | $$PWD/axisanimation_p.h \ |
|
20 | $$PWD/axisanimation_p.h \ | |
21 | $$PWD/chartanimator_p.h \ |
|
21 | $$PWD/chartanimator_p.h \ | |
22 | $$PWD/chartanimation_p.h \ |
|
22 | $$PWD/chartanimation_p.h \ | |
23 | $$PWD/xyanimation_p.h \ |
|
23 | $$PWD/xyanimation_p.h \ | |
24 | $$PWD/pieanimation_p.h \ |
|
24 | $$PWD/pieanimation_p.h \ | |
25 | $$PWD/piesliceanimation_p.h \ |
|
25 | $$PWD/piesliceanimation_p.h \ | |
26 | $$PWD/splineanimation_p.h \ |
|
26 | $$PWD/splineanimation_p.h \ | |
27 | $$PWD/baranimation_p.h \ |
|
27 | $$PWD/baranimation_p.h \ | |
28 | $$PWD/stackedbaranimation_p.h \ |
|
28 | $$PWD/stackedbaranimation_p.h \ | |
29 | $$PWD/percentbaranimation_p.h \ |
|
29 | $$PWD/percentbaranimation_p.h \ | |
30 | $$PWD/abstractbaranimation_p.h \ |
|
30 | $$PWD/abstractbaranimation_p.h \ | |
31 | $$PWD/horizontalbaranimation_p.h \ |
|
31 | $$PWD/horizontalbaranimation_p.h \ | |
32 | $$PWD/horizontalstackedbaranimation_p.h |
|
32 | $$PWD/horizontalstackedbaranimation_p.h \ | |
|
33 | $$PWD/horizontalpercentbaranimation_p.h |
@@ -1,64 +1,64 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "horizontalstackedbaranimation_p.h" |
|
21 | #include "horizontalstackedbaranimation_p.h" | |
22 | #include "abstractbarchartitem_p.h" |
|
22 | #include "abstractbarchartitem_p.h" | |
23 | #include <QTimer> |
|
23 | #include <QTimer> | |
24 |
|
24 | |||
25 | Q_DECLARE_METATYPE(QVector<QRectF>) |
|
25 | Q_DECLARE_METATYPE(QVector<QRectF>) | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | HorizontalStackedBarAnimation::HorizontalStackedBarAnimation(AbstractBarChartItem *item) : |
|
29 | HorizontalStackedBarAnimation::HorizontalStackedBarAnimation(AbstractBarChartItem *item) : | |
30 | AbstractBarAnimation(item) |
|
30 | AbstractBarAnimation(item) | |
31 | { |
|
31 | { | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | HorizontalStackedBarAnimation::~HorizontalStackedBarAnimation() |
|
34 | HorizontalStackedBarAnimation::~HorizontalStackedBarAnimation() | |
35 | { |
|
35 | { | |
36 |
|
36 | |||
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 |
|
39 | |||
40 | QVariant HorizontalStackedBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const |
|
40 | QVariant HorizontalStackedBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const | |
41 | { |
|
41 | { | |
42 | QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from); |
|
42 | QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from); | |
43 | QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to); |
|
43 | QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to); | |
44 | QVector<QRectF> result; |
|
44 | QVector<QRectF> result; | |
45 |
|
45 | |||
46 | Q_ASSERT(startVector.count() == endVector.count()); |
|
46 | Q_ASSERT(startVector.count() == endVector.count()); | |
47 |
|
47 | |||
48 | qreal xAxis = m_item->geometry().x(); |
|
48 | qreal xAxis = m_item->geometry().x(); | |
49 |
|
49 | |||
50 | for(int i = 0; i < startVector.count(); i++) { |
|
50 | for(int i = 0; i < startVector.count(); i++) { | |
51 | qreal h = endVector[i].height(); |
|
51 | qreal h = endVector[i].height(); | |
52 |
qreal w = |
|
52 | qreal w = endVector[i].width() * progress; | |
53 | qreal x = xAxis + ((endVector[i].left() - xAxis) * progress); |
|
53 | qreal x = xAxis + ((endVector[i].left() - xAxis) * progress); | |
54 | qreal y = endVector[i].top(); |
|
54 | qreal y = endVector[i].top(); | |
55 |
|
55 | |||
56 | QRectF value(x,y,w,h); |
|
56 | QRectF value(x,y,w,h); | |
57 | result << value; |
|
57 | result << value; | |
58 | } |
|
58 | } | |
59 | return qVariantFromValue(result); |
|
59 | return qVariantFromValue(result); | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | #include "moc_horizontalstackedbaranimation_p.cpp" |
|
62 | #include "moc_horizontalstackedbaranimation_p.cpp" | |
63 |
|
63 | |||
64 | QTCOMMERCIALCHART_END_NAMESPACE |
|
64 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,50 +1,55 | |||||
1 | INCLUDEPATH += $$PWD |
|
1 | INCLUDEPATH += $$PWD | |
2 | DEPENDPATH += $$PWD |
|
2 | DEPENDPATH += $$PWD | |
3 |
|
3 | |||
4 | SOURCES += \ |
|
4 | SOURCES += \ | |
5 | $$PWD/bar.cpp \ |
|
5 | $$PWD/bar.cpp \ | |
6 | $$PWD/abstractbarchartitem.cpp \ |
|
6 | $$PWD/abstractbarchartitem.cpp \ | |
7 | $$PWD/percentbarchartitem.cpp \ |
|
7 | $$PWD/percentbarchartitem.cpp \ | |
8 | $$PWD/barchartitem.cpp \ |
|
8 | $$PWD/barchartitem.cpp \ | |
9 | $$PWD/qabstractbarseries.cpp \ |
|
9 | $$PWD/qabstractbarseries.cpp \ | |
10 | $$PWD/qbarset.cpp \ |
|
10 | $$PWD/qbarset.cpp \ | |
11 | $$PWD/qpercentbarseries.cpp \ |
|
11 | $$PWD/qpercentbarseries.cpp \ | |
12 | $$PWD/qstackedbarseries.cpp \ |
|
12 | $$PWD/qstackedbarseries.cpp \ | |
13 | $$PWD/qbarseries.cpp \ |
|
13 | $$PWD/qbarseries.cpp \ | |
14 | $$PWD/stackedbarchartitem.cpp \ |
|
14 | $$PWD/stackedbarchartitem.cpp \ | |
15 | $$PWD/qbarmodelmapper.cpp \ |
|
15 | $$PWD/qbarmodelmapper.cpp \ | |
16 | $$PWD/qvbarmodelmapper.cpp \ |
|
16 | $$PWD/qvbarmodelmapper.cpp \ | |
17 | $$PWD/qhbarmodelmapper.cpp \ |
|
17 | $$PWD/qhbarmodelmapper.cpp \ | |
18 | $$PWD/qhorizontalbarseries.cpp \ |
|
18 | $$PWD/qhorizontalbarseries.cpp \ | |
19 | $$PWD/horizontalbarchartitem.cpp \ |
|
19 | $$PWD/horizontalbarchartitem.cpp \ | |
20 | $$PWD/qhorizontalstackedbarseries.cpp \ |
|
20 | $$PWD/qhorizontalstackedbarseries.cpp \ | |
21 | $$PWD/horizontalstackedbarchartitem.cpp |
|
21 | $$PWD/horizontalstackedbarchartitem.cpp \ | |
|
22 | $$PWD/qhorizontalpercentbarseries.cpp \ | |||
|
23 | $$PWD/horizontalpercentbarchartitem.cpp | |||
22 |
|
24 | |||
23 | PRIVATE_HEADERS += \ |
|
25 | PRIVATE_HEADERS += \ | |
24 | $$PWD/bar_p.h \ |
|
26 | $$PWD/bar_p.h \ | |
25 | $$PWD/abstractbarchartitem_p.h \ |
|
27 | $$PWD/abstractbarchartitem_p.h \ | |
26 | $$PWD/percentbarchartitem_p.h \ |
|
28 | $$PWD/percentbarchartitem_p.h \ | |
27 | $$PWD/stackedbarchartitem_p.h \ |
|
29 | $$PWD/stackedbarchartitem_p.h \ | |
28 | $$PWD/barchartitem_p.h \ |
|
30 | $$PWD/barchartitem_p.h \ | |
29 | $$PWD/qbarset_p.h \ |
|
31 | $$PWD/qbarset_p.h \ | |
30 | $$PWD/qabstractbarseries_p.h \ |
|
32 | $$PWD/qabstractbarseries_p.h \ | |
31 | $$PWD/qstackedbarseries_p.h\ |
|
33 | $$PWD/qstackedbarseries_p.h\ | |
32 | $$PWD/qpercentbarseries_p.h \ |
|
34 | $$PWD/qpercentbarseries_p.h \ | |
33 | $$PWD/qbarseries_p.h \ |
|
35 | $$PWD/qbarseries_p.h \ | |
34 | $$PWD/qbarmodelmapper_p.h \ |
|
36 | $$PWD/qbarmodelmapper_p.h \ | |
35 | $$PWD/qhorizontalbarseries_p.h \ |
|
37 | $$PWD/qhorizontalbarseries_p.h \ | |
36 | $$PWD/horizontalbarchartitem_p.h \ |
|
38 | $$PWD/horizontalbarchartitem_p.h \ | |
37 | $$PWD/qhorizontalstackedbarseries_p.h \ |
|
39 | $$PWD/qhorizontalstackedbarseries_p.h \ | |
38 | $$PWD/horizontalstackedbarchartitem_p.h |
|
40 | $$PWD/horizontalstackedbarchartitem_p.h \ | |
|
41 | $$PWD/qhorizontalpercentbarseries_p.h \ | |||
|
42 | $$PWD/horizontalpercentbarchartitem_p.h | |||
39 |
|
43 | |||
40 | PUBLIC_HEADERS += \ |
|
44 | PUBLIC_HEADERS += \ | |
41 | $$PWD/qabstractbarseries.h \ |
|
45 | $$PWD/qabstractbarseries.h \ | |
42 | $$PWD/qbarset.h \ |
|
46 | $$PWD/qbarset.h \ | |
43 | $$PWD/qpercentbarseries.h \ |
|
47 | $$PWD/qpercentbarseries.h \ | |
44 | $$PWD/qstackedbarseries.h \ |
|
48 | $$PWD/qstackedbarseries.h \ | |
45 | $$PWD/qbarseries.h \ |
|
49 | $$PWD/qbarseries.h \ | |
46 | $$PWD/qbarmodelmapper.h \ |
|
50 | $$PWD/qbarmodelmapper.h \ | |
47 | $$PWD/qvbarmodelmapper.h \ |
|
51 | $$PWD/qvbarmodelmapper.h \ | |
48 | $$PWD/qhbarmodelmapper.h \ |
|
52 | $$PWD/qhbarmodelmapper.h \ | |
49 | $$PWD/qhorizontalbarseries.h \ |
|
53 | $$PWD/qhorizontalbarseries.h \ | |
50 | $$PWD/qhorizontalstackedbarseries.h |
|
54 | $$PWD/qhorizontalstackedbarseries.h \ | |
|
55 | $$PWD/qhorizontalpercentbarseries.h |
@@ -1,84 +1,85 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef ABSTRACTBARSERIES_H |
|
21 | #ifndef ABSTRACTBARSERIES_H | |
22 | #define ABSTRACTBARSERIES_H |
|
22 | #define ABSTRACTBARSERIES_H | |
23 |
|
23 | |||
24 | #include <qabstractseries.h> |
|
24 | #include <qabstractseries.h> | |
25 | #include <QStringList> |
|
25 | #include <QStringList> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | class QBarSet; |
|
29 | class QBarSet; | |
30 | class QAbstractBarSeriesPrivate; |
|
30 | class QAbstractBarSeriesPrivate; | |
31 |
|
31 | |||
32 | // Container for series |
|
32 | // Container for series | |
33 | class QTCOMMERCIALCHART_EXPORT QAbstractBarSeries : public QAbstractSeries |
|
33 | class QTCOMMERCIALCHART_EXPORT QAbstractBarSeries : public QAbstractSeries | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth) |
|
36 | Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth) | |
37 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
37 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
38 | Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
38 | Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) | |
39 |
|
39 | |||
40 | protected: |
|
40 | protected: | |
41 | explicit QAbstractBarSeries(QObject *parent = 0); |
|
41 | explicit QAbstractBarSeries(QObject *parent = 0); | |
42 |
|
42 | |||
43 | public: |
|
43 | public: | |
44 | virtual ~QAbstractBarSeries(); |
|
44 | virtual ~QAbstractBarSeries(); | |
45 |
|
45 | |||
46 | void setBarWidth(qreal width); |
|
46 | void setBarWidth(qreal width); | |
47 | qreal barWidth() const; |
|
47 | qreal barWidth() const; | |
48 |
|
48 | |||
49 | bool append(QBarSet *set); |
|
49 | bool append(QBarSet *set); | |
50 | bool remove(QBarSet *set); |
|
50 | bool remove(QBarSet *set); | |
51 | bool append(QList<QBarSet* > sets); |
|
51 | bool append(QList<QBarSet* > sets); | |
52 | bool insert(int index, QBarSet *set); |
|
52 | bool insert(int index, QBarSet *set); | |
53 | int count() const; |
|
53 | int count() const; | |
54 | QList<QBarSet*> barSets() const; |
|
54 | QList<QBarSet*> barSets() const; | |
55 | void clear(); |
|
55 | void clear(); | |
56 |
|
56 | |||
57 | void setLabelsVisible(bool visible = true); |
|
57 | void setLabelsVisible(bool visible = true); | |
58 | bool isLabelsVisible() const; |
|
58 | bool isLabelsVisible() const; | |
59 |
|
59 | |||
60 | protected: |
|
60 | protected: | |
61 | explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d,QObject *parent = 0); |
|
61 | explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d,QObject *parent = 0); | |
62 |
|
62 | |||
63 | Q_SIGNALS: |
|
63 | Q_SIGNALS: | |
64 | void clicked(int index, QBarSet *barset); |
|
64 | void clicked(int index, QBarSet *barset); | |
65 | void hovered(bool status, QBarSet *barset); |
|
65 | void hovered(bool status, QBarSet *barset); | |
66 | void countChanged(); |
|
66 | void countChanged(); | |
67 | void labelsVisibleChanged(); |
|
67 | void labelsVisibleChanged(); | |
68 |
|
68 | |||
69 | void barsetsAdded(QList<QBarSet*> sets); |
|
69 | void barsetsAdded(QList<QBarSet*> sets); | |
70 | void barsetsRemoved(QList<QBarSet*> sets); |
|
70 | void barsetsRemoved(QList<QBarSet*> sets); | |
71 |
|
71 | |||
72 | protected: |
|
72 | protected: | |
73 | Q_DECLARE_PRIVATE(QAbstractBarSeries) |
|
73 | Q_DECLARE_PRIVATE(QAbstractBarSeries) | |
74 | friend class AbstractBarChartItem; |
|
74 | friend class AbstractBarChartItem; | |
75 | friend class PercentBarChartItem; |
|
75 | friend class PercentBarChartItem; | |
76 | friend class StackedBarChartItem; |
|
76 | friend class StackedBarChartItem; | |
77 | friend class BarChartItem; |
|
77 | friend class BarChartItem; | |
78 | friend class HorizontalBarChartItem; |
|
78 | friend class HorizontalBarChartItem; | |
79 | friend class HorizontalStackedBarChartItem; |
|
79 | friend class HorizontalStackedBarChartItem; | |
|
80 | friend class HorizontalPercentBarChartItem; | |||
80 | }; |
|
81 | }; | |
81 |
|
82 | |||
82 | QTCOMMERCIALCHART_END_NAMESPACE |
|
83 | QTCOMMERCIALCHART_END_NAMESPACE | |
83 |
|
84 | |||
84 | #endif // ABSTRACTBARSERIES_H |
|
85 | #endif // ABSTRACTBARSERIES_H |
@@ -1,117 +1,118 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QBARSET_H |
|
21 | #ifndef QBARSET_H | |
22 | #define QBARSET_H |
|
22 | #define QBARSET_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <QPen> |
|
25 | #include <QPen> | |
26 | #include <QBrush> |
|
26 | #include <QBrush> | |
27 | #include <QFont> |
|
27 | #include <QFont> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 | class QBarSetPrivate; |
|
30 | class QBarSetPrivate; | |
31 |
|
31 | |||
32 | class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject |
|
32 | class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
|
35 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) | |
36 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
36 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
37 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
|
37 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |
38 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) |
|
38 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) | |
39 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) |
|
39 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) | |
40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
41 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
41 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
42 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) |
|
42 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) | |
43 |
|
43 | |||
44 | public: |
|
44 | public: | |
45 | explicit QBarSet(const QString label, QObject *parent = 0); |
|
45 | explicit QBarSet(const QString label, QObject *parent = 0); | |
46 | virtual ~QBarSet(); |
|
46 | virtual ~QBarSet(); | |
47 |
|
47 | |||
48 | void setLabel(const QString label); |
|
48 | void setLabel(const QString label); | |
49 | QString label() const; |
|
49 | QString label() const; | |
50 |
|
50 | |||
51 | void append(const qreal value); |
|
51 | void append(const qreal value); | |
52 | void append(const QList<qreal> &values); |
|
52 | void append(const QList<qreal> &values); | |
53 |
|
53 | |||
54 | QBarSet& operator << (const qreal &value); |
|
54 | QBarSet& operator << (const qreal &value); | |
55 |
|
55 | |||
56 | void insert(const int index, const qreal value); |
|
56 | void insert(const int index, const qreal value); | |
57 | void remove(const int index, const int count = 1); |
|
57 | void remove(const int index, const int count = 1); | |
58 | void replace(const int index, const qreal value); |
|
58 | void replace(const int index, const qreal value); | |
59 | qreal at(const int index) const; |
|
59 | qreal at(const int index) const; | |
60 | qreal operator [] (const int index) const; |
|
60 | qreal operator [] (const int index) const; | |
61 | int count() const; |
|
61 | int count() const; | |
62 | qreal sum() const; |
|
62 | qreal sum() const; | |
63 |
|
63 | |||
64 | void setPen(const QPen &pen); |
|
64 | void setPen(const QPen &pen); | |
65 | QPen pen() const; |
|
65 | QPen pen() const; | |
66 |
|
66 | |||
67 | void setBrush(const QBrush &brush); |
|
67 | void setBrush(const QBrush &brush); | |
68 | QBrush brush() const; |
|
68 | QBrush brush() const; | |
69 |
|
69 | |||
70 | void setLabelBrush(const QBrush &brush); |
|
70 | void setLabelBrush(const QBrush &brush); | |
71 | QBrush labelBrush() const; |
|
71 | QBrush labelBrush() const; | |
72 |
|
72 | |||
73 | void setLabelFont(const QFont &font); |
|
73 | void setLabelFont(const QFont &font); | |
74 | QFont labelFont() const; |
|
74 | QFont labelFont() const; | |
75 |
|
75 | |||
76 | QColor color(); |
|
76 | QColor color(); | |
77 | void setColor(QColor color); |
|
77 | void setColor(QColor color); | |
78 |
|
78 | |||
79 | QColor borderColor(); |
|
79 | QColor borderColor(); | |
80 | void setBorderColor(QColor color); |
|
80 | void setBorderColor(QColor color); | |
81 |
|
81 | |||
82 | QColor labelColor(); |
|
82 | QColor labelColor(); | |
83 | void setLabelColor(QColor color); |
|
83 | void setLabelColor(QColor color); | |
84 |
|
84 | |||
85 | Q_SIGNALS: |
|
85 | Q_SIGNALS: | |
86 | void clicked(int index); |
|
86 | void clicked(int index); | |
87 | void hovered(bool status); |
|
87 | void hovered(bool status); | |
88 | void penChanged(); |
|
88 | void penChanged(); | |
89 | void brushChanged(); |
|
89 | void brushChanged(); | |
90 | void labelChanged(); |
|
90 | void labelChanged(); | |
91 | void labelBrushChanged(); |
|
91 | void labelBrushChanged(); | |
92 | void labelFontChanged(); |
|
92 | void labelFontChanged(); | |
93 | void colorChanged(QColor color); |
|
93 | void colorChanged(QColor color); | |
94 | void borderColorChanged(QColor color); |
|
94 | void borderColorChanged(QColor color); | |
95 | void labelColorChanged(QColor color); |
|
95 | void labelColorChanged(QColor color); | |
96 |
|
96 | |||
97 | void valuesAdded(int index, int count); |
|
97 | void valuesAdded(int index, int count); | |
98 | void valuesRemoved(int index, int count); |
|
98 | void valuesRemoved(int index, int count); | |
99 | void valueChanged(int index); |
|
99 | void valueChanged(int index); | |
100 |
|
100 | |||
101 | private: |
|
101 | private: | |
102 | QScopedPointer<QBarSetPrivate> d_ptr; |
|
102 | QScopedPointer<QBarSetPrivate> d_ptr; | |
103 | Q_DISABLE_COPY(QBarSet) |
|
103 | Q_DISABLE_COPY(QBarSet) | |
104 | friend class QAbstractBarSeries; |
|
104 | friend class QAbstractBarSeries; | |
105 | friend class BarLegendMarker; |
|
105 | friend class BarLegendMarker; | |
106 | friend class AbstractBarChartItem; |
|
106 | friend class AbstractBarChartItem; | |
107 | friend class QAbstractBarSeriesPrivate; |
|
107 | friend class QAbstractBarSeriesPrivate; | |
108 | friend class StackedBarChartItem; |
|
108 | friend class StackedBarChartItem; | |
109 | friend class PercentBarChartItem; |
|
109 | friend class PercentBarChartItem; | |
110 | friend class BarChartItem; |
|
110 | friend class BarChartItem; | |
111 | friend class HorizontalBarChartItem; |
|
111 | friend class HorizontalBarChartItem; | |
112 | friend class HorizontalStackedBarChartItem; |
|
112 | friend class HorizontalStackedBarChartItem; | |
|
113 | friend class HorizontalPercentBarChartItem; | |||
113 | }; |
|
114 | }; | |
114 |
|
115 | |||
115 | QTCOMMERCIALCHART_END_NAMESPACE |
|
116 | QTCOMMERCIALCHART_END_NAMESPACE | |
116 |
|
117 | |||
117 | #endif // QBARSET_H |
|
118 | #endif // QBARSET_H |
@@ -1,78 +1,78 | |||||
1 | #include "qhorizontalbarseries.h" |
|
1 | #include "qhorizontalbarseries.h" | |
2 | #include "qhorizontalbarseries_p.h" |
|
2 | #include "qhorizontalbarseries_p.h" | |
3 | #include "horizontalbarchartitem_p.h" |
|
3 | #include "horizontalbarchartitem_p.h" | |
4 | #include "horizontalbaranimation_p.h" |
|
4 | #include "horizontalbaranimation_p.h" | |
5 |
|
5 | |||
6 | #include "chartdataset_p.h" |
|
6 | #include "chartdataset_p.h" | |
7 | #include "charttheme_p.h" |
|
7 | #include "charttheme_p.h" | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
12 | QHorizontalBarSeries::QHorizontalBarSeries(QObject *parent) : |
|
12 | QHorizontalBarSeries::QHorizontalBarSeries(QObject *parent) : | |
13 | QAbstractBarSeries(*new QHorizontalBarSeriesPrivate(this), parent) |
|
13 | QAbstractBarSeries(*new QHorizontalBarSeriesPrivate(this), parent) | |
14 | { |
|
14 | { | |
15 | } |
|
15 | } | |
16 |
|
16 | |||
17 | QAbstractSeries::SeriesType QHorizontalBarSeries::type() const |
|
17 | QAbstractSeries::SeriesType QHorizontalBarSeries::type() const | |
18 | { |
|
18 | { | |
19 | return QAbstractSeries::SeriesTypeHorizontalBar; |
|
19 | return QAbstractSeries::SeriesTypeHorizontalBar; | |
20 | } |
|
20 | } | |
21 |
|
21 | |||
22 |
|
22 | |||
23 |
|
23 | |||
24 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
24 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
25 |
|
25 | |||
26 | QHorizontalBarSeriesPrivate::QHorizontalBarSeriesPrivate(QHorizontalBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
26 | QHorizontalBarSeriesPrivate::QHorizontalBarSeriesPrivate(QHorizontalBarSeries *q) : QAbstractBarSeriesPrivate(q) | |
27 | { |
|
27 | { | |
28 |
|
28 | |||
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | void QHorizontalBarSeriesPrivate::scaleDomain(Domain& domain) |
|
31 | void QHorizontalBarSeriesPrivate::scaleDomain(Domain& domain) | |
32 | { |
|
32 | { | |
33 | qreal minX(domain.minX()); |
|
33 | qreal minX(domain.minX()); | |
34 | qreal minY(domain.minY()); |
|
34 | qreal minY(domain.minY()); | |
35 | qreal maxX(domain.maxX()); |
|
35 | qreal maxX(domain.maxX()); | |
36 | qreal maxY(domain.maxY()); |
|
36 | qreal maxY(domain.maxY()); | |
37 | int tickXCount(domain.tickXCount()); |
|
37 | int tickXCount(domain.tickXCount()); | |
38 | int tickYCount(domain.tickYCount()); |
|
38 | int tickYCount(domain.tickYCount()); | |
39 |
|
39 | |||
40 | qreal y = categoryCount(); |
|
40 | qreal y = categoryCount(); | |
41 | qreal x = max(); |
|
41 | qreal x = max(); | |
42 | minX = qMin(minX, x); |
|
42 | minX = qMin(minX, x); | |
43 | minY = qMin(minY, -0.5); |
|
43 | minY = qMin(minY, - (qreal)0.5); | |
44 | maxX = qMax(maxX, x); |
|
44 | maxX = qMax(maxX, x); | |
45 | maxY = qMax(maxY, y -0.5); |
|
45 | maxY = qMax(maxY, y - (qreal)0.5); | |
46 | tickYCount = y+1; |
|
46 | tickYCount = y+1; | |
47 |
|
47 | |||
48 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
48 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 |
|
51 | |||
52 | Chart* QHorizontalBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
52 | Chart* QHorizontalBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
53 | { |
|
53 | { | |
54 | Q_Q(QHorizontalBarSeries); |
|
54 | Q_Q(QHorizontalBarSeries); | |
55 |
|
55 | |||
56 | HorizontalBarChartItem* bar = new HorizontalBarChartItem(q,presenter); |
|
56 | HorizontalBarChartItem* bar = new HorizontalBarChartItem(q,presenter); | |
57 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
57 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
58 | bar->setAnimator(presenter->animator()); |
|
58 | bar->setAnimator(presenter->animator()); | |
59 | bar->setAnimation(new HorizontalBarAnimation(bar)); |
|
59 | bar->setAnimation(new HorizontalBarAnimation(bar)); | |
60 | } |
|
60 | } | |
61 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
61 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
62 | return bar; |
|
62 | return bar; | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | QAbstractAxis::AxisType QHorizontalBarSeriesPrivate::defaultAxisXType() const |
|
65 | QAbstractAxis::AxisType QHorizontalBarSeriesPrivate::defaultAxisXType() const | |
66 | { |
|
66 | { | |
67 | return QAbstractAxis::AxisTypeValues; |
|
67 | return QAbstractAxis::AxisTypeValues; | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | QAbstractAxis::AxisType QHorizontalBarSeriesPrivate::defaultAxisYType() const |
|
70 | QAbstractAxis::AxisType QHorizontalBarSeriesPrivate::defaultAxisYType() const | |
71 | { |
|
71 | { | |
72 | return QAbstractAxis::AxisTypeCategories; |
|
72 | return QAbstractAxis::AxisTypeCategories; | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 |
|
75 | |||
76 | #include "moc_qhorizontalbarseries.cpp" |
|
76 | #include "moc_qhorizontalbarseries.cpp" | |
77 |
|
77 | |||
78 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,76 +1,76 | |||||
1 | #include "qhorizontalstackedbarseries.h" |
|
1 | #include "qhorizontalstackedbarseries.h" | |
2 | #include "qhorizontalstackedbarseries_p.h" |
|
2 | #include "qhorizontalstackedbarseries_p.h" | |
3 | #include "horizontalstackedbarchartitem_p.h" |
|
3 | #include "horizontalstackedbarchartitem_p.h" | |
4 | #include "horizontalstackedbaranimation_p.h" |
|
4 | #include "horizontalstackedbaranimation_p.h" | |
5 |
|
5 | |||
6 | #include "chartdataset_p.h" |
|
6 | #include "chartdataset_p.h" | |
7 | #include "charttheme_p.h" |
|
7 | #include "charttheme_p.h" | |
8 |
|
8 | |||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 |
|
10 | |||
11 | QHorizontalStackedBarSeries::QHorizontalStackedBarSeries(QObject *parent) : |
|
11 | QHorizontalStackedBarSeries::QHorizontalStackedBarSeries(QObject *parent) : | |
12 | QAbstractBarSeries(*new QHorizontalStackedBarSeriesPrivate(this), parent) |
|
12 | QAbstractBarSeries(*new QHorizontalStackedBarSeriesPrivate(this), parent) | |
13 | { |
|
13 | { | |
14 | } |
|
14 | } | |
15 |
|
15 | |||
16 | QAbstractSeries::SeriesType QHorizontalStackedBarSeries::type() const |
|
16 | QAbstractSeries::SeriesType QHorizontalStackedBarSeries::type() const | |
17 | { |
|
17 | { | |
18 | return QAbstractSeries::SeriesTypeHorizontalStackedBar; |
|
18 | return QAbstractSeries::SeriesTypeHorizontalStackedBar; | |
19 | } |
|
19 | } | |
20 |
|
20 | |||
21 |
|
21 | |||
22 |
|
22 | |||
23 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
23 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
24 |
|
24 | |||
25 | QHorizontalStackedBarSeriesPrivate::QHorizontalStackedBarSeriesPrivate(QHorizontalStackedBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
25 | QHorizontalStackedBarSeriesPrivate::QHorizontalStackedBarSeriesPrivate(QHorizontalStackedBarSeries *q) : QAbstractBarSeriesPrivate(q) | |
26 | { |
|
26 | { | |
27 |
|
27 | |||
28 | } |
|
28 | } | |
29 |
|
29 | |||
30 | void QHorizontalStackedBarSeriesPrivate::scaleDomain(Domain& domain) |
|
30 | void QHorizontalStackedBarSeriesPrivate::scaleDomain(Domain& domain) | |
31 | { |
|
31 | { | |
32 | qreal minX(domain.minX()); |
|
32 | qreal minX(domain.minX()); | |
33 | qreal minY(domain.minY()); |
|
33 | qreal minY(domain.minY()); | |
34 | qreal maxX(domain.maxX()); |
|
34 | qreal maxX(domain.maxX()); | |
35 | qreal maxY(domain.maxY()); |
|
35 | qreal maxY(domain.maxY()); | |
36 | int tickXCount(domain.tickXCount()); |
|
36 | int tickXCount(domain.tickXCount()); | |
37 | int tickYCount(domain.tickYCount()); |
|
37 | int tickYCount(domain.tickYCount()); | |
38 |
|
38 | |||
39 | qreal y = categoryCount(); |
|
39 | qreal y = categoryCount(); | |
40 | qreal x = maxCategorySum(); |
|
40 | qreal x = maxCategorySum(); | |
41 | minX = qMin(minX, x); |
|
41 | minX = qMin(minX, x); | |
42 | minY = qMin(minY, -0.5); |
|
42 | minY = qMin(minY, - (qreal)0.5); | |
43 | maxX = qMax(maxX, x); |
|
43 | maxX = qMax(maxX, x); | |
44 | maxY = qMax(maxY, y -0.5); |
|
44 | maxY = qMax(maxY, y - (qreal)0.5); | |
45 | tickYCount = y+1; |
|
45 | tickYCount = y+1; | |
46 |
|
46 | |||
47 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
47 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | Chart* QHorizontalStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
50 | Chart* QHorizontalStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
51 | { |
|
51 | { | |
52 | Q_Q(QHorizontalStackedBarSeries); |
|
52 | Q_Q(QHorizontalStackedBarSeries); | |
53 |
|
53 | |||
54 | HorizontalStackedBarChartItem* bar = new HorizontalStackedBarChartItem(q,presenter); |
|
54 | HorizontalStackedBarChartItem* bar = new HorizontalStackedBarChartItem(q,presenter); | |
55 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
55 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
56 | bar->setAnimator(presenter->animator()); |
|
56 | bar->setAnimator(presenter->animator()); | |
57 | bar->setAnimation(new HorizontalStackedBarAnimation(bar)); |
|
57 | bar->setAnimation(new HorizontalStackedBarAnimation(bar)); | |
58 | } |
|
58 | } | |
59 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
59 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
60 | return bar; |
|
60 | return bar; | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | QAbstractAxis::AxisType QHorizontalStackedBarSeriesPrivate::defaultAxisXType() const |
|
63 | QAbstractAxis::AxisType QHorizontalStackedBarSeriesPrivate::defaultAxisXType() const | |
64 | { |
|
64 | { | |
65 | return QAbstractAxis::AxisTypeValues; |
|
65 | return QAbstractAxis::AxisTypeValues; | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | QAbstractAxis::AxisType QHorizontalStackedBarSeriesPrivate::defaultAxisYType() const |
|
68 | QAbstractAxis::AxisType QHorizontalStackedBarSeriesPrivate::defaultAxisYType() const | |
69 | { |
|
69 | { | |
70 | return QAbstractAxis::AxisTypeCategories; |
|
70 | return QAbstractAxis::AxisTypeCategories; | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | #include "moc_qhorizontalstackedbarseries.cpp" |
|
74 | #include "moc_qhorizontalstackedbarseries.cpp" | |
75 |
|
75 | |||
76 | QTCOMMERCIALCHART_END_NAMESPACE |
|
76 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now