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:

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

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:

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

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:

{
  "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"
}

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