@@ -6,7 +6,6 CURRENTLY_BUILDING_COMPONENTS = "examples" | |||||
6 | TEMPLATE = subdirs |
|
6 | TEMPLATE = subdirs | |
7 | SUBDIRS += \ |
|
7 | SUBDIRS += \ | |
8 | areachart \ |
|
8 | areachart \ | |
9 | barchart \ |
|
|||
10 | #customchart \ |
|
9 | #customchart \ | |
11 | linechart \ |
|
10 | linechart \ | |
12 | percentbarchart \ |
|
11 | percentbarchart \ |
@@ -25,7 +25,7 | |||||
25 | #include <QLabel> |
|
25 | #include <QLabel> | |
26 | #include <QDebug> |
|
26 | #include <QDebug> | |
27 | #include <QBarSet> |
|
27 | #include <QBarSet> | |
28 | #include <QBarSeries> |
|
28 | #include <QGroupedBarSeries> | |
29 | #include <QLegend> |
|
29 | #include <QLegend> | |
30 | #include <QFormLayout> |
|
30 | #include <QFormLayout> | |
31 |
|
31 | |||
@@ -118,7 +118,7 MainWidget::MainWidget(QWidget *parent) : | |||||
118 |
|
118 | |||
119 | void MainWidget::createSeries() |
|
119 | void MainWidget::createSeries() | |
120 | { |
|
120 | { | |
121 | m_series = new QBarSeries(); |
|
121 | m_series = new QGroupedBarSeries(); | |
122 | addBarset(); |
|
122 | addBarset(); | |
123 | addBarset(); |
|
123 | addBarset(); | |
124 | addBarset(); |
|
124 | addBarset(); | |
@@ -196,7 +196,7 void MainWidget::addBarset() | |||||
196 | { |
|
196 | { | |
197 | QBarSet *barSet = new QBarSet(QString("set ") + QString::number(m_series->count())); |
|
197 | QBarSet *barSet = new QBarSet(QString("set ") + QString::number(m_series->count())); | |
198 | qreal delta = m_series->count() * 0.1; |
|
198 | qreal delta = m_series->count() * 0.1; | |
199 | *barSet << QPointF(0.0 + delta, 1 + delta) << QPointF(1.0 + delta, 2 + delta) << QPointF(2.0 + delta, 3 + delta) << QPointF(3.0 + delta, 4 + delta); |
|
199 | *barSet << 1 + delta << 2 + delta << 3 + delta << 4 + delta; | |
200 | m_series->append(barSet); |
|
200 | m_series->append(barSet); | |
201 | } |
|
201 | } | |
202 |
|
202 |
@@ -30,7 +30,7 | |||||
30 | #include <QGraphicsGridLayout> |
|
30 | #include <QGraphicsGridLayout> | |
31 | #include <QDoubleSpinBox> |
|
31 | #include <QDoubleSpinBox> | |
32 | #include <QGroupBox> |
|
32 | #include <QGroupBox> | |
33 | #include <QBarSeries> |
|
33 | #include <QGroupedBarSeries> | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
35 | QTCOMMERCIALCHART_USE_NAMESPACE | |
36 |
|
36 | |||
@@ -66,7 +66,7 public slots: | |||||
66 | private: |
|
66 | private: | |
67 |
|
67 | |||
68 | QChart *m_chart; |
|
68 | QChart *m_chart; | |
69 | QBarSeries *m_series; |
|
69 | QGroupedBarSeries *m_series; | |
70 |
|
70 | |||
71 | QChartView *m_chartView; |
|
71 | QChartView *m_chartView; | |
72 | QGridLayout *m_mainLayout; |
|
72 | QGridLayout *m_mainLayout; |
@@ -57,8 +57,6 void DeclarativeBarSet::setValues(QVariantList values) | |||||
57 | for (int i(0); i < values.count(); i++) { |
|
57 | for (int i(0); i < values.count(); i++) { | |
58 | if (values.at(i).canConvert(QVariant::Double)) |
|
58 | if (values.at(i).canConvert(QVariant::Double)) | |
59 | QBarSet::append(values[i].toDouble()); |
|
59 | QBarSet::append(values[i].toDouble()); | |
60 | else if (values.at(i).canConvert(QVariant::PointF)) |
|
|||
61 | QBarSet::append(values[i].toPointF()); |
|
|||
62 | } |
|
60 | } | |
63 | } |
|
61 | } | |
64 |
|
62 |
@@ -47,11 +47,9 public: | |||||
47 |
|
47 | |||
48 | public: // From QBarSet |
|
48 | public: // From QBarSet | |
49 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } |
|
49 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } | |
50 | Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); } |
|
|||
51 | Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); } |
|
50 | Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); } | |
52 | Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); } |
|
51 | Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); } | |
53 |
Q_INVOKABLE |
|
52 | Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); } | |
54 | Q_INVOKABLE QPointF at(int index) { return QBarSet::at(index); } |
|
|||
55 |
|
53 | |||
56 | Q_SIGNALS: |
|
54 | Q_SIGNALS: | |
57 | void countChanged(int count); |
|
55 | void countChanged(int count); |
@@ -83,30 +83,30 QVector<QRectF> BarChartItem::calculateLayout() | |||||
83 | for (int category = 0; category < categoryCount; category++) { |
|
83 | for (int category = 0; category < categoryCount; category++) { | |
84 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); |
|
84 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); | |
85 | for (int set = 0; set < setCount; set++) { |
|
85 | for (int set = 0; set < setCount; set++) { | |
86 | QBarSet* barSet = m_series->d_func()->barsetAt(set); |
|
86 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); | |
87 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; |
|
87 | qreal xPos = (barSet->m_values.at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; | |
88 | qreal barHeight = barSet->at(category).y() * scaleY; |
|
88 | qreal barHeight = barSet->m_values.at(category).y() * scaleY; | |
89 |
|
89 | |||
90 | Bar* bar = m_bars.at(itemIndex); |
|
90 | Bar* bar = m_bars.at(itemIndex); | |
91 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); |
|
91 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); | |
92 |
|
92 | |||
93 | layout.append(rect); |
|
93 | layout.append(rect); | |
94 |
bar->setPen(barSet->pen |
|
94 | bar->setPen(barSet->m_pen); | |
95 |
bar->setBrush(barSet->brush |
|
95 | bar->setBrush(barSet->m_brush); | |
96 | bar->setVisible(barsVisible); |
|
96 | bar->setVisible(barsVisible); | |
97 |
|
97 | |||
98 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
98 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
99 |
|
99 | |||
100 | if (!qFuzzyIsNull(barSet->at(category).y())) { |
|
100 | if (!qFuzzyIsNull(barSet->m_values.at(category).y())) { | |
101 | label->setText(QString::number(barSet->at(category).y())); |
|
101 | label->setText(QString::number(barSet->m_values.at(category).y())); | |
102 | } else { |
|
102 | } else { | |
103 | label->setText(QString("")); |
|
103 | label->setText(QString("")); | |
104 | } |
|
104 | } | |
105 |
|
105 | |||
106 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
106 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) | |
107 | ,yPos - barHeight/2 - label->boundingRect().height()/2); |
|
107 | ,yPos - barHeight/2 - label->boundingRect().height()/2); | |
108 |
label->setFont(barSet->labelFont |
|
108 | label->setFont(barSet->m_labelFont); | |
109 |
label->setBrush(barSet->labelBrush |
|
109 | label->setBrush(barSet->m_labelBrush); | |
110 |
|
110 | |||
111 | itemIndex++; |
|
111 | itemIndex++; | |
112 | } |
|
112 | } |
@@ -23,6 +23,7 | |||||
23 | #include "qbarset_p.h" |
|
23 | #include "qbarset_p.h" | |
24 | #include "qbarseries_p.h" |
|
24 | #include "qbarseries_p.h" | |
25 | #include "qbarset.h" |
|
25 | #include "qbarset.h" | |
|
26 | #include "qbarset_p.h" | |||
26 |
|
27 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
29 | |||
@@ -53,32 +54,32 QVector<QRectF> GroupedBarChartItem::calculateLayout() | |||||
53 | for (int category = 0; category < categoryCount; category++) { |
|
54 | for (int category = 0; category < categoryCount; category++) { | |
54 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); |
|
55 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); | |
55 | for (int set = 0; set < setCount; set++) { |
|
56 | for (int set = 0; set < setCount; set++) { | |
56 | QBarSet* barSet = m_series->d_func()->barsetAt(set); |
|
57 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); | |
57 |
|
58 | |||
58 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left(); |
|
59 | qreal xPos = (barSet->m_values.at(category).x() - m_domainMinX) * scaleX + m_rect.left(); | |
59 | xPos -= setCount*barWidth/2; |
|
60 | xPos -= setCount*barWidth/2; | |
60 | xPos += set*barWidth; |
|
61 | xPos += set*barWidth; | |
61 | qreal barHeight = barSet->at(category).y() * scaleY; |
|
62 | qreal barHeight = barSet->m_values.at(category).y() * scaleY; | |
62 | Bar* bar = m_bars.at(itemIndex); |
|
63 | Bar* bar = m_bars.at(itemIndex); | |
63 |
|
64 | |||
64 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); |
|
65 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); | |
65 | layout.append(rect); |
|
66 | layout.append(rect); | |
66 |
bar->setPen(barSet->pen |
|
67 | bar->setPen(barSet->m_pen); | |
67 |
bar->setBrush(barSet->brush |
|
68 | bar->setBrush(barSet->m_brush); | |
68 | bar->setVisible(barsVisible); |
|
69 | bar->setVisible(barsVisible); | |
69 |
|
70 | |||
70 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
71 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
71 |
|
72 | |||
72 | if (!qFuzzyIsNull(barSet->at(category).y())) { |
|
73 | if (!qFuzzyIsNull(barSet->m_values.at(category).y())) { | |
73 | label->setText(QString::number(barSet->at(category).y())); |
|
74 | label->setText(QString::number(barSet->m_values.at(category).y())); | |
74 | } else { |
|
75 | } else { | |
75 | label->setText(QString("")); |
|
76 | label->setText(QString("")); | |
76 | } |
|
77 | } | |
77 |
|
78 | |||
78 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
79 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) | |
79 | ,yPos - barHeight/2 - label->boundingRect().height()/2); |
|
80 | ,yPos - barHeight/2 - label->boundingRect().height()/2); | |
80 |
label->setFont(barSet->labelFont |
|
81 | label->setFont(barSet->m_labelFont); | |
81 |
label->setBrush(barSet->labelBrush |
|
82 | label->setBrush(barSet->m_labelBrush); | |
82 |
|
83 | |||
83 | itemIndex++; |
|
84 | itemIndex++; | |
84 | } |
|
85 | } |
@@ -23,6 +23,7 | |||||
23 | #include "qbarseries_p.h" |
|
23 | #include "qbarseries_p.h" | |
24 | #include "qbarset.h" |
|
24 | #include "qbarset.h" | |
25 | #include "chartanimator_p.h" |
|
25 | #include "chartanimator_p.h" | |
|
26 | #include "qbarset_p.h" | |||
26 |
|
27 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
29 | |||
@@ -55,14 +56,14 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||||
55 | qreal percentage = (100 / colSum); |
|
56 | qreal percentage = (100 / colSum); | |
56 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); |
|
57 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); | |
57 | for (int set=0; set < setCount; set++) { |
|
58 | for (int set=0; set < setCount; set++) { | |
58 | QBarSet* barSet = m_series->d_func()->barsetAt(set); |
|
59 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); | |
59 |
|
60 | |||
60 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; |
|
61 | qreal xPos = (barSet->m_values.at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; | |
61 |
|
62 | |||
62 | qreal barHeight = barSet->at(category).y() * percentage * scaleY; |
|
63 | qreal barHeight = barSet->m_values.at(category).y() * percentage * scaleY; | |
63 | Bar* bar = m_bars.at(itemIndex); |
|
64 | Bar* bar = m_bars.at(itemIndex); | |
64 |
bar->setPen(barSet->pen |
|
65 | bar->setPen(barSet->m_pen); | |
65 |
bar->setBrush(barSet->brush |
|
66 | bar->setBrush(barSet->m_brush); | |
66 | bar->setVisible(barsVisible); |
|
67 | bar->setVisible(barsVisible); | |
67 |
|
68 | |||
68 | QRectF rect(xPos, yPos-barHeight, barWidth, barHeight); |
|
69 | QRectF rect(xPos, yPos-barHeight, barWidth, barHeight); | |
@@ -82,8 +83,8 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||||
82 |
|
83 | |||
83 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
84 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) | |
84 | ,yPos - barHeight/2 - label->boundingRect().height()/2); |
|
85 | ,yPos - barHeight/2 - label->boundingRect().height()/2); | |
85 |
label->setFont(barSet->labelFont |
|
86 | label->setFont(barSet->m_labelFont); | |
86 |
label->setBrush(barSet->labelBrush |
|
87 | label->setBrush(barSet->m_labelBrush); | |
87 |
|
88 | |||
88 | itemIndex++; |
|
89 | itemIndex++; | |
89 | yPos -= barHeight; |
|
90 | yPos -= barHeight; |
@@ -416,7 +416,7 void QBarModelMapperPrivate::barSetsAdded(QList<QBarSet*> sets) | |||||
416 | for(int i = firstIndex + m_firstBarSetSection; i < firstIndex + m_firstBarSetSection + sets.count(); i++) { |
|
416 | for(int i = firstIndex + m_firstBarSetSection; i < firstIndex + m_firstBarSetSection + sets.count(); i++) { | |
417 | m_model->setHeaderData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, sets.at(i - firstIndex - m_firstBarSetSection)->label()); |
|
417 | m_model->setHeaderData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, sets.at(i - firstIndex - m_firstBarSetSection)->label()); | |
418 | for (int j = 0; j < sets.at(i - firstIndex - m_firstBarSetSection)->count(); j++) |
|
418 | for (int j = 0; j < sets.at(i - firstIndex - m_firstBarSetSection)->count(); j++) | |
419 |
m_model->setData(barModelIndex(i, j), sets.at(i - firstIndex - m_firstBarSetSection)->at(j) |
|
419 | m_model->setData(barModelIndex(i, j), sets.at(i - firstIndex - m_firstBarSetSection)->at(j)); | |
420 | } |
|
420 | } | |
421 | blockModelSignals(false); |
|
421 | blockModelSignals(false); | |
422 | initializeBarFromModel(); |
|
422 | initializeBarFromModel(); | |
@@ -465,7 +465,7 void QBarModelMapperPrivate::valuesAdded(int index, int count) | |||||
465 | m_model->insertColumns(index + m_first, count); |
|
465 | m_model->insertColumns(index + m_first, count); | |
466 |
|
466 | |||
467 | for (int j = index; j < index + count; j++) |
|
467 | for (int j = index; j < index + count; j++) | |
468 |
m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, j), m_barSets.at(barSetIndex)->at(j) |
|
468 | m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, j), m_barSets.at(barSetIndex)->at(j)); | |
469 |
|
469 | |||
470 | blockModelSignals(false); |
|
470 | blockModelSignals(false); | |
471 | initializeBarFromModel(); |
|
471 | initializeBarFromModel(); | |
@@ -510,7 +510,7 void QBarModelMapperPrivate::barValueChanged(int index) | |||||
510 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); |
|
510 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); | |
511 |
|
511 | |||
512 | blockModelSignals(); |
|
512 | blockModelSignals(); | |
513 |
m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, index), m_barSets.at(barSetIndex)->at(index) |
|
513 | m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, index), m_barSets.at(barSetIndex)->at(index)); | |
514 | blockModelSignals(false); |
|
514 | blockModelSignals(false); | |
515 | initializeBarFromModel(); |
|
515 | initializeBarFromModel(); | |
516 | } |
|
516 | } |
@@ -432,7 +432,7 qreal QBarSeriesPrivate::min() | |||||
432 | for (int i = 0; i < m_barSets.count(); i++) { |
|
432 | for (int i = 0; i < m_barSets.count(); i++) { | |
433 | int categoryCount = m_barSets.at(i)->count(); |
|
433 | int categoryCount = m_barSets.at(i)->count(); | |
434 | for (int j = 0; j < categoryCount; j++) { |
|
434 | for (int j = 0; j < categoryCount; j++) { | |
435 |
qreal temp = m_barSets.at(i)->at(j) |
|
435 | qreal temp = m_barSets.at(i)->at(j); | |
436 | if (temp < min) |
|
436 | if (temp < min) | |
437 | min = temp; |
|
437 | min = temp; | |
438 | } |
|
438 | } | |
@@ -450,7 +450,7 qreal QBarSeriesPrivate::max() | |||||
450 | for (int i = 0; i < m_barSets.count(); i++) { |
|
450 | for (int i = 0; i < m_barSets.count(); i++) { | |
451 | int categoryCount = m_barSets.at(i)->count(); |
|
451 | int categoryCount = m_barSets.at(i)->count(); | |
452 | for (int j = 0; j < categoryCount; j++) { |
|
452 | for (int j = 0; j < categoryCount; j++) { | |
453 |
qreal temp = m_barSets.at(i)->at(j) |
|
453 | qreal temp = m_barSets.at(i)->at(j); | |
454 | if (temp > max) |
|
454 | if (temp > max) | |
455 | max = temp; |
|
455 | max = temp; | |
456 | } |
|
456 | } | |
@@ -469,7 +469,7 qreal QBarSeriesPrivate::valueAt(int set, int category) | |||||
469 | return 0; |
|
469 | return 0; | |
470 | } |
|
470 | } | |
471 |
|
471 | |||
472 |
return m_barSets.at(set)->at(category) |
|
472 | return m_barSets.at(set)->at(category); | |
473 | } |
|
473 | } | |
474 |
|
474 | |||
475 | qreal QBarSeriesPrivate::percentageAt(int set, int category) |
|
475 | qreal QBarSeriesPrivate::percentageAt(int set, int category) | |
@@ -482,7 +482,7 qreal QBarSeriesPrivate::percentageAt(int set, int category) | |||||
482 | return 0; |
|
482 | return 0; | |
483 | } |
|
483 | } | |
484 |
|
484 | |||
485 |
qreal value = m_barSets.at(set)->at(category) |
|
485 | qreal value = m_barSets.at(set)->at(category); | |
486 | qreal sum = categorySum(category); |
|
486 | qreal sum = categorySum(category); | |
487 | if ( qFuzzyIsNull(sum) ) { |
|
487 | if ( qFuzzyIsNull(sum) ) { | |
488 | return 0; |
|
488 | return 0; | |
@@ -497,7 +497,7 qreal QBarSeriesPrivate::categorySum(int category) | |||||
497 | int count = m_barSets.count(); // Count sets |
|
497 | int count = m_barSets.count(); // Count sets | |
498 | for (int set = 0; set < count; set++) { |
|
498 | for (int set = 0; set < count; set++) { | |
499 | if (category < m_barSets.at(set)->count()) |
|
499 | if (category < m_barSets.at(set)->count()) | |
500 |
sum += m_barSets.at(set)->at(category) |
|
500 | sum += m_barSets.at(set)->at(category); | |
501 | } |
|
501 | } | |
502 | return sum; |
|
502 | return sum; | |
503 | } |
|
503 | } | |
@@ -508,7 +508,7 qreal QBarSeriesPrivate::absoluteCategorySum(int category) | |||||
508 | int count = m_barSets.count(); // Count sets |
|
508 | int count = m_barSets.count(); // Count sets | |
509 | for (int set = 0; set < count; set++) { |
|
509 | for (int set = 0; set < count; set++) { | |
510 | if (category < m_barSets.at(set)->count()) |
|
510 | if (category < m_barSets.at(set)->count()) | |
511 |
sum += qAbs(m_barSets.at(set)->at(category) |
|
511 | sum += qAbs(m_barSets.at(set)->at(category)); | |
512 | } |
|
512 | } | |
513 | return sum; |
|
513 | return sum; | |
514 | } |
|
514 | } | |
@@ -535,7 +535,7 qreal QBarSeriesPrivate::minX() | |||||
535 | for (int i = 0; i < m_barSets.count(); i++) { |
|
535 | for (int i = 0; i < m_barSets.count(); i++) { | |
536 | int categoryCount = m_barSets.at(i)->count(); |
|
536 | int categoryCount = m_barSets.at(i)->count(); | |
537 | for (int j = 0; j < categoryCount; j++) { |
|
537 | for (int j = 0; j < categoryCount; j++) { | |
538 | qreal temp = m_barSets.at(i)->at(j).x(); |
|
538 | qreal temp = m_barSets.at(i)->d_ptr.data()->m_values.at(j).x(); | |
539 | if (temp < min) |
|
539 | if (temp < min) | |
540 | min = temp; |
|
540 | min = temp; | |
541 | } |
|
541 | } | |
@@ -553,7 +553,7 qreal QBarSeriesPrivate::maxX() | |||||
553 | for (int i = 0; i < m_barSets.count(); i++) { |
|
553 | for (int i = 0; i < m_barSets.count(); i++) { | |
554 | int categoryCount = m_barSets.at(i)->count(); |
|
554 | int categoryCount = m_barSets.at(i)->count(); | |
555 | for (int j = 0; j < categoryCount; j++) { |
|
555 | for (int j = 0; j < categoryCount; j++) { | |
556 | qreal temp = m_barSets.at(i)->at(j).x(); |
|
556 | qreal temp = m_barSets.at(i)->d_ptr.data()->m_values.at(j).x(); | |
557 | if (temp > max) |
|
557 | if (temp > max) | |
558 | max = temp; |
|
558 | max = temp; | |
559 | } |
|
559 | } |
@@ -276,42 +276,17 QString QBarSet::label() const | |||||
276 | } |
|
276 | } | |
277 |
|
277 | |||
278 | /*! |
|
278 | /*! | |
279 | Appends a point to set. Parameter \a value x coordinate defines the |
|
279 | Appends new value \a value to the end of set. | |
280 | position in x-axis and y coordinate defines the height of bar. |
|
|||
281 | Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries) |
|
|||
282 | the x values are used or ignored. |
|
|||
283 | */ |
|
|||
284 | void QBarSet::append(const QPointF value) |
|
|||
285 | { |
|
|||
286 | int index = d_ptr->m_values.count(); |
|
|||
287 | d_ptr->append(value); |
|
|||
288 | emit valuesAdded(index, 1); |
|
|||
289 | } |
|
|||
290 |
|
||||
291 | /*! |
|
|||
292 | Appends a list of \a values to set. Works like append with single point. |
|
|||
293 | \sa append() |
|
|||
294 | */ |
|
|||
295 | void QBarSet::append(const QList<QPointF> &values) |
|
|||
296 | { |
|
|||
297 | int index = d_ptr->m_values.count(); |
|
|||
298 | d_ptr->append(values); |
|
|||
299 | emit valuesAdded(index, values.count()); |
|
|||
300 | } |
|
|||
301 |
|
||||
302 | /*! |
|
|||
303 | Appends new value \a value to the end of set. Internally the value is converted to QPointF, |
|
|||
304 | with x coordinate being the index of appended value and y coordinate is the value. |
|
|||
305 | */ |
|
280 | */ | |
306 | void QBarSet::append(const qreal value) |
|
281 | void QBarSet::append(const qreal value) | |
307 | { |
|
282 | { | |
308 | // Convert to QPointF and use other append(QPointF) method. |
|
283 | // Convert to QPointF | |
309 | append(QPointF(d_ptr->m_values.count(), value)); |
|
284 | d_ptr->append(QPointF(d_ptr->m_values.count(), value)); | |
310 | } |
|
285 | } | |
311 |
|
286 | |||
312 | /*! |
|
287 | /*! | |
313 | Appends a list of reals to set. Works like append with single real value. The \a values in list |
|
288 | Appends a list of reals to set. Works like append with single real value. The \a values in list | |
314 | are converted to QPointF, where x coordinate is the index of point and y coordinate is the value. |
|
289 | are appended to end of barset | |
315 | \sa append() |
|
290 | \sa append() | |
316 | */ |
|
291 | */ | |
317 | void QBarSet::append(const QList<qreal> &values) |
|
292 | void QBarSet::append(const QList<qreal> &values) | |
@@ -327,17 +302,8 void QBarSet::append(const QList<qreal> &values) | |||||
327 | */ |
|
302 | */ | |
328 | QBarSet& QBarSet::operator << (const qreal &value) |
|
303 | QBarSet& QBarSet::operator << (const qreal &value) | |
329 | { |
|
304 | { | |
330 | append(value); |
|
305 | // append(value); | |
331 | return *this; |
|
306 | d_ptr->append(QPointF(d_ptr->m_values.count(), value)); | |
332 | } |
|
|||
333 |
|
||||
334 | /*! |
|
|||
335 | Convinience operator. Same as append, with QPointF \a value. |
|
|||
336 | \sa append() |
|
|||
337 | */ |
|
|||
338 | QBarSet& QBarSet::operator << (const QPointF &value) |
|
|||
339 | { |
|
|||
340 | append(value); |
|
|||
341 | return *this; |
|
307 | return *this; | |
342 | } |
|
308 | } | |
343 |
|
309 | |||
@@ -353,17 +319,6 void QBarSet::insert(const int index, const qreal value) | |||||
353 | } |
|
319 | } | |
354 |
|
320 | |||
355 | /*! |
|
321 | /*! | |
356 | Inserts new \a value on the \a index position. |
|
|||
357 | The value that is currently at this postion is moved to postion index + 1 |
|
|||
358 | \sa remove() |
|
|||
359 | */ |
|
|||
360 | void QBarSet::insert(const int index, const QPointF value) |
|
|||
361 | { |
|
|||
362 | d_ptr->insert(index,value); |
|
|||
363 | emit valuesAdded(index,1); |
|
|||
364 | } |
|
|||
365 |
|
||||
366 | /*! |
|
|||
367 | Removes \a count number of values from the set starting at \a index. |
|
322 | Removes \a count number of values from the set starting at \a index. | |
368 | \sa insert() |
|
323 | \sa insert() | |
369 | */ |
|
324 | */ | |
@@ -387,40 +342,27 void QBarSet::replace(const int index, const qreal value) | |||||
387 | } |
|
342 | } | |
388 | } |
|
343 | } | |
389 |
|
344 | |||
390 | /*! |
|
|||
391 | Sets a new value \a value to set, indexed by \a index |
|
|||
392 | */ |
|
|||
393 | void QBarSet::replace(const int index, const QPointF value) |
|
|||
394 | { |
|
|||
395 | if (index >= 0 && index < d_ptr->m_values.count()) { |
|
|||
396 | d_ptr->replace(index,value); |
|
|||
397 | emit valueChanged(index); |
|
|||
398 | } |
|
|||
399 | } |
|
|||
400 |
|
345 | |||
401 | /*! |
|
346 | /*! | |
402 | Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF. |
|
347 | Returns value of set indexed by \a index. | |
403 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value |
|
348 | If the index is out of bounds 0.0 is returned. | |
404 | of the QPointF (if appended with QPointF append). |
|
|||
405 | If the index is out of bounds QPointF(0, 0.0) is returned. |
|
|||
406 | */ |
|
349 | */ | |
407 |
|
|
350 | qreal QBarSet::at(const int index) const | |
408 | { |
|
351 | { | |
409 | if (index < 0 || index >= d_ptr->m_values.count()) { |
|
352 | if (index < 0 || index >= d_ptr->m_values.count()) { | |
410 |
return |
|
353 | return 0; | |
411 | } |
|
354 | } | |
412 |
|
355 | |||
413 | return d_ptr->m_values.at(index); |
|
356 | return d_ptr->m_values.at(index).y(); | |
414 | } |
|
357 | } | |
415 |
|
358 | |||
416 | /*! |
|
359 | /*! | |
417 | Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF. |
|
360 | Returns value of set indexed by \a index. | |
418 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value |
|
361 | If the index is out of bounds 0.0 is returned. | |
419 | of the QPointF (if appended with QPointF append). |
|
|||
420 | */ |
|
362 | */ | |
421 |
|
|
363 | qreal QBarSet::operator [](const int index) const | |
422 | { |
|
364 | { | |
423 |
return |
|
365 | return at(index); | |
424 | } |
|
366 | } | |
425 |
|
367 | |||
426 | /*! |
|
368 | /*! | |
@@ -432,13 +374,12 int QBarSet::count() const | |||||
432 | } |
|
374 | } | |
433 |
|
375 | |||
434 | /*! |
|
376 | /*! | |
435 | Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation. |
|
377 | Returns sum of all values in barset. | |
436 | */ |
|
378 | */ | |
437 | qreal QBarSet::sum() const |
|
379 | qreal QBarSet::sum() const | |
438 | { |
|
380 | { | |
439 | qreal total(0); |
|
381 | qreal total(0); | |
440 | for (int i=0; i < d_ptr->m_values.count(); i++) { |
|
382 | for (int i=0; i < d_ptr->m_values.count(); i++) { | |
441 | //total += d_ptr->m_values.at(i); |
|
|||
442 | total += d_ptr->m_values.at(i).y(); |
|
383 | total += d_ptr->m_values.at(i).y(); | |
443 | } |
|
384 | } | |
444 | return total; |
|
385 | return total; |
@@ -48,21 +48,16 public: | |||||
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 QPointF value); |
|
|||
52 | void append(const QList<QPointF> &values); |
|
|||
53 | void append(const qreal value); |
|
51 | void append(const qreal value); | |
54 | void append(const QList<qreal> &values); |
|
52 | void append(const QList<qreal> &values); | |
55 |
|
53 | |||
56 | QBarSet& operator << (const qreal &value); |
|
54 | QBarSet& operator << (const qreal &value); | |
57 | QBarSet& operator << (const QPointF &value); |
|
|||
58 |
|
55 | |||
59 | void insert(const int index, const qreal value); |
|
56 | void insert(const int index, const qreal value); | |
60 | void insert(const int index, const QPointF value); |
|
|||
61 | void remove(const int index, const int count = 1); |
|
57 | void remove(const int index, const int count = 1); | |
62 | void replace(const int index, const qreal value); |
|
58 | void replace(const int index, const qreal value); | |
63 |
|
|
59 | qreal at(const int index) const; | |
64 |
|
|
60 | qreal operator [] (const int index) const; | |
65 | QPointF operator [] (const int index) const; |
|
|||
66 | int count() const; |
|
61 | int count() const; | |
67 | qreal sum() const; |
|
62 | qreal sum() const; | |
68 |
|
63 | |||
@@ -110,6 +105,9 private: | |||||
110 | friend class BarLegendMarker; |
|
105 | friend class BarLegendMarker; | |
111 | friend class BarChartItem; |
|
106 | friend class BarChartItem; | |
112 | friend class QBarSeriesPrivate; |
|
107 | friend class QBarSeriesPrivate; | |
|
108 | friend class StackedBarChartItem; | |||
|
109 | friend class PercentBarChartItem; | |||
|
110 | friend class GroupedBarChartItem; | |||
113 | }; |
|
111 | }; | |
114 |
|
112 | |||
115 | QTCOMMERCIALCHART_END_NAMESPACE |
|
113 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -53,14 +53,14 QVector<QRectF> StackedBarChartItem::calculateLayout() | |||||
53 | for (int category = 0; category < categoryCount; category++) { |
|
53 | for (int category = 0; category < categoryCount; category++) { | |
54 | qreal yPos = height + rangeY * m_domainMinY + geometry().topLeft().y(); |
|
54 | qreal yPos = height + rangeY * m_domainMinY + geometry().topLeft().y(); | |
55 | for (int set=0; set < setCount; set++) { |
|
55 | for (int set=0; set < setCount; set++) { | |
56 | QBarSet* barSet = m_series->d_func()->barsetAt(set); |
|
56 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); | |
57 |
|
57 | |||
58 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; |
|
58 | qreal xPos = (barSet->m_values.at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; | |
59 |
|
59 | |||
60 | qreal barHeight = barSet->at(category).y() * scaleY; |
|
60 | qreal barHeight = barSet->m_values.at(category).y() * scaleY; | |
61 | Bar* bar = m_bars.at(itemIndex); |
|
61 | Bar* bar = m_bars.at(itemIndex); | |
62 |
bar->setPen(barSet->pen |
|
62 | bar->setPen(barSet->m_pen); | |
63 |
bar->setBrush(barSet->brush |
|
63 | bar->setBrush(barSet->m_brush); | |
64 | bar->setVisible(barsVisible); |
|
64 | bar->setVisible(barsVisible); | |
65 |
|
65 | |||
66 | QRectF rect(xPos, yPos-barHeight, barWidth, barHeight); |
|
66 | QRectF rect(xPos, yPos-barHeight, barWidth, barHeight); | |
@@ -68,16 +68,16 QVector<QRectF> StackedBarChartItem::calculateLayout() | |||||
68 |
|
68 | |||
69 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
69 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
70 |
|
70 | |||
71 | if (!qFuzzyIsNull(barSet->at(category).y())) { |
|
71 | if (!qFuzzyIsNull(barSet->m_values.at(category).y())) { | |
72 | label->setText(QString::number(barSet->at(category).y())); |
|
72 | label->setText(QString::number(barSet->m_values.at(category).y())); | |
73 | } else { |
|
73 | } else { | |
74 | label->setText(QString("")); |
|
74 | label->setText(QString("")); | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
77 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) | |
78 | ,yPos - barHeight/2 - label->boundingRect().height()/2); |
|
78 | ,yPos - barHeight/2 - label->boundingRect().height()/2); | |
79 |
label->setFont(barSet->labelFont |
|
79 | label->setFont(barSet->m_labelFont); | |
80 |
label->setBrush(barSet->labelBrush |
|
80 | label->setBrush(barSet->m_labelBrush); | |
81 | itemIndex++; |
|
81 | itemIndex++; | |
82 | yPos -= barHeight; |
|
82 | yPos -= barHeight; | |
83 | } |
|
83 | } |
@@ -605,7 +605,7 void tst_qbarmodelmapper::modelUpdateCell() | |||||
605 | createVerticalMapper(); |
|
605 | createVerticalMapper(); | |
606 |
|
606 | |||
607 | QVERIFY(m_model->setData(m_model->index(1, 0), 44)); |
|
607 | QVERIFY(m_model->setData(m_model->index(1, 0), 44)); | |
608 |
QCOMPARE(m_series->barSets().at(0)->at(1) |
|
608 | QCOMPARE(m_series->barSets().at(0)->at(1), 44.0); | |
609 | QCOMPARE(m_model->data(m_model->index(1, 0)).toReal(), 44.0); |
|
609 | QCOMPARE(m_model->data(m_model->index(1, 0)).toReal(), 44.0); | |
610 | } |
|
610 | } | |
611 |
|
611 |
@@ -319,11 +319,13 void tst_QBarSeries::mouseclicked() | |||||
319 | QBarSeries* series = new QBarSeries(); |
|
319 | QBarSeries* series = new QBarSeries(); | |
320 |
|
320 | |||
321 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
321 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
322 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); |
|
322 | // *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); | |
|
323 | *set1 << 10 << 10 << 10; | |||
323 | series->append(set1); |
|
324 | series->append(set1); | |
324 |
|
325 | |||
325 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
326 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
326 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); |
|
327 | // *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); | |
|
328 | *set2 << 10 << 10 << 10; | |||
327 | series->append(set2); |
|
329 | series->append(set2); | |
328 |
|
330 | |||
329 | QSignalSpy seriesSpy(series,SIGNAL(clicked(int,QBarSet*))); |
|
331 | QSignalSpy seriesSpy(series,SIGNAL(clicked(int,QBarSet*))); | |
@@ -455,11 +457,13 void tst_QBarSeries::mousehovered() | |||||
455 | QBarSeries* series = new QBarSeries(); |
|
457 | QBarSeries* series = new QBarSeries(); | |
456 |
|
458 | |||
457 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
459 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
458 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); |
|
460 | // *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); | |
|
461 | *set1 << 10 << 10 << 10; | |||
459 | series->append(set1); |
|
462 | series->append(set1); | |
460 |
|
463 | |||
461 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
464 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
462 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); |
|
465 | // *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); | |
|
466 | *set2 << 10 << 10 << 10; | |||
463 | series->append(set2); |
|
467 | series->append(set2); | |
464 |
|
468 | |||
465 | QSignalSpy seriesSpy(series,SIGNAL(hovered(bool,QBarSet*))); |
|
469 | QSignalSpy seriesSpy(series,SIGNAL(hovered(bool,QBarSet*))); | |
@@ -549,11 +553,13 void tst_QBarSeries::clearWithAnimations() | |||||
549 | QBarSeries* series = new QBarSeries(); |
|
553 | QBarSeries* series = new QBarSeries(); | |
550 |
|
554 | |||
551 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
555 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
552 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); |
|
556 | // *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); | |
|
557 | *set1 << 10 << 10 << 10; | |||
553 | series->append(set1); |
|
558 | series->append(set1); | |
554 |
|
559 | |||
555 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
560 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
556 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); |
|
561 | // *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); | |
|
562 | *set2 << 10 << 10 << 10; | |||
557 | series->append(set2); |
|
563 | series->append(set2); | |
558 |
|
564 | |||
559 | QChartView view(new QChart()); |
|
565 | QChartView view(new QChart()); |
@@ -137,7 +137,7 void tst_QBarSet::append() | |||||
137 |
|
137 | |||
138 | for (int i=0; i<count; i++) { |
|
138 | for (int i=0; i<count; i++) { | |
139 | m_barset->append(value); |
|
139 | m_barset->append(value); | |
140 |
QCOMPARE(m_barset->at(i) |
|
140 | QCOMPARE(m_barset->at(i), value); | |
141 | sum += value; |
|
141 | sum += value; | |
142 | value += 1.0; |
|
142 | value += 1.0; | |
143 | } |
|
143 | } | |
@@ -167,7 +167,7 void tst_QBarSet::appendOperator() | |||||
167 |
|
167 | |||
168 | for (int i=0; i<count; i++) { |
|
168 | for (int i=0; i<count; i++) { | |
169 | *m_barset << value; |
|
169 | *m_barset << value; | |
170 |
QCOMPARE(m_barset->at(i) |
|
170 | QCOMPARE(m_barset->at(i), value); | |
171 | sum += value; |
|
171 | sum += value; | |
172 | value += 1.0; |
|
172 | value += 1.0; | |
173 | } |
|
173 | } | |
@@ -188,20 +188,20 void tst_QBarSet::insert() | |||||
188 | QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int))); |
|
188 | QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int))); | |
189 |
|
189 | |||
190 | m_barset->insert(0, 1.0); // 1.0 |
|
190 | m_barset->insert(0, 1.0); // 1.0 | |
191 |
QCOMPARE(m_barset->at(0) |
|
191 | QCOMPARE(m_barset->at(0), 1.0); | |
192 | QCOMPARE(m_barset->count(), 1); |
|
192 | QCOMPARE(m_barset->count(), 1); | |
193 | QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0)); |
|
193 | QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0)); | |
194 |
|
194 | |||
195 | m_barset->insert(0, 2.0); // 2.0 1.0 |
|
195 | m_barset->insert(0, 2.0); // 2.0 1.0 | |
196 |
QCOMPARE(m_barset->at(0) |
|
196 | QCOMPARE(m_barset->at(0), 2.0); | |
197 |
QCOMPARE(m_barset->at(1) |
|
197 | QCOMPARE(m_barset->at(1), 1.0); | |
198 | QCOMPARE(m_barset->count(), 2); |
|
198 | QCOMPARE(m_barset->count(), 2); | |
199 | QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0)); |
|
199 | QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0)); | |
200 |
|
200 | |||
201 | m_barset->insert(1, 3.0); // 2.0 3.0 1.0 |
|
201 | m_barset->insert(1, 3.0); // 2.0 3.0 1.0 | |
202 |
QCOMPARE(m_barset->at(1) |
|
202 | QCOMPARE(m_barset->at(1), 3.0); | |
203 |
QCOMPARE(m_barset->at(0) |
|
203 | QCOMPARE(m_barset->at(0), 2.0); | |
204 |
QCOMPARE(m_barset->at(2) |
|
204 | QCOMPARE(m_barset->at(2), 1.0); | |
205 | QCOMPARE(m_barset->count(), 3); |
|
205 | QCOMPARE(m_barset->count(), 3); | |
206 | QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0)); |
|
206 | QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0)); | |
207 | QCOMPARE(valueSpy.count(), 3); |
|
207 | QCOMPARE(valueSpy.count(), 3); | |
@@ -228,9 +228,9 void tst_QBarSet::remove() | |||||
228 |
|
228 | |||
229 | // Remove middle |
|
229 | // Remove middle | |
230 | m_barset->remove(2); // 1.0 2.0 4.0 |
|
230 | m_barset->remove(2); // 1.0 2.0 4.0 | |
231 |
QCOMPARE(m_barset->at(0) |
|
231 | QCOMPARE(m_barset->at(0), 1.0); | |
232 |
QCOMPARE(m_barset->at(1) |
|
232 | QCOMPARE(m_barset->at(1), 2.0); | |
233 |
QCOMPARE(m_barset->at(2) |
|
233 | QCOMPARE(m_barset->at(2), 4.0); | |
234 | QCOMPARE(m_barset->count(), 3); |
|
234 | QCOMPARE(m_barset->count(), 3); | |
235 | QCOMPARE(m_barset->sum(), 7.0); |
|
235 | QCOMPARE(m_barset->sum(), 7.0); | |
236 | QCOMPARE(valueSpy.count(), 1); |
|
236 | QCOMPARE(valueSpy.count(), 1); | |
@@ -245,8 +245,8 void tst_QBarSet::remove() | |||||
245 |
|
245 | |||
246 | // Remove first |
|
246 | // Remove first | |
247 | m_barset->remove(0); // 2.0 4.0 |
|
247 | m_barset->remove(0); // 2.0 4.0 | |
248 |
QCOMPARE(m_barset->at(0) |
|
248 | QCOMPARE(m_barset->at(0), 2.0); | |
249 |
QCOMPARE(m_barset->at(1) |
|
249 | QCOMPARE(m_barset->at(1), 4.0); | |
250 | QCOMPARE(m_barset->count(), 2); |
|
250 | QCOMPARE(m_barset->count(), 2); | |
251 | QCOMPARE(m_barset->sum(), 6.0); |
|
251 | QCOMPARE(m_barset->sum(), 6.0); | |
252 |
|
252 | |||
@@ -310,16 +310,16 void tst_QBarSet::replace() | |||||
310 | m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0 |
|
310 | m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0 | |
311 | QCOMPARE(m_barset->count(), 4); |
|
311 | QCOMPARE(m_barset->count(), 4); | |
312 | QCOMPARE(m_barset->sum(), 14.0); |
|
312 | QCOMPARE(m_barset->sum(), 14.0); | |
313 |
QCOMPARE(m_barset->at(0) |
|
313 | QCOMPARE(m_barset->at(0), 5.0); | |
314 |
|
314 | |||
315 | // Replace last |
|
315 | // Replace last | |
316 | m_barset->replace(3, 6.0); |
|
316 | m_barset->replace(3, 6.0); | |
317 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 |
|
317 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 | |
318 | QCOMPARE(m_barset->sum(), 16.0); |
|
318 | QCOMPARE(m_barset->sum(), 16.0); | |
319 |
QCOMPARE(m_barset->at(0) |
|
319 | QCOMPARE(m_barset->at(0), 5.0); | |
320 |
QCOMPARE(m_barset->at(1) |
|
320 | QCOMPARE(m_barset->at(1), 2.0); | |
321 |
QCOMPARE(m_barset->at(2) |
|
321 | QCOMPARE(m_barset->at(2), 3.0); | |
322 |
QCOMPARE(m_barset->at(3) |
|
322 | QCOMPARE(m_barset->at(3), 6.0); | |
323 |
|
323 | |||
324 | // Illegal indexes |
|
324 | // Illegal indexes | |
325 | m_barset->replace(4, 6.0); |
|
325 | m_barset->replace(4, 6.0); | |
@@ -328,10 +328,10 void tst_QBarSet::replace() | |||||
328 | m_barset->replace(-1, 6.0); |
|
328 | m_barset->replace(-1, 6.0); | |
329 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 |
|
329 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 | |
330 | QCOMPARE(m_barset->sum(), 16.0); |
|
330 | QCOMPARE(m_barset->sum(), 16.0); | |
331 |
m_barset->replace(4, |
|
331 | m_barset->replace(4, 1.0); | |
332 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 |
|
332 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 | |
333 | QCOMPARE(m_barset->sum(), 16.0); |
|
333 | QCOMPARE(m_barset->sum(), 16.0); | |
334 |
m_barset->replace(-1, |
|
334 | m_barset->replace(-1, 1.0); | |
335 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 |
|
335 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 | |
336 | QCOMPARE(m_barset->sum(), 16.0); |
|
336 | QCOMPARE(m_barset->sum(), 16.0); | |
337 |
|
337 | |||
@@ -353,10 +353,10 void tst_QBarSet::at() | |||||
353 | m_barset->append(3.0); |
|
353 | m_barset->append(3.0); | |
354 | m_barset->append(4.0); |
|
354 | m_barset->append(4.0); | |
355 |
|
355 | |||
356 |
QCOMPARE(m_barset->at(0) |
|
356 | QCOMPARE(m_barset->at(0), 1.0); | |
357 |
QCOMPARE(m_barset->at(1) |
|
357 | QCOMPARE(m_barset->at(1), 2.0); | |
358 |
QCOMPARE(m_barset->at(2) |
|
358 | QCOMPARE(m_barset->at(2), 3.0); | |
359 |
QCOMPARE(m_barset->at(3) |
|
359 | QCOMPARE(m_barset->at(3), 4.0); | |
360 | } |
|
360 | } | |
361 |
|
361 | |||
362 | void tst_QBarSet::atOperator_data() |
|
362 | void tst_QBarSet::atOperator_data() | |
@@ -374,10 +374,10 void tst_QBarSet::atOperator() | |||||
374 | m_barset->append(3.0); |
|
374 | m_barset->append(3.0); | |
375 | m_barset->append(4.0); |
|
375 | m_barset->append(4.0); | |
376 |
|
376 | |||
377 |
QCOMPARE(m_barset->operator [](0) |
|
377 | QCOMPARE(m_barset->operator [](0), 1.0); | |
378 |
QCOMPARE(m_barset->operator [](1) |
|
378 | QCOMPARE(m_barset->operator [](1), 2.0); | |
379 |
QCOMPARE(m_barset->operator [](2) |
|
379 | QCOMPARE(m_barset->operator [](2), 3.0); | |
380 |
QCOMPARE(m_barset->operator [](3) |
|
380 | QCOMPARE(m_barset->operator [](3), 4.0); | |
381 | } |
|
381 | } | |
382 |
|
382 | |||
383 | void tst_QBarSet::count_data() |
|
383 | void tst_QBarSet::count_data() |
General Comments 0
You need to be logged in to leave comments.
Login now