@@ -13,15 +13,45 @@ WOQLChartConfig.prototype.constructor = Config.ViewConfig;
1313
1414WOQLChartConfig . prototype . prettyPrint = function ( ) {
1515 var str = "view = View.chart();\n" ;
16- str += this . getBasicPrettyPrint ( ) ;
17- for ( var i = 0 ; i < this . rules . length ; i ++ ) {
16+ for ( var i = 0 ; i < this . rules . length ; i ++ ) {
1817 str += "view." + this . rules [ i ] . prettyPrint ( ) + "\n" ;
1918 }
19+ if ( typeof this . margin ( ) != "undefined" ) {
20+ str += "view.margin(" + this . margin ( ) + ")\n" ;
21+ }
22+ if ( typeof this . title ( ) != "undefined" ) {
23+ str += "view.title('" + this . title ( ) + "')\n" ;
24+ }
25+ if ( typeof this . description ( ) != "undefined" ) {
26+ str += "view.description('" + this . description ( ) + "')\n" ;
27+ }
28+ if ( typeof this . layout ( ) != "undefined" ) {
29+ str += "view.layout('" + this . layout ( ) + "')\n" ;
30+ }
31+
32+ str += this . getBasicPrettyPrint ( ) ;
2033 return str ;
2134}
2235
2336WOQLChartConfig . prototype . json = function ( ) {
24- let mj = { "chart" :this . getBasicJSON ( ) , "rules" : this . getRulesJSON ( ) } ;
37+ /*
38+ *general properties
39+ */
40+ var conf = { } ;
41+ if ( typeof this . margin ( ) != "undefined" ) {
42+ conf [ 'margin' ] = this . margin ( ) ;
43+ }
44+ if ( typeof this . title ( ) != "undefined" ) {
45+ conf [ 'title' ] = this . title ( ) ;
46+ }
47+ if ( typeof this . description ( ) != "undefined" ) {
48+ conf [ 'description' ] = this . description ( ) ;
49+ }
50+ if ( typeof this . layout ( ) != "undefined" ) {
51+ conf [ 'layout' ] = this . layout ( ) ;
52+ }
53+
54+ let mj = { "chart" :conf , "rules" : this . getRulesJSON ( ) } ;
2555 return mj ;
2656}
2757
@@ -34,8 +64,57 @@ WOQLChartConfig.prototype.loadJSON = function(config, rules){
3464 jr . push ( nr ) ;
3565 }
3666 this . rules = jr ;
67+ if ( typeof config . margin != "undefined" ) {
68+ this . margin ( config . margin ) ;
69+ }
70+ if ( typeof config . title != "undefined" ) {
71+ this . title ( config . title ) ;
72+ }
73+ if ( typeof config . description != "undefined" ) {
74+ this . description ( config . description ) ;
75+ }
76+ if ( typeof config . layout != "undefined" ) {
77+ this . layout ( config . layout ) ;
78+ }
79+ }
80+
81+ WOQLChartConfig . prototype . title = function ( title ) {
82+ if ( typeof title == "undefined" ) {
83+ return this . _title ;
84+ }
85+ this . _title = title ;
86+ return this ;
87+ }
88+
89+ WOQLChartConfig . prototype . description = function ( description ) {
90+ if ( description ) {
91+ this . _description = description ;
92+ return this
93+ }
94+ return this . _description ;
95+ }
96+
97+ //layout "vertical" | "horizontal"
98+ WOQLChartConfig . prototype . layout = function ( layout ) {
99+ if ( layout ) {
100+ this . _layout = layout ;
101+ return this
102+ }
103+ return this . _layout ;
104+ }
105+
106+
107+ //default is { top: 10, right: 30, left: 0, bottom: 0 }
108+ WOQLChartConfig . prototype . margin = function ( marginObj ) {
109+ if ( marginObj ) {
110+ this . _margin = marginObj ;
111+ return this
112+ }
113+
114+ return this . _margin ;
37115}
38116
117+
39118WOQLChartConfig . prototype . create = function ( client ) {
40119 var wqt = new WOQLChartConfig ( client , this ) ;
41120 return wqt ;
@@ -122,6 +201,19 @@ WOQLChartRule.prototype.label = function(label){
122201 return this . rule . label ;
123202}
124203
204+ /*
205+ *line is the default value
206+ * 'line' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | 'none'
207+ */
208+
209+ WOQLChartRule . prototype . legendType = function ( legendType ) {
210+ if ( legendType ) {
211+ this . rule . legendType = legendType ;
212+ return this ;
213+ }
214+ return this . rule . legendType ;
215+ }
216+
125217
126218WOQLChartRule . prototype . fill = function ( color ) {
127219 if ( color ) {
0 commit comments