diff --git a/examples/scatterinteractions/main.cpp b/examples/scatterinteractions/main.cpp index 9ae175b..109e5ea 100644 --- a/examples/scatterinteractions/main.cpp +++ b/examples/scatterinteractions/main.cpp @@ -5,6 +5,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; + w.resize(400, 300); w.show(); return a.exec(); diff --git a/examples/scatterinteractions/mainwindow.cpp b/examples/scatterinteractions/mainwindow.cpp index 7179cf5..5655003 100644 --- a/examples/scatterinteractions/mainwindow.cpp +++ b/examples/scatterinteractions/mainwindow.cpp @@ -8,17 +8,14 @@ QTCOMMERCIALCHART_USE_NAMESPACE MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { - resize(400, 300); - setWindowFlags(Qt::FramelessWindowHint); - QChartView *chartView = new QChartView(this); chartView->setChartTitle("Click to play with points"); chartView->setRenderHint(QPainter::Antialiasing); setCentralWidget(chartView); m_scatter = new QScatterSeries(); - for(qreal x(0.5); x <= 5.0; x += 0.5) { - for(qreal y(0.5); y <= 5.0; y += 0.5) { + for(qreal x(0.5); x <= 4.0; x += 0.5) { + for(qreal y(0.5); y <= 4.0; y += 0.5) { *m_scatter << QPointF(x, y); } } diff --git a/src/scatterseries/scatterchartitem.cpp b/src/scatterseries/scatterchartitem.cpp index ade29cf..44f95cc 100644 --- a/src/scatterseries/scatterchartitem.cpp +++ b/src/scatterseries/scatterchartitem.cpp @@ -6,6 +6,12 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE + + + + + + ScatterChartItem::ScatterChartItem(QScatterSeries *series, QGraphicsItem *parent) : XYChartItem(series,parent), m_series(series), @@ -113,7 +119,8 @@ void ScatterChartItem::setGeometry(QVector& points) for(int i=0; i< points.size();i++) { QGraphicsItem* item = items.at(i); const QPointF& point = points.at(i); - item->setPos(point.x()-1,point.y()-1); + const QRectF& rect = item->boundingRect(); + item->setPos(point.x()-rect.width()/2,point.y()-rect.height()/2); if(!clipRect().contains(point)) { item->setVisible(false); } diff --git a/src/scatterseries/scatterchartitem_p.h b/src/scatterseries/scatterchartitem_p.h index f63f117..9c1a39b 100644 --- a/src/scatterseries/scatterchartitem_p.h +++ b/src/scatterseries/scatterchartitem_p.h @@ -3,7 +3,7 @@ #include "qchartglobal.h" #include "xychartitem_p.h" -#include +#include #include QTCOMMERCIALCHART_BEGIN_NAMESPACE