Search

Dark theme | Light theme
Showing posts with label GroovyGoodness:CLI. Show all posts
Showing posts with label GroovyGoodness:CLI. Show all posts

September 1, 2025

Groovy Goodness: Create Ascii Bar Charts

Groovy 5 adds a new utility method to create an ascii bar chart. You can use the bar method in the org.codehaus.groovy.util.StringUtil class. You can pass a value, a minimum and maximum value and optinally specify the width of the bar chart. The result is a String value consisting of a number of "blocks". A block could be whole, but also 1/8 eights of the block are used to get a nice looking bar chart. How many of these values are needed is based on the input arguments. With this method you have a nice way to format number values on a command-line.