Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Listmodel and BarSeries
Qt 6.11 is out! See what's new in the release blog

Listmodel and BarSeries

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 239 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    filipdns
    wrote on last edited by filipdns
    #1

    Hello,

    I need to have bar graphic with X axis = year from first record to this year and Y = simulate value (Y value are for test before to have real value).

    I have ListModel below:

        function yearinterval()
        {
            //format date-> "yyyy-mm-dd"
            var firstyear= new Date(JS.dbolderflight().date_etape).getFullYear()
            var lastyear= new Date().getFullYear()
            var deltayear=parseInt(lastyear)-parseInt(firstyear)
            return {firstyear:firstyear,deltayear:deltayear}
        }
        ListModel {
            id: yearlistModel
        }
        Component.onCompleted: {
            for (var i = 0 ; i < yearinterval().deltayear+1;i+=1 ) {
                yearlistModel.append({"name": parseInt(yearinterval().firstyear)+i, "index": i})
            }
        }
    

    the "JS.dbolderflight().date_etape" is js script to get the first record date from SQLite database.

    How can I get the data from the ListModel to StringList to be able to use it on :

        Item {
            anchors.fill:parent
            ChartView {
                title: "Bar series"
                anchors.fill: parent
                //legend.alignment: Qt.AlignBottom
                antialiasing: true
    
                BarSeries {
                    id: mySeries
                    axisX: BarCategoryAxis { categories: [yearlistModel]}
                    BarSet { label: "Jours de disponibilité"; values: [2, 2, 3, 4, 5, 6] }
                    BarSet { label: "Jours de vol"; values: [5, 1, 2, 4, 1, 7] }
                    BarSet { label: "Jours de visite"; values: [3, 5, 8, 13, 5, 8] }
                    BarSet { label: "Jours de panne"; values: [10, 5, 2, 18, 1, 7] }
                }
            }
        }
    

    to have years display on X axis?

    Thank you for your help

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved