|
Strange Ticks and Labels in Real-Time Chart |
Posted by Fabio on Jan-15-2016 06:21 |
|
Hello,
I have a Qt 5.5 project with ChartDirector 6.0 that has a chart dialog. The dialog displays real-time line charts (as the one in realtimezoomscroll) and real-time scatter charts (as the one in xyzoomscroll).
With the help of this forum, I have been able to have a chart, which has square grids with the same scales (i.e., a square grid with a side of 25 cm). This scenario works well most of the time. However, from time to time, the chart starts showing labels with about 20 decimals, and some of the grid lines become very dense as shown in the attached chart.
I will greatly appreciate your support to debug this issue,
Fabio
|
Re: Strange Ticks and Labels in Real-Time Chart |
Posted by Peter Kwan on Jan-16-2016 04:31 |
|
Hi Fabio,
This is usually caused by trying to set the axis scale twice with conflicting values. One
common case is to use both Axis.setLinearScale and
QChartViewer.syncLinearAxisWithViewPort.
The purpose of Axis.setLinearScale is to configure the axis scale to the specified values.
The purpose of QChartViewer.syncLinearAxisWithViewPort is to configure the axis scale
according to the viewport. These two methods inherently are in conflict, as they configure
the scale and labels of the same axis to different values.
If the above is the cause of the problem, there are several methods:
(a) If the purpose of Axis.setLinearScale is to configure the full scale of the initial chart,
you may consider to use QChartViewer.setFullScale instead.
(b) Alternatively, you may make sure the Axis.setLinearScale is only run the first time the
chart is drawn, and is not run for subsequent redrawing of the chart due to zoom/scroll or
other viewport events. (A flag and an "if" statement may be used to determine if the chart
is generated for the first time, and only then the Axis.setLinearScale is used.)
Hope this can help.
Regards
Peter Kwan |
Re: Strange Ticks and Labels in Real-Time Chart |
Posted by Fabio on Jan-26-2016 02:47 |
|
Hi Peter,
I decided to use method (b) to solve the issue. In my chart dialog, I changed the code to:
// Set grid lines to geometrically form squares
if (solutionSet->getIndex() <= 1) {
xyChart->xAxis()->setLinearScale(0, 100, 10, 5);
xyChart->yAxis()->setLinearScale(-30, 70, 10, 5);
}
You may consider this issue as resolved.
I greatly appreciate your continued support,
Fabio |
|