DateTimeAxis - How to set min and max?



  • Hi,

    I'm working on a chart which should show the time from 0 to 24 h on the x axis. Is there any example out there?

    My code snippet:

    @
    import QtQuick 2.3
    import QtQuick.Controls 1.2
    import QtCharts 2.0

    Rectangle {
    id: detailRectangle
    anchors.fill: parent

    ChartView {
        title: "Line"
        anchors.fill: parent
        antialiasing: true
    
        LineSeries {
            axisY: ValueAxis {
                min: 0
                max: 1
                titleText: "kWh"
            }
    
            axisX: DateTimeAxis {
                format: "hh:mm"
                tickCount: 5
                min: new Date("October 13, 2014 11:13:00");
                max: new Date("October 13, 2014 13:13:00");
            }
    
            name: "LineSeries"
            XYPoint { x: 0; y: 0 }
            XYPoint { x: 1.1; y: 2.1 }
            XYPoint { x: 1.9; y: 3.3 }
            XYPoint { x: 2.1; y: 2.1 }
            XYPoint { x: 2.9; y: 4.9 }
            XYPoint { x: 3.4; y: 3.0 }
            XYPoint { x: 4.1; y: 3.3 }
        }
    }
    

    }
    @


  • Lifetime Qt Champion

    Hi,

    Following the QDateTime doc i'd try with "HH:mm"

    Hope it helps


Log in to reply
 

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