Resizing axis causes artifacts in a LineSeries binded to QAbstractTableModel



  • I've built a sample QtQuick 2 application which plots a line series dynamically using QtCharts.

    The data for the Line series comes from C++ using a model derived from QAbstractTableModel class and exposed by a QVXYModelMapper.

    The problem is that during resizing the axis, some artifacts are produced in the plotted series. Specifically, a straight line appears which goes from the previous plotted point to the current plotting position.

    This issue only happens for the QAbstractTableModel-based series. You can see an example of this happening several times because of resize in the following screenshot:

    The buggy series is the green one. Note that the data for blue series is generated completely in QML and it doesn't have this issue.

    The source code of reproducing this problem is available here:

    https://github.com/nickaein/qtcharts_dynamic_series

    Here is the main.qml from this source code just for reference:

    import QtQuick 2.7
    import QtQuick.Window 2.2
    import QtQuick.Controls 2.0
    import QtCharts 2.0
    
    ApplicationWindow {
    	visible: true
    	width: 600
    	height: 300
    	property int timeStep: 0
    
    	ChartView {
    		id: chartView
    		anchors.fill: parent
    
    		ValueAxis {
    			id: axisX
    			min: 0
    			max: 400
    		}
    
    		Component.onCompleted:  {
    			mapper.series = series2
    		}
    
    		LineSeries {
    			id: series1
    			axisX: axisX
    		}
    
    		LineSeries {
    			id: series2
    			axisX: axisX
    		}
    	}
    
    	Timer {
    		interval: 100
    		repeat: true
    		running: true
    		onTriggered: {
    			timeStep++;
    			var y = (1+Math.cos(timeStep/10.0))/2.0;
    			series1.append(timeStep, y);
    		}
    	}
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.