1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

Merge pull request from Laserlicht/fix_chart

avoid zero size Y axis
This commit is contained in:
Ivan Savenko 2024-08-28 13:59:30 +03:00 committed by GitHub
commit 536134d396
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -472,6 +472,7 @@ LineChart::LineChart(Rect position, std::string title, TData data, TIcons icons,
int gridLineCount = 10;
int gridStep = computeGridStep(maxVal, gridLineCount);
niceMaxVal = gridStep * std::ceil(maxVal / gridStep);
niceMaxVal = std::max(1, niceMaxVal); // avoid zero size Y axis (if all values are 0)
// calculate points in chart
auto getPoint = [this](int i, std::vector<float> data){