QtCharts recalculate/update axis for new series values
Unsolved
General and Desktop
-
Hi
I have a slot function updatePlot(...) that receives a QVector<double> and iterates through the vector data
and fills a series which has been cleared prior.{ ... ls = new QLineSeries(); chart = new QChart(); xAxis = new QValueAxis; yAxis = new QValueAxis; cv = new QChartView(chart); chart->addSeries(ls); chart->addAxis(xAxis, Qt::AlignBottom); chart->addAxis(yAxis, Qt::AlignLeft); ls->attachAxis(xAxis); ls->attachAxis(yAxis); ... } ... void PlotWindow::updatePlot(const QVector<double> &dat) { ls->clear(); for(int i=0;i<dat.size();i++){ ls->append(i,dat.at(i)); } }
The problem of course is now that the data changes x and y ranges every time, but the axes
stay at the same range. What is the proper way to recalculate the x/y axes ranges?Do I have to take care of it and calculate the high/low values in the for loop or is there a function in the qtcharts that does this for me?