コード例 #1
0
QCPDataMap *Layout2D::generateDataMap(Column *xData, Column *yData, int from,
                                      int to) {
  QCPDataMap *dataMap = new QCPDataMap();

  double xdata = 0, ydata = 0;
  for (int i = from; i < to + 1; i++) {
    xdata = xData->valueAt(i);
    ydata = yData->valueAt(i);
    dataMap->insert(xdata, QCPData(xdata, ydata));
  }
  return dataMap;
}
コード例 #2
0
void MainWindow::setupGraphTest(QCustomPlot *customPlot)
{
	customPlot->addGraph();

	QCPDataMap *dataMap = new QCPDataMap;
	int n = 10e6;
	QTime t;
	t.start();
	for (int i=0; i<n; ++i)
	{
		dataMap->insert(i, QCPData(i, i));
	}
	qDebug() << "data" << t.restart();
	customPlot->graph(0)->setData(dataMap, false);
	qDebug() << "set" << t.restart();
	customPlot->xAxis->setRange(0, 50);
	customPlot->yAxis->setRange(-1, 1);
	t.restart();
	customPlot->replot();
	qDebug() << "replot" << t.restart();
	//customPlot->rescaleAxes();
}