##// END OF EJS Templates
First version of legend. Simple markers and serie names. Using drilldown as example for now.
First version of legend. Simple markers and serie names. Using drilldown as example for now.

File last commit:

r486:7ab45bf9f776
r529:73dc1554f5c7
Show More
mainwindow.cpp
54 lines | 1.4 KiB | text/x-c | CppLexer
#include "mainwindow.h"
#include <qchartglobal.h>
#include <qchartview.h>
#include <QDebug>
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) {
*m_scatter << QPointF(x, y);
}
}
chartView->addSeries(m_scatter);
// Add two more series
m_scatter2 = new QScatterSeries();
chartView->addSeries(m_scatter2);
m_scatter3 = new QScatterSeries();
chartView->addSeries(m_scatter3);
connect(m_scatter, SIGNAL(clicked(QPointF)), this, SLOT(clickPoint(QPointF)));
}
MainWindow::~MainWindow()
{
}
void MainWindow::clickPoint(QPointF coordinate)
{
// Remove the clicked point from the series and add points to the two other series we have
//TODO: fix me
/*
int index = m_scatter->closestPoint(coordinate);
QPointF point = m_scatter->data().at(index);
Q_ASSERT(m_scatter->removeAt(index));
point.rx() += 0.25;
point.ry() += 0.25;
*m_scatter2 << point;
point.ry() -= 0.25;
*m_scatter3 << point;
*/
}