Skip to content

Commit f597ad8

Browse files
committed
change chartConfig
1 parent efdefc0 commit f597ad8

File tree

1 file changed

+83
-1
lines changed

1 file changed

+83
-1
lines changed

lib/viewer/chartConfig.js

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ WOQLChartConfig.prototype.xAxis = function(...vars){
146146
return woqlRule;
147147
}
148148

149+
WOQLChartConfig.prototype.legend = function(...vars){
150+
let woqlRule = new WOQLChartRule().scope("Legend");
151+
woqlRule.setVariables(vars);
152+
this.rules.push(woqlRule);
153+
return woqlRule;
154+
}
155+
149156
WOQLChartConfig.prototype.yAxis = function(...vars){
150157
let woqlRule = new WOQLChartRule().scope("YAxis");
151158
woqlRule.setVariables(vars);
@@ -287,10 +294,47 @@ WOQLChartRule.prototype.padding=function(paddingObj){
287294
}
288295

289296
/*
290-
* The type of xAxis or yAxis 'number' | 'category' default is 'category'.
297+
*
298+
*/
299+
300+
WOQLChartRule.prototype.labelDateInput=function(labelDateInput){
301+
if(labelDateInput){
302+
this.rule.labelDateInput=labelDateInput
303+
return this;
304+
}
305+
return this.rule.labelDateInput
306+
}
307+
308+
/*
309+
* output date example 'YYYY-MM-DD' : 2020:03:11 or ''YYYY [text] YYYY', 2020 mytext 2020'
310+
*/
311+
312+
WOQLChartRule.prototype.labelDateOutput=function(labelDateOutput){
313+
if(labelDateOutput){
314+
this.rule.labelDateOutput=labelDateOutput
315+
return this;
316+
}
317+
return this.rule.labelDateOutput
318+
}
319+
320+
WOQLChartRule.prototype.stackId=function(stackId){
321+
if(stackId){
322+
this.rule.stackId=stackId
323+
return this;
324+
}
325+
return this.rule.stackId
326+
}
327+
328+
329+
330+
/*
331+
* The type of xAxis 'number' | 'category' default is 'category'
332+
* The type of yAxis 'number' | 'category' default is 'number'
291333
* The type of line chart 'basis'|'basisClosed'|'basisOpen'|'linear'|'linearClosed'|'natural'|'monotoneX'|'monotoneY'|'monotone' | 'step' | 'stepBefore' | 'stepAfter' |
292334
*/
293335

336+
337+
294338
WOQLChartRule.prototype.type=function(type){
295339
if(type){
296340
this.rule.type=type
@@ -310,6 +354,44 @@ WOQLChartRule.prototype.axisDomain=function(domainArr){
310354
return this.rule.domain
311355
}
312356

357+
/*
358+
*
359+
* @param {string} name of the variable for the custom color
360+
*/
361+
362+
WOQLChartRule.prototype.colorEntry=function(propValue){
363+
if(propValue){
364+
this.rule.colorEntry=propValue
365+
return this;
366+
}
367+
return this.rule.colorEntry
368+
}
369+
370+
/*
371+
*
372+
* @param {object} an object of possible value and color {"value1":"#ff0000"...}
373+
*/
374+
375+
WOQLChartRule.prototype.customColors=function(colorsObj){
376+
if(colorsObj){
377+
this.rule.customColors=colorsObj
378+
return this;
379+
}
380+
return this.rule.customColors
381+
}
382+
383+
/*
384+
* @param {array} payload array of the object for descrive the legend [{value:"legend label",color:"#ff0000",type:"rect"}]
385+
*/
386+
387+
WOQLChartRule.prototype.payload=function(payloadArr){
388+
if(payloadArr){
389+
this.rule.payload=payloadArr
390+
return this;
391+
}
392+
return this.rule.payload
393+
}
394+
313395

314396
WOQLChartRule.prototype.barSize=function(barSize){
315397
if(barSize){

0 commit comments

Comments
 (0)