Coffee Space


Listen:

Grapher

NOTE: Depreciated code.

The idea here is to make an extremely simple graphing tool that is quickly run on most browsers. This takes advantage of HTML5 and may not be supported everywhere hence the format should be as fail safe as possible.

{ “x” : [ “-5”, “-4”, “-3”, “-2”, “-1”, “0”, “1”, “2”, “3”, “4”, “5” ], “y” : [ “-5”, “-4”, “-3”, “-2”, “-1”, “0”, “1”, “2”, “3”, “4”, “5” ] }

Requirements

The result

The code:

0001 {
0002   "x" : [
0003     "1", "2", "4", "5", "6", "7", "8", "9", "10"
0004   ],
0005   "y" : [
0006     "2", "3", "7", "11", "13", "17", "19", "23", "27"
0007   ],
0008   "join" : "true"
0009 }

Is translated to (browser permitting):

{ “x” : [ “1”, “2”, “4”, “5”, “6”, “7”, “8”, “9”, “10” ], “y” : [ “2”, “3”, “7”, “11”, “13”, “17”, “19”, “23”, “27” ], “join” : “true” }

Note how it skipped the missing element and it’s joined.

Another example would be using words:

0010 {
0011   "x" : [
0012     "Dog", "Cat", "Mouse", "Cheetah", "Wolf"
0013   ],
0014   "y" : [
0015     "23", "18", "7", "47", "48"
0016   ],
0017   "bold" : "true"
0018 }

Is translated to (browser permitting) in bold:

{ “x” : [ “Dog”, “Cat”, “Mouse”, “Cheetah”, “Wolf” ], “y” : [ “23”, “18”, “7”, “47”, “48” ], “bold” : “true” }

And lastly, large amounts of data:

0019 {
0020   "x" : [
0021     "183", "-980", "204", "322", "-530", "335", "691", "-216", "879", "648", "-602", "-737", "607", "-571", "225", "72", "744", "-518"
0022   ],
0023   "y" : [
0024     "648", "-602", "-737", "607", "571", "-225", "72", "-744", "-518", "-183", "980", "204", "322", "530", "-335", "-691", "-216", "-879"
0025   ],
0026   "display-text" : "false",
0027   "width" : "250",
0028   "height" : "200",
0029   "title" : "Random Numbers"
0030 }

Is translated to (browser permitting) without text and half the size:

{ “x” : [ “183”, “-980”, “204”, “322”, “-530”, “335”, “691”, “-216”, “879”, “648”, “-602”, “-737”, “607”, “-571”, “225”, “72”, “744”, “-518” ], “y” : [ “648”, “-602”, “-737”, “607”, “571”, “-225”, “72”, “-744”, “-518”, “-183”, “980”, “204”, “322”, “530”, “-335”, “-691”, “-216”, “-879” ], “display-text” : “false”, “width” : “250”, “height” : “200”, “title” : “Random Numbers” }

Functions