简体   繁体   中英

QtCharts - How to set fixed Y axis scale?

I am using Qt Framework (C++) to create a bar chart of percentages. How to make make the Y-axis that shows percentages always remain at 100% even if none of the values are near 100%?

In this picture, the maximum percentage of an instance is only 60 and hence the Y-axis shows only until 60. It does not show until 100.

In this picture, the maximum percentage is only 80 and so the Y-axis shows only until 80.

How to make the chart show a scale of 100 in the Y-axis all the time?

Okay, I was setting the range as (100,100) instead of (0,100). The correct code is: axisY->setRange(0,100);

I also added axisY->applyNiceNumbers(); and agamAxisY->setTickCount(10); so that the graph is beautifully incremented by 10 percentage points from 0-100.

Hope this helps someone out there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM