Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Graph plotting issue in QML



  • I need to plot a Spline series chart. Below is the code

    ChartView {
                                              id:graph
                                              //title: "Graph"
                                              anchors.fill: rect1
                                               antialiasing: true
    
                                               ValueAxis {            /*-----Graph X axis range-----*/
                                                   id: axisx
                                                    min: 0
                                                    max: 100
                                                    tickCount: 11
                                                    labelFormat: "%.0f"
                                               }
                                               ValueAxis {            /*-----Graph Y axis range-----*/
                                                   id: axisy
                                                    min: 0
                                                    max: 200
                                                    tickCount: 11
                                                    labelFormat: "%.0f"
                                               }
    
                                               SplineSeries {         /*-----Graph 1 values-----*/
                                                   id: grp1
                                                   axisX: axisx
                                                   axisY: axisy
                                                 
                                                   XYPoint { y: 200; x: 0 }
                                                  XYPoint { y: 180; x: 55 }
                                                   
                                               }
                                          }
    

    I have defined an array, property var ary: [0,90,65,50,75,80,25,50,70,0].

    Here in array, index is y-axis and value is the x-axis.
    Please any one help me to use "for" loop or any other solution in the code in the place of XYPoint { y: 200; x: 0 }, to plot all the array elements instead of using multiple XYPoint { y: 200; x: 0 } lines.



  • @mnhg hi

    for(var i in ary)
       grp1.append(ary[i],i)
          
    

Log in to reply