简体   繁体   English

QtCharts - 如何设置固定的 Y 轴刻度?

[英]QtCharts - How to set fixed Y axis scale?

I am using Qt Framework (C++) to create a bar chart of percentages.我正在使用 Qt 框架 (C++) 创建百分比条形图。 How to make make the Y-axis that shows percentages always remain at 100% even if none of the values are near 100%?即使没有一个值接近 100%,如何使显示百分比的 Y 轴始终保持在 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.在这张图片中,实例的最大百分比仅为 60,因此 Y 轴仅显示到 60。直到 100 才显示。

In this picture, the maximum percentage is only 80 and so the Y-axis shows only until 80.在这张图片中,最大百分比只有 80,所以 Y 轴只显示到 80。

How to make the chart show a scale of 100 in the Y-axis all the time?如何让图表在 Y 轴上一直显示 100 的刻度?

Okay, I was setting the range as (100,100) instead of (0,100).好的,我将范围设置为 (100,100) 而不是 (0,100)。 The correct code is: axisY->setRange(0,100);正确的代码是: axisY->setRange(0,100);

I also added axisY->applyNiceNumbers();我还添加了axisY->applyNiceNumbers(); and agamAxisY->setTickCount(10);agamAxisY->setTickCount(10); so that the graph is beautifully incremented by 10 percentage points from 0-100.这样图表就可以从 0-100 漂亮地增加 10 个百分点。

Hope this helps someone out there.希望这可以帮助那里的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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