Bug 457248 - System monitor pie chart scaling error with non-zero manual data range
Summary: System monitor pie chart scaling error with non-zero manual data range
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kquickcharts
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.94.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Arjen Hiemstra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-28 20:05 UTC by Roman Lebedev
Modified: 2022-08-11 23:47 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.98


Attachments
pie chart settings in system monitor (34.42 KB, image/png)
2022-07-29 10:34 UTC, Roman Lebedev
Details
sensors on system monitor (31.21 KB, image/png)
2022-07-29 10:34 UTC, Roman Lebedev
Details
idle chart (11.59 KB, image/png)
2022-07-29 10:34 UTC, Roman Lebedev
Details
chart under load (12.11 KB, image/png)
2022-07-29 10:35 UTC, Roman Lebedev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Lebedev 2022-07-28 20:05:19 UTC
1. The coordinate system is wrong. Somehow "Start from angle = -180*" results in starting from six-o-clock, which is -90* in reality: https://upload.wikimedia.org/wikipedia/commons/9/9a/Degree-Radian_Conversion.svg
2. There is some weird normalization bug. Even when the underlying data reaches the specified data range max, the pie chart is still far from being full.
Comment 1 Paul Worrall 2022-07-29 08:18:38 UTC
The scaling looks ok to me. 

What I did:
1. Add Widget => System Monitor Sensor (defaults to a pie chart)
2. Add sensor "Core 1 Total Usage"
3. Set manual data range 0 to 100%
4. Run something that uses 100% CPU (e.g. the "stress" utility)

The pie chart fills 360deg

Can you give a specific case where the scaling looks wrong?
Comment 2 Arjen Hiemstra 2022-07-29 09:39:12 UTC
(In reply to Roman Lebedev from comment #0)
> 1. The coordinate system is wrong. Somehow "Start from angle = -180*"
> results in starting from six-o-clock, which is -90* in reality:
> https://upload.wikimedia.org/wikipedia/commons/9/9a/Degree-Radian_Conversion.
> svg

Starting angle is arbitrary and there's no standard. In the case of the Quick Charts library, it follows what other chart libraries do: 0 is at the top, so -180 degrees is at the bottom.

> 2. There is some weird normalization bug. Even when the underlying data
> reaches the specified data range max, the pie chart is still far from being
> full.

Please show a code sample where this happens. If you're using automatic maximum, the data source may be providing a different maximum than what you expect.
Comment 3 Roman Lebedev 2022-07-29 10:34:20 UTC
Created attachment 150971 [details]
pie chart settings in system monitor
Comment 4 Roman Lebedev 2022-07-29 10:34:35 UTC
Created attachment 150972 [details]
sensors on system monitor
Comment 5 Roman Lebedev 2022-07-29 10:34:50 UTC
Created attachment 150973 [details]
idle chart
Comment 6 Roman Lebedev 2022-07-29 10:35:01 UTC
Created attachment 150974 [details]
chart under load
Comment 7 Roman Lebedev 2022-07-29 15:23:56 UTC
(In reply to Arjen Hiemstra from comment #2)
> (In reply to Roman Lebedev from comment #0)
> > 1. The coordinate system is wrong. Somehow "Start from angle = -180*"
> > results in starting from six-o-clock, which is -90* in reality:
> > https://upload.wikimedia.org/wikipedia/commons/9/9a/Degree-Radian_Conversion.
> > svg
> 
> Starting angle is arbitrary and there's no standard. In the case of the
> Quick Charts library, it follows what other chart libraries do: 0 is at the
> top, so -180 degrees is at the bottom.
> 
> > 2. There is some weird normalization bug. Even when the underlying data
> > reaches the specified data range max, the pie chart is still far from being
> > full.
> 
> Please show a code sample where this happens. If you're using automatic
> maximum, the data source may be providing a different maximum than what you
> expect.

I'm using pie chart in system monitor sensor, measuring cpu temperature.
Uploaded screenshots, let me know if that is not sufficient..
Comment 8 Paul Worrall 2022-07-29 17:26:49 UTC
I can reproduce the scaling error, it occurs when using a manual data range with a non-zero "From" value:

Using a "CPU Total Usage" sensor:

1. If the data range is set to "From: 0%" & "To: 100%", then 100% CPU is full scale as expected
2. If the data range is set to "From: 20%" & "To: 100%", then 100% CPU is only about 3/4 full scale
Comment 9 Roman Lebedev 2022-08-10 20:37:32 UTC
https://invent.kde.org/frameworks/kquickcharts/-/merge_requests/46
I haven't touched multi-item source handling, i don't really understand how it's supposed to behave,
and i think it might not be handled correctly.
Comment 10 Nate Graham 2022-08-11 23:47:03 UTC
Fixed by Roman Lebedev with https://invent.kde.org/frameworks/kquickcharts/-/commit/7d72fc0e9173dc95e8095c1d33ded5ca45673b90 in Frameworks 5.98!