Skip to content

Commit f85f9fb

Browse files
committed
add woqlchart test
1 parent 484722b commit f85f9fb

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
WOQLClient:require('./lib/woqlClient'),
2+
WOQLClient:require('./lib/woqlClient'),
33
ConnectionCapabilities:require('./lib/connectionCapabilities'),
44
ConnectionConfig:require('./lib/connectionConfig'),
55
IDParser:require('./lib/terminusIDParser'),

lib/viewer/chartConfig.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ WOQLChartRule.prototype.style=function(key,value){
114114
return this.rule[key];
115115
}
116116

117+
WOQLChartRule.prototype.label = function(label){
118+
if(label){
119+
this.rule.label = label;
120+
return this;
121+
}
122+
return this.rule.label;
123+
}
124+
125+
117126
WOQLChartRule.prototype.fill=function(color){
118127
if(color){
119128
this.rule.fill = color;
@@ -156,12 +165,17 @@ WOQLChartRule.prototype.labelRotate=function(angle){
156165
return this.rule.labelRotate;
157166
}
158167

159-
WOQLChartRule.prototype.axisType=function(type){
168+
/*
169+
* The type of xAxis or yAxis 'number' | 'category' default is 'category'.
170+
* The type of line chart 'basis'|'basisClosed'|'basisOpen'|'linear'|'linearClosed'|'natural'|'monotoneX'|'monotoneY'|'monotone' | 'step' | 'stepBefore' | 'stepAfter' |
171+
*/
172+
173+
WOQLChartRule.prototype.type=function(type){
160174
if(type){
161-
this.pattern.scope=type
175+
this.rule.type=type
162176
return this;
163177
}
164-
return this.pattern.scope
178+
return this.rule.type
165179
}
166180
/*
167181
* works only if type is number

test/woqlChart.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const expect = require('chai').expect;
2+
var WOQLChartConfig = require('../lib/viewer/chartConfig');
3+
4+
describe('woqlChart config', function () {
5+
6+
let woqlChart;
7+
8+
beforeEach(function() {
9+
woqlChart = new WOQLChartConfig()
10+
});
11+
12+
it("config type chart",function(){
13+
expect(woqlChart.type).to.equal('chart');
14+
15+
woqlChart.xAxis("timestamp").label("Day").type("number");
16+
17+
const json={"chart":{},"rules":[{"pattern":{"scope":"XAxis","variables":["v:timestamp"]}
18+
,"rule":{"label":"Day","type":"number"}}]}
19+
20+
21+
console.log(JSON.stringify(woqlChart.json()));
22+
23+
})
24+
25+
})

test/woqlViewConfig.spec.js

Whitespace-only changes.

0 commit comments

Comments
 (0)