-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGoG-Parser.js
105 lines (101 loc) · 2.62 KB
/
GoG-Parser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//specification = {
// "id" : "canvas_1"
// "width": 600,
// "height": 600,
// "margin" : 35,
// "background": "transparent",
// "data": [
// {
// "name": "static",
// "values": [
// {"x": 10, "y": 20},
// {"x": 30, "y": 20},
// {"x": 40, "y": 10},
// {"x": 20, "y": 30},
// {"x": 20, "y": 50},
// {"x": 5, "y": 60}
// ]
//
// }, {
// "name": "fromUrl",
// "url": "test.csv",
// "format": "csv"
// }
// ],
// "transform": [
// {
// "name": "log_x", // new variable name
// "function": "log", // function name
// "data": "static", // data source
// "field": "x" // column name
// }
// ],
// "scales": [
// {
// "name": "xscale", // scale name
// "type": "linear", // scale type
// "range": "width", // chart width
// "domain": {
// "data": "static",
// "field": "x"
// }
// },
// {
// "name": "yscale", //scale name
// "type": "linear", // scale type
// "range": "height", // chart height
// "domain": {
// "data": "static", // data source
// "field": "y" // data field
// }
// }
// ],
// "axes": [
// {
// "type": "x", // x axis
// "scale": "xscale"// scale for axis
// },
// {
// "type": "y", // y axis
// "scale": "yscale"// scale for axis
// }
// ]
//
//};
var lib = {};;
var GoG_Parser;
GoG_Parser = function(obj) {
var key, value;
lib.GoG_JSON = {};
lib.Canvas_JSON = {};
/* if(obj.id==""){
can=document.createElement("canvas");
can.id="dcan";
obj.id=can.id;
} */
lib.Canvas_JSON.id =obj.id;
lib.Canvas_JSON.Background = obj.background;
lib.GoG_JSON.width = obj.width;
lib.GoG_JSON.height = obj.height;
if (obj.margin == ""){
obj.margin=60;
}
lib.GoG_JSON.margin = obj.margin;
lib.data = new Data();
lib.transform = new Transform();
lib.scales = new Scale();
lib.axes = new axes();
lib.geom = new Geom();
lib.define = new Define();
lib.guides=new guides();
for (key in obj) {
value = obj[key];
if (key === "width" || key === "height" || key === "margin" || key === "background" || key === "id") {
continue;
} else {
lib[key]["process"](value);
}
}
return Canvas_Parse(lib.Canvas_JSON);
};
//# sourceMappingURL=GoG-Parser.js.map