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. ChartView with multiple selectable LineSeries
Forum Updated to NodeBB v4.3 + New Features

ChartView with multiple selectable LineSeries

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 410 Views
  • 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.
  • A Offline
    A Offline
    Andresfe
    wrote on last edited by
    #1

    Hello everyone,

    I have a multiple series of data with 4 channels each which I want to plot using QML. A quick example of the data structure:

    "Raw Signal" :
    Channel 1 : [data]
    Channel 2 : [data]
    Channel 3 : [data]
    Channel 4 : [data]

    "Filtered Signal" :
    Channel 1 : [data]
    Channel 2 : [data]
    Channel 3 : [data]
    Channel 4 : [data]

    I want to be able to select one of the signals and either plot the 4 channels at the same time or in 4 different plots.
    The way I approached the problem was by creating a QAbstractListModel containing QAbstractTables where each table corresponds to one of the signals ("Raw Signal", "Filtered Signal").

    For plotting I wrote the following code

            StackLayout {
                id: graphsStackLayout
                Layout.fillHeight:true
                currentIndex: keysComboBox.currentIndex
                Repeater {
                    model: liveSignalsModel
                    ColumnLayout {
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        RowLayout {
                            Label {
                                Layout.preferredWidth: root.topLabelsWidth
                                text: "Channel:"
                            }
                            
                            ComboBox {
                                id: channelsComboBox
                                model: channels
                            }
                        }
                        
                        ChartView {
                            id: chartView
                            Layout.fillWidth: true
                            Layout.fillHeight: true
                            antialiasing: true
    
                            LineSeries {
                                id: line
                                name: key
                                useOpenGL: true
                                axisX: ValueAxis {
                                    min: value.xAxisData["start"]
                                    max: value.sampleCount * value.xAxisData["dx"]
                                    titleText: value.xAxisData["xLabel"] 
                                }
                                axisY: ValueAxis {
                                    min: value.minY
                                    max: value.maxY
                                    titleText: "[" + unit + "]"
                                }
                            }
    
                            HXYModelMapper {
                                id: mapper
                                model: value
                                xRow: 0
                                yRow: channelsComboBox.currentIndex + 1
                                series: line
                            }
                        }
                    }
                }
            }
    

    Where liveSignalsModel is the QAbstractListModel and keysComboBox is ComboBox that I use for selecting the signal. However this approach hoags almost all my pc resources. Creating multiple ChartViews is probably not efficient at all. Is there any other way to access the table models in the list model ? Or any better approach for my goal?

    Thank you all

    PS: I am using PySide2/QML

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Toan Vo Khanh Nguyen
      wrote on last edited by
      #2

      Hello,
      Sorry I could not answer your question! But btw,
      I new to PySide and QML, could you share me how to visible LineSeries to the chart, when I set 'useOpenGL: true', it could not render to GUI. Could you share me your code above?

      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