[Qt charts 2.1] Problem with DateTimeAxis



  • Hi everybody,

    I'm facing to an issue with qt charts 2.1
    I need to draw a line series within a 10 seconds interval. I have created a DateTimeAxis with min and max parameters set accordingly to my need. It seems that when the time resolution is too high (interval less than few seconds), points are located at the same x position .. Here is a minimalist code which reproduce the problem :

    import QtQuick 2.5
    import QtQuick.Window 2.2
    import QtCharts 2.1
    
    
    Window {
    
        visible: true
        width: 640
        height: 480
    
        ChartView {
            id: chartView
            anchors.fill: parent
            property bool openGL: true
    
            ValueAxis {
                id: axisY1
                min: -1.5
                max: 1.5
                tickCount: 5
                minorTickCount: 5
            }
    
            DateTimeAxis {
                id: axisX
                tickCount: 10
                min: new Date(new Date() - 10000)
                max: new Date()
                format: "mm:ss"
            }
    
            LineSeries {
                id: lineSeries1
                name: "signal 1"
                axisX: axisX
                axisY: axisY1
                useOpenGL: chartView.openGL
                XYPoint { x: toMsecsSinceEpoch(new Date(new Date() - 10000)); y: -1 }
                XYPoint { x: toMsecsSinceEpoch(new Date()); y: 1 }
            }
        }
    
        function toMsecsSinceEpoch(date) {
            var msecs = date.getTime();
            return msecs;
        }
    }
    
    

    The visual result is a vertical line located at the left of the chart ..
    Any ideas for solve that ?



  • Hello,
    I am also having this same issue. It seems as though this problem with the DateTimeAxis only persists when used in QML, as I created a simple example using my same dataset with a strictly c++ approach and the dataset was displayed correctly. When used in QML, the points are all mapped to the same X position, as you have stated.


Log in to reply
 

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