charting_routines
SYNOPSIS
Charting routines: quick, poor man's charting of one's data
- line_chart(): Generate an ASCII multi-line chart based on an arbitrary query.
- google_line_chart(): Generate a Google Image multi-line chart URL based on an arbitrary query.
EXAMPLES
Generate a 2 line sample chart:
mysql> call line_chart("select n, log(n), sin(n/5)+2 from numbers where n > 0 order by n limit 80", "log n, 2 + sin n/5");
+---------+----------------------------------------------------------------------------------+
| y_scale | common_schema_chart |
+---------+----------------------------------------------------------------------------------+
| 4.38 | ---------------------------------------------------------------------########### |
| 4.11 | -----------------------------------------------------################----------- |
| 3.83 | ----------------------------------------#############--------------------------- |
| 3.56 | ------------------------------##########---------------------------------------- |
| 3.29 | -----------------------#######-------------------------------------------------- |
| 3.01 | -----*****-------######-------------*****---------------------------*****------- |
| 2.74 | ---**-----**-####-----------------**-----**-----------------------**-----**----- |
| 2.46 | -**-------##**-------------------*---------**-------------------**---------*---- |
| 2.19 | *------###----*----------------**------------*-----------------*------------**-- |
| 1.92 | -----##--------*--------------*---------------**-------------**---------------*- |
| 1.64 | ----#-----------**----------**------------------*-----------*------------------* |
| 1.37 | ---#--------------**-------*---------------------**-------**-------------------- |
| 1.10 | --#-----------------*******------------------------*******---------------------- |
| 0.82 | -#------------------------------------------------------------------------------ |
| 0.55 | -------------------------------------------------------------------------------- |
| 0.27 | -------------------------------------------------------------------------------- |
| 0.00 | #------------------------------------------------------------------------------- |
| | v::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::v |
| | 1 80 |
| | # log n |
| | * 2 + sin n/5 |
+---------+----------------------------------------------------------------------------------+
Generate a 2 line sample chart in google image chart URL format:
mysql> call google_line_chart("select n, log(n), sin(n/5)+2 from numbers where n > 0 order by n limit 80", "log n, 2 + sin n/5") \G
*************************** 1. row ***************************
google_chart_url: http://chart.apis.google.com/chart?cht=lc&chs=800x350&chtt=SQL+chart+by+common_schema&chxt=x,y&chxr=1,0.0,4.4&chd=s:AKPTWZbdfghjklmnnopqqrssttuuvvwwxxxyyzzz0001112222333444455555666677777888888999,fhkmopqqponljhebYWTRQPOOOQRTVYbdgjlnopqqpomkifcZXUSQPOOOPQSUXacfikmopqqponljgdbY&chxs=0,505050,10,0,lt&chxl=0:|1|||||||||||||||||||20||||||||||||||||||||40||||||||||||||||||||60||||||||||||||||||||80&chg=1.265822784,25,1,2,0,0&chco=ff8c00,4682b4&chdl=log n|2 + sin n/5&chdlp=b