Data display in Qchart

  • In my code, I use two QLineSeries to add data to QChart, their x Axis is the 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

  • 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){
    return std::make_tuple(true,series->at(i).y());
    return std::make_tuple(false,0.0);

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

Log in to reply