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. Cant assign axisYRight to LineSeries created at runtime
Qt 6.11 is out! See what's new in the release blog

Cant assign axisYRight to LineSeries created at runtime

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 430 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.
  • F Offline
    F Offline
    FrecciaGLT
    wrote on last edited by
    #1

    Hello everyone,
    I am working on an application that creates LineSeries at runtime.
    The problem I am having is that I need two y-Axis, meaning that one has to be an axisYRight.
    When dynamically creating the LineSeries I cant assign one of the y-Axis as an axisYRight, trying to assign the axis afterwards does nothing.
    I have tried getting around the problem by already having a LineSeries with the correct axis in the View and setting the unwanted axis to invisible but
    this leads to the LineSeries accepting a completely different and wrong scaling or that LineSeries not showing up at all.

    Is there a way to correctly implement this?
    The following code illustrates the issue.

    ChartView 
    {
      id: linechart;
      anchors.fill: parent;
    
      property var updateChart: chartContext.updateChart;
    
      title: chartContext.chartTitle;
      antialiasing: true;
    
      ValueAxis {
          id: xAxis;
          min: chartContext.minXAxis;
          max: chartContext.maxXAxis;           
      }
      ValueAxis {
          id: yAxis;
          min: chartContext.minYAxis;
          max: chartContext.maxYAxis;
      }
      ValueAxis {
          id: yAxis2;
          min: chartContext.minYAxis2;
          max: chartContext.maxYAxis2;
      }
    
      onUpdateChartChanged: {
          linechart.removeAllSeries();
    
          for (var i = 0; i < dataModel.numberOfSeries; ++i) {          
              var lineSeries;
              if (dataModel.axisLocation(i) == "Right") {
                  lineSeries = linechart.createSeries(ChartView.SeriesTypeLine, dataModel.getYLabel(i), xAxis);
                  lineSeries.axisYRight = yAxis2;
              }
              else {
                  lineSeries = linechart.createSeries(ChartView.SeriesTypeLine, dataModel.getYLabel(i), xAxis, yAxis);
              }         
          }
      }
    }
    

    Code example taken from: https://stackoverflow.com/q/43543560

    Thanks 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