You can generate simple bar charts directly from a MySQL prompt that look like this...

+-------+-----------------------+-----------------------------------------------+
| Month | Uptime                | Latency                                       |
+-------+-----------------------+-----------------------------------------------+
| Jan   | %%%%%%%%%%%%%%%%%%%%% | ####################                          |
| Feb   | %%%%%%%%%%%%%%%%%%%   | ##############################                |
| Mar   | %%%%%%%%%%%%%%%%%%%%  | #########################################     |
| Apr   | %%%%%%%%%%%%%%%%%%%%% | #####################                         |
| May   | %%%%%%%%%%%%%%%%%%%%% | ###############                               |
| Jun   | %%%%%%%%%%%%%%%%%%    | ############################################# |
| Jul   | %%%%%%%%%%%%%%%%%%%%% | ################################              |
| Aug   | %%%%%%%%%%%%%%%%%%%%% | ##############################                |
| Sep   | %%%%%%%%%%%%%%%%%%%%% | ###############                               |
| Oct   | %%%%%%%%%%%%%%%%%%    | ####################################          |
| Nov   | %%%%%%%%%%%%%%%%%%%%  | ##########################                    |
| Dec   | %%%%%%%%%%%%%%%%%%%%% | #################                             |
+-------+-----------------------+-----------------------------------------------+

To generate this type of output, you can execute the following commands to generate the sample data and to execute the SELECT that generates the bar chart itself…

CREATE TABLE TrendicsWebsiteCheckResults (
	Month VARCHAR(3) NOT NULL,
	Uptime FLOAT NOT NULL,
	Latency FLOAT NOT NULL
);
INSERT INTO TrendicsWebsiteCheckResults VALUES ('Jan', 100.0, 97.5),
('Feb', 92.3, 145.7),('Mar', 95.6, 201.1), ('Apr', 100.0, 101.3),
('May', 100.0, 72.0), ('Jun', 87.5, 221.0), ('Jul', 98.6, 152.7),
('Aug', 100.0, 144.8), ('Sep', 100.0, 68.8), ('Oct', 87.5, 177.2),
('Nov', 95.6, 123.4), ('Dec', 100.0, 77.9);

SELECT Month,
REPEAT("%", (Uptime-0.0)*0.2+1) Uptime,
REPEAT("#", (Latency-0.0)*0.2+1) Latency
FROM TrendicsWebsiteCheckResults;

Within the REPEAT() function, use whatever character you like for your bar chart and adjust the constants to scale each bar chart appropriately. This is a super simple way to quickly chart out data from a MySQL prompt.

Bookmark at:
StumbleUpon | Digg | Del.icio.us | Dzone | Newsvine | Spurl | Simpy | Furl | Reddit | Yahoo! MyWeb
2 Responses to “MySQL Prompt Bar Charts”
  1. ultra cool tip!!

  2. Very nice trick :)

Leave a Reply