Hallo,
I am running a timeline-like QChart. To follow the graph as data come in I continuously call a slot to dateTimeAxis->setMin and ->setMax.
// create chart
timeLine = new QChart();
// manage X-axis
dateTimeAxis = new QDateTimeAxis;
dateTimeAxis->setTickCount(9);
dateTimeAxis->setFormat("hh:mm");
dateTimeAxis->setMin(currentTime.addSecs(-rangeAxisX / 2));
dateTimeAxis->setMax(currentTime.addSecs( rangeAxisX / 2));
chartView = new QChartView(timeLine);
connect(&timer, SIGNAL(timeout()), this, SLOT(updateChart()));
void MainWindow::updateChart(){
// get current time
dateTimeAxis->setMin(currentTime.addSecs(-rangeAxisX / 2));
dateTimeAxis->setMax(currentTime.addSecs( rangeAxisX / 2));
}
// create chart
timeLine = new QChart();
// manage X-axis
dateTimeAxis = new QDateTimeAxis;
dateTimeAxis->setTickCount(9);
dateTimeAxis->setFormat("hh:mm");
dateTimeAxis->setMin(currentTime.addSecs(-rangeAxisX / 2));
dateTimeAxis->setMax(currentTime.addSecs( rangeAxisX / 2));
chartView = new QChartView(timeLine);
connect(&timer, SIGNAL(timeout()), this, SLOT(updateChart()));
void MainWindow::updateChart(){
// get current time
currentTime = QDateTime::currentDateTime();
dateTimeAxis->setMin(currentTime.addSecs(-rangeAxisX / 2));
dateTimeAxis->setMax(currentTime.addSecs( rangeAxisX / 2));
}
To copy to clipboard, switch view to plain text mode
Problem: the grid does not move as one expect it to do on a timeline. Much more it remains static as the labels on the ticks change instead.
I would like to have a "moving grid" with ticks at every - lets say - five minutes.
<..|.....|.....|.....|...<
<-5---10--15---20-<
I tried a little bit around in the chartview-class and the scroll-thing. But it turned out, that (as far as my sorrier knowledge allows me to conclude) these things work in integers while my chart lives in qreal. So - this results in a quite rough user-experience.
Any idea welcome.
Thanks in advance, Lars
Bookmarks