Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MainWindow::drawChart(QtCharts::QChart *chart, QtCharts::QXYSeries *series, const QModelIndex &index)
- {
- QPointF p;
- QVector<QPointF> points;
- double min_x = std::numeric_limits<double>::max();
- double max_x = -std::numeric_limits<double>::max();
- double min_y = std::numeric_limits<double>::max();
- double max_y = -std::numeric_limits<double>::max();
- QList<QVariant> var = index.data(Qt::DisplayRole).toList();
- for (int i = 0; i < var.size(); i++)
- {
- p = var.at(i).toPointF();
- points << p;
- min_x = std::min(min_x, p.x());
- min_y = std::min(min_y, p.y());
- max_x = std::max(max_x, p.x());
- max_y = std::max(max_y, p.y());
- }
- series->replace(points);
- chart->axisX()->setRange(min_x, max_x);
- chart->axisY()->setRange(min_y, max_y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement