Skip to content

GoG Lib technical documentation

AESN edited this page Jun 21, 2017 · 9 revisions

Home > Technical Documentation

The technical documentation reflects the GoG Lib architecture, each Json should include the following:

##1. Mandartory configurations

key required description
id yes Canvas id where the graphic appears
width yes numeric value represents canvas width
height yes numeric value represents canvas height
margin yes numeric value represents canvas margin

##2. data

We believe that tabular data is easier to manipulate, GoG Lib loads data into javascript objects where each object is a single observation. Data sets can be specified directly (either through including the data inline or providing a URL from which to load the data), or bound dynamically at runtime (by providing data at chart instantiation time). Note that loading data from a URL will be subject to the policies of your runtime environment (e.g., cross-domain request rules).

Examples

  1. Loading static data:
  {
        "name": "table",
        "values": [
          {"x": 1,"y": 28},
          {"x": 2,"y": 55},
          {"x": 3,"y": 43},
          {"x": 4,"y": 91},
          {"x": 5,"y": 81},
          {"x": 6,"y": 53},
          {"x": 7,"y": 19}
          ]
  }

where name is the dataset name which should be unique.

  1. Loading data from a file:
  {
        "name": "table2",
        "values" : "filename.csv",
        "format" : {
             "type" : "csv",
             "parse": {
                "field_name" : "date"
             }
        }
  }

you can load .csv, .json and .tsv files. parse object defines how you would like to parse the fields, supported options are: "date", "boolean", "number". default option is "auto".

##3. transform

Apply statistics and transformation on columns of data has never been easier, define your own statistical method or use pre defined method using JavaScript or R thanks to opencpu

Example

  1. Working with JavaScript statistical methods:
            {
                "function": "power",
                "properties": {
                    "data": "dataName",
                    "field": "x",
                    "power" : "3",
                    "name" : "dataName_power"
                }
            }

Where function represents statistical function name to be called. properties object includes data which is the data name to apply method on, field data column as input to statistical function and name is the new column created as an output. To know more about built in methods and how to define new ones please refer to Up and Running with transformers

  1. Working with R statistical methods:
            {
                "lang": "R",
                "function": "lowess",
                "properties": {
                    "data": "iris",
                    "library" : "stats",
                    "field": "x",
                    "name": "lowess_x"
                }
            }

where lang specifies the statistical function platform, function represents function name to be called. properties object includes data which is the data name to apply method on, field data column as input to statistical function and name is the new column created as an output. please refer to Up and Running with transformers for more details.

##4. scale

we use d3 for scaling data.

Key description
name a string value represents scale name
type a string value represents scale type. example "linear", "log", "category10".
range a string value equals "width" or "height". can use an array as a range, example [2,5] where 2 is minmum value and 5 is the maximum value
domain an object includes 2 keys "data" key which is a string defines dataset name, "field" a string value represents the value to be scaled

For more information about scales and how d3 scales works please refer to d3-scale

Clone this wiki locally