Chart height was changed automatically when did attach multiple axis.



  • Hello,

    I'm trying make multi chart.
    To start with, I changed the following example chart.

    http://doc.qt.io/QtCharts/qtcharts-multiaxis-main-cpp.html

    int main(int argc, char *argv[])
    {
        ...
        QCategoryAxis *axisY3 = new QCategoryAxis;
        axisY3->append("Low", 5);
        axisY3->append("Medium", 12);
        axisY3->append("High", 17);
        axisY3->setLinePenColor(series->pen().color());
        axisY3->setGridLinePen((series->pen()));
    
        chart->addAxis(axisY3, Qt::AlignRight);
        series->attachAxis(axisX);
        series->attachAxis(axisY3);
        
        //Added code
        series = new QSplineSeries;
        chart->addSeries(series);
        QValueAxis *axisY4 = new QValueAxis;
        axisY4->setLinePenColor(series->pen().color());
        chart->addAxis(axisY4, Qt::AlignLeft);
        series->attachAxis(axisX);
        series->attachAxis(axisY4);
        ...
        Add to axis the axis10 from axis5.
        ...
        series = new QSplineSeries;
        chart->addSeries(series);
        QValueAxis *axisY11 = new QValueAxis;
        axisY11->setLinePenColor(series->pen().color());
        chart->addAxis(axisY11, Qt::AlignLeft);
        series->attachAxis(axisX);
        series->attachAxis(axisY11);
        //Added code
    
        QChartView *chartView = new QChartView(chart);
        chartView->setRenderHint(QPainter::Antialiasing);
    
        QMainWindow window;
        window.setCentralWidget(chartView);
        window.resize(800, 600);
        window.show();
    
        return a.exec();
    }
    

    As a result, chart height was changed automatically.
    I know that, can adjust chart height by call the "chart->setMaximumHeight(500)".
    I made the Dynamic multi-scroll chart(using the setMaximumHeight()).But, chart height was changed automatically when chart was scrolled.

    Please teach me the proper way to set the height of the chart .


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.