Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Data display in Qchart

Data display in Qchart

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.1k 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.
  • S Offline
    S Offline
    sildtfine
    wrote on last edited by
    #1

    In my code, I use two QLineSeries to add data to QChart, their x Axis is the same.it is a DateTimeAxis,but Y Axis is different, then I want to show two series's values at the same time point.I found there is no such a function could do it,Anyone has good ideal?
    for exmaple ,when I clicked on a series, I can get the value of this point in the serie,but how can I get another value of different serie which has the same DateTimeAxis.
    In the PIC,I want to know two values of different series in the red line.
    alt text

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Once you have the X of one series you can iterate all values of the other values and search for the x and retrieve the Y:

      std::tuple<bool,qreal> getYforX(const QXYSeries* const series, qreal xPoint){
      for(int i=0;i<series->count();++i){
      if(series->at(i).x()==xPoint)
      return std::make_tuple(true,series->at(i).y());
      }
      return std::make_tuple(false,0.0);
      }
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • S Offline
        S Offline
        sildtfine
        wrote on last edited by
        #3

        Thank you! it works.I'm just curious that there are no ready-made functions

        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