Skip to content

Conversation

@Explorer09
Copy link
Contributor

@Explorer09 Explorer09 commented Mar 17, 2024

This pull request implements the "two-channel" graph style as the new "Graph2" meter mode. This is based on #714 so that the graphs will be shown with colors.

This new mode is designed for a few meters only— only DiskIORateMeter (#1763) and NetworkIOMeter can correctly utilise this mode by showing the input and output rates as separate channels.

The feature was previously discussed in #1390.

Below is a preview screenshot taken in macOS Sequoia.
I included both Unicode mode and --no-unicode mode.
htop-screenshot-graph2-meter-mode

@Explorer09 Explorer09 force-pushed the graph-with-neg branch 3 times, most recently from f47a975 to 745f394 Compare March 28, 2024 13:54
@BenBE BenBE added the new feature Completely new feature label Apr 13, 2024
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 3 times, most recently from 31cb513 to bedca8f Compare April 21, 2024 06:39
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 4 times, most recently from ade4922 to 54d3d1c Compare April 26, 2024 18:59
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 3 times, most recently from 728ef87 to 3033b1d Compare May 2, 2024 21:01
@BenBE BenBE self-assigned this May 2, 2024
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 2 times, most recently from aa96aa4 to 10bb617 Compare May 22, 2024 19:03
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 2 times, most recently from f57affb to 5e3eeb1 Compare August 25, 2024 23:10
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 2 times, most recently from b5560f5 to 8a8cfda Compare December 16, 2024 09:53
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 3 times, most recently from c7c11bc to b446269 Compare February 9, 2025 18:16
@BenBE BenBE linked an issue May 15, 2025 that may be closed by this pull request
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 3 times, most recently from b9b525e to d1623cd Compare August 3, 2025 20:51
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 2 times, most recently from 2a785b5 to 19a9056 Compare August 10, 2025 18:58
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 2 times, most recently from 8b55f27 to 200df88 Compare August 18, 2025 23:58
@Explorer09 Explorer09 changed the title "Positive/negative" graph meter style Two-channel graph (Graph2) meter style Sep 4, 2025
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 2 times, most recently from beb5b3a to 983b642 Compare September 13, 2025 09:38
@Explorer09 Explorer09 marked this pull request as ready for review September 13, 2025 12:32
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 2 times, most recently from f197d8a to 2bf8ae1 Compare September 27, 2025 09:40
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 3 times, most recently from 606ea67 to dd3e180 Compare October 15, 2025 06:50
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 3 times, most recently from c275287 to f910395 Compare October 28, 2025 12:33
Round the graph meter's dynamic scale to a power of two and print the
graph scale. For a percent graph, a "%" character is printed in place
of the scale.

Signed-off-by: Kang-Che Sung <[email protected]>
This is a prerequisite for the feature "Graph meter coloring (with
GraphData structure rework)".

powerOf2Floor() will utilize __builtin_clz() or stdc_bit_floor_ui()
(__builtin_clz() is preferred) if either is supported.

popCount8() will utilize ARM NEON instructions and x86 POPCNT
instruction if the machine supports either of them.

I am not adopting the C23 standard interface stdc_count_ones_uc() yet,
as I am not sure C libraries would implement it as fast as our version.

Signed-off-by: Kang-Che Sung <[email protected]>
Rewrite the entire graph meter drawing code to support color graph
drawing in addition to the dynamic scaling (both can work together
because of the new GraphData structure design).

The colors of a graph are based on the percentages of item values of
the meter. The rounding differences of each terminal character are
addressed through the different numbers of braille dots.

Due to low resolution of the character terminal, the rasterized colors
may not look nice, but better than nothing. :)

The new GraphData structure design has two technical limitations:
* The height of a graph meter now has a limit of 8191 (terminal rows).
* If dynamic scaling is used, the "total" value or scale of a graph now
  has to align to a power of 2.

The code is designed with the anticipation that the graph height may
change at runtime. No UI or option has been implemented for that yet.

Signed-off-by: Kang-Che Sung <[email protected]>
Specifically 'PIXPERROW_*' and 'GraphMeterMode_dots*' constants.
They were commented out rather than removed in the previous commit (for
ease of code reviewing). Now this commit removes the constant defines
for good.
Introduce a new meter mode (meter style) called "Graph2". The "Graph2"
name stands for "two-channel graph" or "two-quadrant graph".

This meter mode is not in the list of default supported modes. This
"Graph2" mode is intended for meters with two item values. It plots
the first item above the x-axis and the second item below the x-axis.
Items other than the first two are always hidden.

This code is written with the intention to share as much code with the
Graph meter mode as possible.

Signed-off-by: Kang-Che Sung <[email protected]>
This special case of "details" value would print as ':' in the ASCII
display mode. It is used in "Graph2" meter drawing only.

Signed-off-by: Kang-Che Sung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Completely new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Graph meter style with negative values

2 participants