@@ -31,7 +31,7 void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q | |||||
31 | if (!m_rect.contains(anchor)) { |
|
31 | if (!m_rect.contains(anchor)) { | |
32 | QPointF point1, point2; |
|
32 | QPointF point1, point2; | |
33 |
|
33 | |||
34 |
// establish the position of the anchor point in relation to m_ |
|
34 | // establish the position of the anchor point in relation to m_rect | |
35 | bool above = anchor.y() <= m_rect.top(); |
|
35 | bool above = anchor.y() <= m_rect.top(); | |
36 | bool aboveCenter = anchor.y() > m_rect.top() && anchor.y() <= m_rect.center().y(); |
|
36 | bool aboveCenter = anchor.y() > m_rect.top() && anchor.y() <= m_rect.center().y(); | |
37 | bool belowCenter = anchor.y() > m_rect.center().y() && anchor.y() <= m_rect.bottom(); |
|
37 | bool belowCenter = anchor.y() > m_rect.center().y() && anchor.y() <= m_rect.bottom(); | |
@@ -42,7 +42,7 void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q | |||||
42 | bool rightOfCenter = anchor.x() > m_rect.center().x() && anchor.x() <= m_rect.right(); |
|
42 | bool rightOfCenter = anchor.x() > m_rect.center().x() && anchor.x() <= m_rect.right(); | |
43 | bool onRight = anchor.x() > m_rect.right(); |
|
43 | bool onRight = anchor.x() > m_rect.right(); | |
44 |
|
44 | |||
45 |
// get the nearest m_ |
|
45 | // get the nearest m_rect corner. | |
46 | qreal x = (onRight + rightOfCenter) * m_rect.width(); |
|
46 | qreal x = (onRight + rightOfCenter) * m_rect.width(); | |
47 | qreal y = (below + belowCenter) * m_rect.height(); |
|
47 | qreal y = (below + belowCenter) * m_rect.height(); | |
48 | bool cornerCase = (above && onLeft) || (above && onRight) || (below && onLeft) || (below && onRight); |
|
48 | bool cornerCase = (above && onLeft) || (above && onRight) || (below && onLeft) || (below && onRight); |
@@ -6,7 +6,9 | |||||
6 | This demo shows how to draw an additional element (a callout) on top of the chart. |
|
6 | This demo shows how to draw an additional element (a callout) on top of the chart. | |
7 | \image demos_callout.png |
|
7 | \image demos_callout.png | |
8 |
|
8 | |||
9 |
QChart class provides two methods that map between the scene coordinates and the series' domain (define |
|
9 | QChart class provides two methods that map between the scene coordinates and the series' domain (defined by the axes ranges). | |
|
10 | ||||
10 | QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series) |
|
11 | QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series) | |
|
12 | ||||
11 | QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series) |
|
13 | QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series) | |
12 | */ |
|
14 | */ |
General Comments 0
You need to be logged in to leave comments.
Login now