@@ -43,13 +43,16 void HorizontalBarChartItem::initializeLayout() | |||
|
43 | 43 | QPointF topLeft; |
|
44 | 44 | QPointF bottomRight; |
|
45 | 45 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { |
|
46 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2 + set/setCount * barWidth)); | |
|
47 | bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2 + (set + 1)/setCount * barWidth)); | |
|
46 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2 + set/setCount * barWidth), m_validData); | |
|
47 | bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2 + (set + 1)/setCount * barWidth), m_validData); | |
|
48 | 48 | } else { |
|
49 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + set/setCount * barWidth)); | |
|
50 | bottomRight = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + (set + 1)/setCount * barWidth)); | |
|
49 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + set/setCount * barWidth), m_validData); | |
|
50 | bottomRight = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + (set + 1)/setCount * barWidth), m_validData); | |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | if (!m_validData) | |
|
54 | return; | |
|
55 | ||
|
53 | 56 | rect.setTopLeft(topLeft); |
|
54 | 57 | rect.setBottomRight(bottomRight); |
|
55 | 58 | m_layout.append(rect.normalized()); |
@@ -72,11 +75,15 QVector<QRectF> HorizontalBarChartItem::calculateLayout() | |||
|
72 | 75 | QRectF rect; |
|
73 | 76 | QPointF topLeft; |
|
74 | 77 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
75 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2 + set/setCount * barWidth)); | |
|
78 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2 + set/setCount * barWidth), m_validData); | |
|
76 | 79 | else |
|
77 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + set/setCount * barWidth)); | |
|
80 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + set/setCount * barWidth), m_validData); | |
|
81 | ||
|
82 | QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(value, category - barWidth / 2 + (set + 1)/setCount * barWidth), m_validData); | |
|
83 | ||
|
84 | if (!m_validData) | |
|
85 | return QVector<QRectF>(); | |
|
78 | 86 | |
|
79 | QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(value, category - barWidth / 2 + (set + 1)/setCount * barWidth)); | |
|
80 | 87 | rect.setTopLeft(topLeft); |
|
81 | 88 | rect.setBottomRight(bottomRight); |
|
82 | 89 | layout.append(rect.normalized()); |
@@ -43,13 +43,16 void HorizontalPercentBarChartItem::initializeLayout() | |||
|
43 | 43 | QPointF topLeft; |
|
44 | 44 | QPointF bottomRight; |
|
45 | 45 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { |
|
46 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2)); | |
|
47 | bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2)); | |
|
46 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2), m_validData); | |
|
47 | bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2), m_validData); | |
|
48 | 48 | } else { |
|
49 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2)); | |
|
50 | bottomRight = domain()->calculateGeometryPoint(QPointF(0, category + barWidth / 2)); | |
|
49 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2), m_validData); | |
|
50 | bottomRight = domain()->calculateGeometryPoint(QPointF(0, category + barWidth / 2), m_validData); | |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | if (!m_validData) | |
|
54 | return; | |
|
55 | ||
|
53 | 56 | rect.setTopLeft(topLeft); |
|
54 | 57 | rect.setBottomRight(bottomRight); |
|
55 | 58 | m_layout.append(rect.normalized()); |
@@ -74,10 +77,13 QVector<QRectF> HorizontalPercentBarChartItem::calculateLayout() | |||
|
74 | 77 | QRectF rect; |
|
75 | 78 | QPointF topLeft; |
|
76 | 79 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
77 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : domain()->minX(), category - barWidth/2)); | |
|
80 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : domain()->minX(), category - barWidth/2), m_validData); | |
|
78 | 81 | else |
|
79 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : 0, category - barWidth/2)); | |
|
80 | QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(100 * (value + sum)/categorySum, category + barWidth/2)); | |
|
82 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : 0, category - barWidth/2), m_validData); | |
|
83 | QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(100 * (value + sum)/categorySum, category + barWidth/2), m_validData); | |
|
84 | ||
|
85 | if (!m_validData) | |
|
86 | return QVector<QRectF>(); | |
|
81 | 87 | rect.setTopLeft(topLeft); |
|
82 | 88 | rect.setBottomRight(bottomRight); |
|
83 | 89 | layout.append(rect.normalized()); |
@@ -43,13 +43,16 void HorizontalStackedBarChartItem::initializeLayout() | |||
|
43 | 43 | QPointF topLeft; |
|
44 | 44 | QPointF bottomRight; |
|
45 | 45 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { |
|
46 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2)); | |
|
47 | bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2)); | |
|
46 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2), m_validData); | |
|
47 | bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2), m_validData); | |
|
48 | 48 | } else { |
|
49 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2)); | |
|
50 | bottomRight = domain()->calculateGeometryPoint(QPointF(0, category + barWidth / 2)); | |
|
49 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2), m_validData); | |
|
50 | bottomRight = domain()->calculateGeometryPoint(QPointF(0, category + barWidth / 2), m_validData); | |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | if (!m_validData) | |
|
54 | return; | |
|
55 | ||
|
53 | 56 | rect.setTopLeft(topLeft); |
|
54 | 57 | rect.setBottomRight(bottomRight); |
|
55 | 58 | m_layout.append(rect.normalized()); |
@@ -75,20 +78,22 QVector<QRectF> HorizontalStackedBarChartItem::calculateLayout() | |||
|
75 | 78 | QPointF topLeft; |
|
76 | 79 | QPointF bottomRight; |
|
77 | 80 | if (value < 0) { |
|
78 | bottomRight = domain()->calculateGeometryPoint(QPointF(value + negativeSum, category - barWidth / 2)); | |
|
81 | bottomRight = domain()->calculateGeometryPoint(QPointF(value + negativeSum, category - barWidth / 2), m_validData); | |
|
79 | 82 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
80 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? negativeSum : domain()->minX(), category + barWidth / 2)); | |
|
83 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? negativeSum : domain()->minX(), category + barWidth / 2), m_validData); | |
|
81 | 84 | else |
|
82 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? negativeSum : 0, category + barWidth / 2)); | |
|
85 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? negativeSum : 0, category + barWidth / 2), m_validData); | |
|
83 | 86 | negativeSum += value; |
|
84 | 87 | } else { |
|
85 | bottomRight = domain()->calculateGeometryPoint(QPointF(value + positiveSum, category - barWidth / 2)); | |
|
88 | bottomRight = domain()->calculateGeometryPoint(QPointF(value + positiveSum, category - barWidth / 2), m_validData); | |
|
86 | 89 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
87 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? positiveSum : domain()->minX(), category + barWidth / 2)); | |
|
90 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? positiveSum : domain()->minX(), category + barWidth / 2), m_validData); | |
|
88 | 91 | else |
|
89 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? positiveSum : 0, category + barWidth / 2)); | |
|
92 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? positiveSum : 0, category + barWidth / 2), m_validData); | |
|
90 | 93 | positiveSum += value; |
|
91 | 94 | } |
|
95 | if (!m_validData) | |
|
96 | return QVector<QRectF>(); | |
|
92 | 97 | rect.setTopLeft(topLeft); |
|
93 | 98 | rect.setBottomRight(bottomRight); |
|
94 | 99 | layout.append(rect.normalized()); |
@@ -45,13 +45,15 void BarChartItem::initializeLayout() | |||
|
45 | 45 | QPointF bottomRight; |
|
46 | 46 | |
|
47 | 47 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { |
|
48 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + set/setCount * barWidth, domain()->minY())); | |
|
49 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2 + (set + 1)/setCount * barWidth, domain()->minY())); | |
|
48 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + set/setCount * barWidth, domain()->minY()), m_validData); | |
|
49 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2 + (set + 1)/setCount * barWidth, domain()->minY()), m_validData); | |
|
50 | 50 | } else { |
|
51 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + set/setCount * barWidth, 0)); | |
|
52 | bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/setCount * barWidth, 0)); | |
|
51 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + set/setCount * barWidth, 0), m_validData); | |
|
52 | bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/setCount * barWidth, 0), m_validData); | |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | if (!m_validData) | |
|
56 | return; | |
|
55 | 57 | rect.setTopLeft(topLeft); |
|
56 | 58 | rect.setBottomRight(bottomRight); |
|
57 | 59 | m_layout.append(rect.normalized()); |
@@ -72,12 +74,16 QVector<QRectF> BarChartItem::calculateLayout() | |||
|
72 | 74 | for (int set = 0; set < setCount; set++) { |
|
73 | 75 | qreal value = m_series->barSets().at(set)->at(category); |
|
74 | 76 | QRectF rect; |
|
75 | QPointF topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set)/(setCount) * barWidth, value)); | |
|
77 | QPointF topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set)/(setCount) * barWidth, value), m_validData); | |
|
76 | 78 | QPointF bottomRight; |
|
77 | 79 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
78 | bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/(setCount) * barWidth, domain()->minY())); | |
|
80 | bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/(setCount) * barWidth, domain()->minY()), m_validData); | |
|
79 | 81 | else |
|
80 | bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/(setCount) * barWidth, 0)); | |
|
82 | bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/(setCount) * barWidth, 0), m_validData); | |
|
83 | ||
|
84 | if (!m_validData) | |
|
85 | return QVector<QRectF>(); | |
|
86 | ||
|
81 | 87 | rect.setTopLeft(topLeft); |
|
82 | 88 | rect.setBottomRight(bottomRight); |
|
83 | 89 | layout.append(rect.normalized()); |
@@ -45,13 +45,16 void PercentBarChartItem::initializeLayout() | |||
|
45 | 45 | QPointF bottomRight; |
|
46 | 46 | |
|
47 | 47 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { |
|
48 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, domain()->minY())); | |
|
49 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, domain()->minY())); | |
|
48 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, domain()->minY()), m_validData); | |
|
49 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, domain()->minY()), m_validData); | |
|
50 | 50 | } else { |
|
51 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, 0)); | |
|
52 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, 0)); | |
|
51 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, 0), m_validData); | |
|
52 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, 0), m_validData); | |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | if (!m_validData) | |
|
56 | return; | |
|
57 | ||
|
55 | 58 | rect.setTopLeft(topLeft); |
|
56 | 59 | rect.setBottomRight(bottomRight); |
|
57 | 60 | m_layout.append(rect.normalized()); |
@@ -74,12 +77,15 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||
|
74 | 77 | for (int set = 0; set < setCount; set++) { |
|
75 | 78 | qreal value = m_series->barSets().at(set)->at(category); |
|
76 | 79 | QRectF rect; |
|
77 | QPointF topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth/2, 100 * (value + sum)/categorySum)); | |
|
80 | QPointF topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth/2, 100 * (value + sum)/categorySum), m_validData); | |
|
78 | 81 | QPointF bottomRight; |
|
79 | 82 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
80 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth/2, set ? 100 * sum/categorySum : domain()->minY())); | |
|
83 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth/2, set ? 100 * sum/categorySum : domain()->minY()), m_validData); | |
|
81 | 84 | else |
|
82 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth/2, set ? 100 * sum/categorySum : 0)); | |
|
85 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth/2, set ? 100 * sum/categorySum : 0), m_validData); | |
|
86 | ||
|
87 | if (!m_validData) | |
|
88 | return QVector<QRectF>(); | |
|
83 | 89 | rect.setTopLeft(topLeft); |
|
84 | 90 | rect.setBottomRight(bottomRight); |
|
85 | 91 | layout.append(rect.normalized()); |
@@ -45,13 +45,16 void StackedBarChartItem::initializeLayout() | |||
|
45 | 45 | QPointF bottomRight; |
|
46 | 46 | |
|
47 | 47 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { |
|
48 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, domain()->minY())); | |
|
49 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, domain()->minY())); | |
|
48 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, domain()->minY()), m_validData); | |
|
49 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, domain()->minY()), m_validData); | |
|
50 | 50 | } else { |
|
51 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, 0)); | |
|
52 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, 0)); | |
|
51 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, 0), m_validData); | |
|
52 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, 0), m_validData); | |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | if (!m_validData) | |
|
56 | return; | |
|
57 | ||
|
55 | 58 | rect.setTopLeft(topLeft); |
|
56 | 59 | rect.setBottomRight(bottomRight); |
|
57 | 60 | m_layout.append(rect.normalized()); |
@@ -76,20 +79,22 QVector<QRectF> StackedBarChartItem::calculateLayout() | |||
|
76 | 79 | QPointF topLeft; |
|
77 | 80 | QPointF bottomRight; |
|
78 | 81 | if (value < 0) { |
|
79 | bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, value + negativeSum)); | |
|
82 | bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, value + negativeSum), m_validData); | |
|
80 | 83 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
81 | topLeft = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? negativeSum : domain()->minY())); | |
|
84 | topLeft = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? negativeSum : domain()->minY()), m_validData); | |
|
82 | 85 | else |
|
83 | topLeft = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? negativeSum : 0)); | |
|
86 | topLeft = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? negativeSum : 0), m_validData); | |
|
84 | 87 | negativeSum += value; |
|
85 | 88 | } else { |
|
86 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, value + positiveSum)); | |
|
89 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, value + positiveSum), m_validData); | |
|
87 | 90 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
88 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : domain()->minY())); | |
|
91 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : domain()->minY()), m_validData); | |
|
89 | 92 | else |
|
90 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : 0)); | |
|
93 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : 0), m_validData); | |
|
91 | 94 | positiveSum += value; |
|
92 | 95 | } |
|
96 | if (!m_validData) | |
|
97 | return QVector<QRectF>(); | |
|
93 | 98 | rect.setTopLeft(topLeft); |
|
94 | 99 | rect.setBottomRight(bottomRight); |
|
95 | 100 | layout.append(rect.normalized()); |
@@ -408,8 +408,9 QPointF ChartDataSet::mapToPosition(const QPointF &value, QAbstractSeries *serie | |||
|
408 | 408 | if (series && series->type() == QAbstractSeries::SeriesTypePie) |
|
409 | 409 | return QPoint(0, 0); |
|
410 | 410 | |
|
411 | bool ok; | |
|
411 | 412 | if (series && m_seriesList.contains(series)) |
|
412 | point += series->d_ptr->m_domain->calculateGeometryPoint(value); | |
|
413 | point += series->d_ptr->m_domain->calculateGeometryPoint(value, ok); | |
|
413 | 414 | return point; |
|
414 | 415 | } |
|
415 | 416 |
@@ -26,6 +26,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
26 | 26 | |
|
27 | 27 | ChartItem::ChartItem(QAbstractSeriesPrivate *series,QGraphicsItem* item): |
|
28 | 28 | ChartElement(item), |
|
29 | m_validData(true), | |
|
29 | 30 | m_series(series) |
|
30 | 31 | { |
|
31 | 32 |
@@ -45,8 +45,11 public: | |||
|
45 | 45 | AbstractDomain* domain() const; |
|
46 | 46 | public Q_SLOTS: |
|
47 | 47 | virtual void handleDomainUpdated(); |
|
48 | ||
|
49 | protected: | |
|
50 | bool m_validData; | |
|
48 | 51 | private: |
|
49 | QAbstractSeriesPrivate* m_series; | |
|
52 | QAbstractSeriesPrivate* m_series; | |
|
50 | 53 | }; |
|
51 | 54 | |
|
52 | 55 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -80,7 +80,7 public: | |||
|
80 | 80 | virtual void zoomOut(const QRectF &rect) = 0; |
|
81 | 81 | virtual void move(qreal dx, qreal dy) = 0; |
|
82 | 82 | |
|
83 | virtual QPointF calculateGeometryPoint(const QPointF &point) const = 0; | |
|
83 | virtual QPointF calculateGeometryPoint(const QPointF &point, bool &ok) const = 0; | |
|
84 | 84 | virtual QPointF calculateDomainPoint(const QPointF &point) const = 0; |
|
85 | 85 | virtual QVector<QPointF> calculateGeometryPoints(const QList<QPointF>& vector) const = 0; |
|
86 | 86 |
@@ -54,7 +54,7 void LogXLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |||
|
54 | 54 | m_logLeftX = logMinX < logMaxX ? logMinX : logMaxX; |
|
55 | 55 | m_logRightX = logMinX > logMaxX ? logMinX : logMaxX; |
|
56 | 56 | if(!m_signalsBlocked) |
|
57 | emit rangeHorizontalChanged(m_minX, m_maxX); | |
|
57 | emit rangeHorizontalChanged(m_minX, m_maxX); | |
|
58 | 58 | } |
|
59 | 59 | |
|
60 | 60 | if (!qFuzzyIsNull(m_minY - minY) || !qFuzzyIsNull(m_maxY - maxY)) { |
@@ -66,7 +66,7 void LogXLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |||
|
66 | 66 | m_logLeftY = logMinY < logMaxY ? logMinY : logMaxY; |
|
67 | 67 | m_logRightY = logMinY > logMaxY ? logMinY : logMaxY; |
|
68 | 68 | if(!m_signalsBlocked) |
|
69 | emit rangeVerticalChanged(m_minY, m_maxY); | |
|
69 | emit rangeVerticalChanged(m_minY, m_maxY); | |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | if (axisXChanged || axisYChanged) |
@@ -131,13 +131,20 void LogXLogYDomain::move(qreal dx, qreal dy) | |||
|
131 | 131 | setRange(minX, maxX, minY, maxY); |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | QPointF LogXLogYDomain::calculateGeometryPoint(const QPointF &point) const | |
|
134 | QPointF LogXLogYDomain::calculateGeometryPoint(const QPointF &point, bool &ok) const | |
|
135 | 135 | { |
|
136 | const qreal deltaX = m_size.width() / qAbs(m_logRightX - m_logLeftX); | |
|
137 |
const qreal delta |
|
|
138 | qreal x = (log10(point.x()) / log10(m_logBaseX)) * deltaX - m_logLeftX * deltaX; | |
|
139 |
qreal |
|
|
140 | return QPointF(x, y); | |
|
136 | if (point.x() > 0 && point.y() > 0) { | |
|
137 | const qreal deltaX = m_size.width() / qAbs(m_logRightX - m_logLeftX); | |
|
138 | const qreal deltaY = m_size.height() / qAbs(m_logRightY - m_logLeftY); | |
|
139 | qreal x = (log10(point.x()) / log10(m_logBaseX)) * deltaX - m_logLeftX * deltaX; | |
|
140 | qreal y = (log10(point.y()) / log10(m_logBaseY)) * -deltaY - m_logLeftY * -deltaY + m_size.height(); | |
|
141 | ok = true; | |
|
142 | return QPointF(x, y); | |
|
143 | } else { | |
|
144 | qWarning() << "Logarithm of negative value is undefined. Empty layout returned"; | |
|
145 | ok = false; | |
|
146 | return QPointF(); | |
|
147 | } | |
|
141 | 148 | } |
|
142 | 149 | |
|
143 | 150 | QVector<QPointF> LogXLogYDomain::calculateGeometryPoints(const QList<QPointF>& vector) const |
@@ -149,10 +156,15 QVector<QPointF> LogXLogYDomain::calculateGeometryPoints(const QList<QPointF>& v | |||
|
149 | 156 | result.resize(vector.count()); |
|
150 | 157 | |
|
151 | 158 | for (int i = 0; i < vector.count(); ++i) { |
|
152 | qreal x = (log10(vector[i].x()) / log10(m_logBaseX)) * deltaX - m_logLeftX * deltaX; | |
|
153 |
qreal |
|
|
154 | result[i].setX(x); | |
|
155 |
result[i].set |
|
|
159 | if (vector[i].x() > 0 && vector[i].y() > 0) { | |
|
160 | qreal x = (log10(vector[i].x()) / log10(m_logBaseX)) * deltaX - m_logLeftX * deltaX; | |
|
161 | qreal y = (log10(vector[i].y()) / log10(m_logBaseY)) * -deltaY - m_logLeftY * -deltaY + m_size.height(); | |
|
162 | result[i].setX(x); | |
|
163 | result[i].setY(y); | |
|
164 | } else { | |
|
165 | qWarning() << "Logarithm of negative value is undefined. Empty layout returned"; | |
|
166 | return QVector<QPointF>(); | |
|
167 | } | |
|
156 | 168 | } |
|
157 | 169 | return result; |
|
158 | 170 | } |
@@ -54,7 +54,7 public: | |||
|
54 | 54 | void zoomOut(const QRectF &rect); |
|
55 | 55 | void move(qreal dx, qreal dy); |
|
56 | 56 | |
|
57 | QPointF calculateGeometryPoint(const QPointF &point) const; | |
|
57 | QPointF calculateGeometryPoint(const QPointF &point, bool &ok) const; | |
|
58 | 58 | QPointF calculateDomainPoint(const QPointF &point) const; |
|
59 | 59 | QVector<QPointF> calculateGeometryPoints(const QList<QPointF>& vector) const; |
|
60 | 60 |
@@ -51,7 +51,7 void LogXYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |||
|
51 | 51 | m_logLeftX = logMinX < logMaxX ? logMinX : logMaxX; |
|
52 | 52 | m_logRightX = logMinX > logMaxX ? logMinX : logMaxX; |
|
53 | 53 | if(!m_signalsBlocked) |
|
54 | emit rangeHorizontalChanged(m_minX, m_maxX); | |
|
54 | emit rangeHorizontalChanged(m_minX, m_maxX); | |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | if (!qFuzzyIsNull(m_minY - minY) || !qFuzzyIsNull(m_maxY - maxY)) { |
@@ -59,7 +59,7 void LogXYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |||
|
59 | 59 | m_maxY = maxY; |
|
60 | 60 | axisYChanged = true; |
|
61 | 61 | if(!m_signalsBlocked) |
|
62 | emit rangeVerticalChanged(m_minY, m_maxY); | |
|
62 | emit rangeVerticalChanged(m_minY, m_maxY); | |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | if (axisXChanged || axisYChanged) |
@@ -125,14 +125,22 void LogXYDomain::move(qreal dx, qreal dy) | |||
|
125 | 125 | setRange(minX, maxX, minY, maxY); |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | QPointF LogXYDomain::calculateGeometryPoint(const QPointF &point) const | |
|
128 | QPointF LogXYDomain::calculateGeometryPoint(const QPointF &point, bool &ok) const | |
|
129 | 129 | { |
|
130 | const qreal deltaX = m_size.width() / (m_logRightX - m_logLeftX); | |
|
131 | const qreal deltaY = m_size.height() / (m_maxY - m_minY); | |
|
132 | 130 | |
|
133 | qreal x = (log10(point.x()) / log10(m_logBaseX)) * deltaX - m_logLeftX * deltaX; | |
|
134 | qreal y = (point.y() - m_minY) * -deltaY + m_size.height(); | |
|
135 | return QPointF(x, y); | |
|
131 | if (point.x() > 0) { | |
|
132 | const qreal deltaX = m_size.width() / (m_logRightX - m_logLeftX); | |
|
133 | const qreal deltaY = m_size.height() / (m_maxY - m_minY); | |
|
134 | ||
|
135 | qreal x = (log10(point.x()) / log10(m_logBaseX)) * deltaX - m_logLeftX * deltaX; | |
|
136 | qreal y = (point.y() - m_minY) * -deltaY + m_size.height(); | |
|
137 | ok = true; | |
|
138 | return QPointF(x, y); | |
|
139 | } else { | |
|
140 | qWarning() << "Logarithm of negative value is undefined. Empty layout returned"; | |
|
141 | ok = false; | |
|
142 | return QPointF(); | |
|
143 | } | |
|
136 | 144 | } |
|
137 | 145 | |
|
138 | 146 | QVector<QPointF> LogXYDomain::calculateGeometryPoints(const QList<QPointF>& vector) const |
@@ -144,10 +152,15 QVector<QPointF> LogXYDomain::calculateGeometryPoints(const QList<QPointF>& vect | |||
|
144 | 152 | result.resize(vector.count()); |
|
145 | 153 | |
|
146 | 154 | for (int i = 0; i < vector.count(); ++i) { |
|
147 | qreal x = (log10(vector[i].x()) / log10(m_logBaseX)) * deltaX - m_logLeftX * deltaX; | |
|
148 | qreal y = (vector[i].y() - m_minY) * -deltaY + m_size.height(); | |
|
149 | result[i].setX(x); | |
|
150 |
result[i].set |
|
|
155 | if (vector[i].x() > 0) { | |
|
156 | qreal x = (log10(vector[i].x()) / log10(m_logBaseX)) * deltaX - m_logLeftX * deltaX; | |
|
157 | qreal y = (vector[i].y() - m_minY) * -deltaY + m_size.height(); | |
|
158 | result[i].setX(x); | |
|
159 | result[i].setY(y); | |
|
160 | } else { | |
|
161 | qWarning() << "Logarithm of negative value is undefined. Empty layout returned"; | |
|
162 | return QVector<QPointF>(); | |
|
163 | } | |
|
151 | 164 | } |
|
152 | 165 | return result; |
|
153 | 166 | } |
@@ -54,7 +54,7 public: | |||
|
54 | 54 | void zoomOut(const QRectF &rect); |
|
55 | 55 | void move(qreal dx, qreal dy); |
|
56 | 56 | |
|
57 | QPointF calculateGeometryPoint(const QPointF &point) const; | |
|
57 | QPointF calculateGeometryPoint(const QPointF &point, bool &ok) const; | |
|
58 | 58 | QPointF calculateDomainPoint(const QPointF &point) const; |
|
59 | 59 | QVector<QPointF> calculateGeometryPoints(const QList<QPointF>& vector) const; |
|
60 | 60 |
@@ -47,7 +47,7 void XLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |||
|
47 | 47 | m_maxX = maxX; |
|
48 | 48 | axisXChanged = true; |
|
49 | 49 | if(!m_signalsBlocked) |
|
50 | emit rangeHorizontalChanged(m_minX, m_maxX); | |
|
50 | emit rangeHorizontalChanged(m_minX, m_maxX); | |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | 53 | if (!qFuzzyIsNull(m_minY - minY) || !qFuzzyIsNull(m_maxY - maxY)) { |
@@ -59,7 +59,7 void XLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |||
|
59 | 59 | m_logLeftY = logMinY < logMaxY ? logMinY : logMaxY; |
|
60 | 60 | m_logRightY = logMinY > logMaxY ? logMinY : logMaxY; |
|
61 | 61 | if(!m_signalsBlocked) |
|
62 | emit rangeVerticalChanged(m_minY, m_maxY); | |
|
62 | emit rangeVerticalChanged(m_minY, m_maxY); | |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | if (axisXChanged || axisYChanged) |
@@ -125,14 +125,21 void XLogYDomain::move(qreal dx, qreal dy) | |||
|
125 | 125 | setRange(minX, maxX, minY, maxY); |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | QPointF XLogYDomain::calculateGeometryPoint(const QPointF &point) const | |
|
128 | QPointF XLogYDomain::calculateGeometryPoint(const QPointF &point, bool &ok) const | |
|
129 | 129 | { |
|
130 | const qreal deltaX = m_size.width() / (m_maxX - m_minX); | |
|
131 |
const qreal delta |
|
|
132 | ||
|
133 | qreal x = (point.x() - m_minX) * deltaX; | |
|
134 | qreal y = (log10(point.y()) / log10(m_logBaseY)) * -deltaY - m_logLeftY * -deltaY + m_size.height(); | |
|
135 | return QPointF(x, y); | |
|
130 | if (point.y() > 0) { | |
|
131 | const qreal deltaX = m_size.width() / (m_maxX - m_minX); | |
|
132 | const qreal deltaY = m_size.height() / qAbs(m_logRightY - m_logLeftY); | |
|
133 | ||
|
134 | qreal x = (point.x() - m_minX) * deltaX; | |
|
135 | qreal y = (log10(point.y()) / log10(m_logBaseY)) * -deltaY - m_logLeftY * -deltaY + m_size.height(); | |
|
136 | ok = true; | |
|
137 | return QPointF(x, y); | |
|
138 | } else { | |
|
139 | qWarning() << "Logarithm of negative value is undefined. Empty layout returned"; | |
|
140 | ok = false; | |
|
141 | return QPointF(); | |
|
142 | } | |
|
136 | 143 | } |
|
137 | 144 | |
|
138 | 145 | QVector<QPointF> XLogYDomain::calculateGeometryPoints(const QList<QPointF>& vector) const |
@@ -144,10 +151,15 QVector<QPointF> XLogYDomain::calculateGeometryPoints(const QList<QPointF>& vect | |||
|
144 | 151 | result.resize(vector.count()); |
|
145 | 152 | |
|
146 | 153 | for (int i = 0; i < vector.count(); ++i) { |
|
147 |
|
|
|
148 | qreal y = (log10(vector[i].y()) / log10(m_logBaseY)) * -deltaY - m_logLeftY * -deltaY + m_size.height(); | |
|
149 | result[i].setX(x); | |
|
150 |
result[i].set |
|
|
154 | if (vector[i].y() > 0) { | |
|
155 | qreal x = (vector[i].x() - m_minX) * deltaX; | |
|
156 | qreal y = (log10(vector[i].y()) / log10(m_logBaseY)) * -deltaY - m_logLeftY * -deltaY + m_size.height(); | |
|
157 | result[i].setX(x); | |
|
158 | result[i].setY(y); | |
|
159 | } else { | |
|
160 | qWarning() << "Logarithm of negative value is undefined. Empty layout returned"; | |
|
161 | return QVector<QPointF>(); | |
|
162 | } | |
|
151 | 163 | } |
|
152 | 164 | return result; |
|
153 | 165 | } |
@@ -168,7 +180,7 bool XLogYDomain::attachAxis(QAbstractAxis* axis) | |||
|
168 | 180 | if(logAxis && logAxis->orientation()==Qt::Vertical){ |
|
169 | 181 | QObject::connect(logAxis, SIGNAL(baseChanged(qreal)), this, SLOT(handleVerticalAxisBaseChanged(qreal))); |
|
170 | 182 | handleVerticalAxisBaseChanged(logAxis->base()); |
|
171 | } | |
|
183 | } | |
|
172 | 184 | return AbstractDomain::attachAxis(axis); |
|
173 | 185 | } |
|
174 | 186 |
@@ -54,7 +54,7 public: | |||
|
54 | 54 | void zoomOut(const QRectF &rect); |
|
55 | 55 | void move(qreal dx, qreal dy); |
|
56 | 56 | |
|
57 | QPointF calculateGeometryPoint(const QPointF &point) const; | |
|
57 | QPointF calculateGeometryPoint(const QPointF &point, bool &ok) const; | |
|
58 | 58 | QPointF calculateDomainPoint(const QPointF &point) const; |
|
59 | 59 | QVector<QPointF> calculateGeometryPoints(const QList<QPointF>& vector) const; |
|
60 | 60 |
@@ -116,12 +116,13 void XYDomain::move(qreal dx, qreal dy) | |||
|
116 | 116 | setRange(minX, maxX, minY, maxY); |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | QPointF XYDomain::calculateGeometryPoint(const QPointF &point) const | |
|
119 | QPointF XYDomain::calculateGeometryPoint(const QPointF &point, bool &ok) const | |
|
120 | 120 | { |
|
121 | 121 | const qreal deltaX = m_size.width() / (m_maxX - m_minX); |
|
122 | 122 | const qreal deltaY = m_size.height() / (m_maxY - m_minY); |
|
123 | 123 | qreal x = (point.x() - m_minX) * deltaX; |
|
124 | 124 | qreal y = (point.y() - m_minY) * -deltaY + m_size.height(); |
|
125 | ok = true; | |
|
125 | 126 | return QPointF(x, y); |
|
126 | 127 | } |
|
127 | 128 |
@@ -54,7 +54,7 public: | |||
|
54 | 54 | void zoomOut(const QRectF &rect); |
|
55 | 55 | void move(qreal dx, qreal dy); |
|
56 | 56 | |
|
57 | QPointF calculateGeometryPoint(const QPointF &point) const; | |
|
57 | QPointF calculateGeometryPoint(const QPointF &point, bool &ok) const; | |
|
58 | 58 | QPointF calculateDomainPoint(const QPointF &point) const; |
|
59 | 59 | QVector<QPointF> calculateGeometryPoints(const QList<QPointF>& vector) const; |
|
60 | 60 | }; |
@@ -135,15 +135,15 void LineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | |||
|
135 | 135 | void LineChartItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
136 | 136 | { |
|
137 | 137 | emit XYChart::hovered(domain()->calculateDomainPoint(event->pos()), true); |
|
138 | event->accept(); | |
|
139 |
|
|
|
138 | // event->accept(); | |
|
139 | QGraphicsItem::hoverEnterEvent(event); | |
|
140 | 140 | } |
|
141 | 141 | |
|
142 | 142 | void LineChartItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
143 | 143 | { |
|
144 | 144 | emit XYChart::hovered(domain()->calculateDomainPoint(event->pos()), false); |
|
145 | event->accept(); | |
|
146 |
|
|
|
145 | // event->accept(); | |
|
146 | QGraphicsItem::hoverEnterEvent(event); | |
|
147 | 147 | } |
|
148 | 148 | |
|
149 | 149 | #include "moc_linechartitem_p.cpp" |
@@ -101,7 +101,8 void SplineChartItem::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> | |||
|
101 | 101 | |
|
102 | 102 | QPointF SplineChartItem::calculateGeometryControlPoint(int index) const |
|
103 | 103 | { |
|
104 | return domain()->calculateGeometryPoint(m_series->d_func()->controlPoint(index)); | |
|
104 | bool ok; | |
|
105 | return domain()->calculateGeometryPoint(m_series->d_func()->controlPoint(index), ok); | |
|
105 | 106 | } |
|
106 | 107 | |
|
107 | 108 | void SplineChartItem::updateGeometry() |
@@ -176,13 +177,13 void SplineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | |||
|
176 | 177 | void SplineChartItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
177 | 178 | { |
|
178 | 179 | emit XYChart::hovered(domain()->calculateDomainPoint(event->pos()), true); |
|
179 | event->accept(); | |
|
180 | QGraphicsItem::hoverEnterEvent(event); | |
|
180 | 181 | } |
|
181 | 182 | |
|
182 | 183 | void SplineChartItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
183 | 184 | { |
|
184 | 185 | emit XYChart::hovered(domain()->calculateDomainPoint(event->pos()), false); |
|
185 | event->accept(); | |
|
186 | QGraphicsItem::hoverLeaveEvent(event); | |
|
186 | 187 | } |
|
187 | 188 | |
|
188 | 189 | #include "moc_splinechartitem_p.cpp" |
@@ -88,7 +88,11 void XYChart::handlePointAdded(int index) | |||
|
88 | 88 | points = domain()->calculateGeometryPoints(m_series->points()); |
|
89 | 89 | } else { |
|
90 | 90 | points = m_points; |
|
91 | QPointF point = domain()->calculateGeometryPoint(m_series->points()[index]); | |
|
91 | QPointF point = domain()->calculateGeometryPoint(m_series->points()[index], m_validData); | |
|
92 | if (!m_validData) { | |
|
93 | m_points.clear(); | |
|
94 | return; | |
|
95 | } | |
|
92 | 96 | points.insert(index, point); |
|
93 | 97 | } |
|
94 | 98 | |
@@ -122,7 +126,11 void XYChart::handlePointReplaced(int index) | |||
|
122 | 126 | if (m_dirty) { |
|
123 | 127 | points = domain()->calculateGeometryPoints(m_series->points()); |
|
124 | 128 | } else { |
|
125 | QPointF point = domain()->calculateGeometryPoint(m_series->points()[index]); | |
|
129 | QPointF point = domain()->calculateGeometryPoint(m_series->points()[index], m_validData); | |
|
130 | if (!m_validData) { | |
|
131 | m_points.clear(); | |
|
132 | return; | |
|
133 | } | |
|
126 | 134 | points = m_points; |
|
127 | 135 | points.replace(index, point); |
|
128 | 136 | } |
General Comments 0
You need to be logged in to leave comments.
Login now