Skip to content

Commit dfcada3

Browse files
committed
imp - Added backward rendering to bar charts
--- We've added another rendering method for bar charts that allow bars to grow from right to left. --- Type: imp Breaking: False Doc Required: False Backport Required: False Part: 1/1
1 parent 636d838 commit dfcada3

File tree

1 file changed

+7
-1
lines changed
  • public/Terminaux/Writer/CyclicWriters/Graphical

1 file changed

+7
-1
lines changed

public/Terminaux/Writer/CyclicWriters/Graphical/BarChart.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public ChartElement[] Elements
6464
set => elements = value;
6565
}
6666

67+
/// <summary>
68+
/// Whether to render the bars backwards (right to left) or not (left to right)
69+
/// </summary>
70+
public bool Backwards { get; set; }
71+
6772
/// <summary>
6873
/// Renders a bar chart
6974
/// </summary>
@@ -119,8 +124,9 @@ public override string Render()
119124
// Render the element and its value
120125
Coordinate coord = new(Left + showcaseLength, Top + e);
121126
int length = (int)(value * wholeLength / maxValue);
127+
int diff = Backwards ? wholeLength - length : 0;
122128
barChart.Append(
123-
ConsolePositioning.RenderChangePosition(coord.X, coord.Y) +
129+
ConsolePositioning.RenderChangePosition(coord.X + diff, coord.Y) +
124130
(UseColors ? ColorTools.RenderSetConsoleColor(color, true) : "") +
125131
new string(' ', length) +
126132
(UseColors ? ColorTools.RenderResetBackground() : "") +

0 commit comments

Comments
 (0)