forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChartViewSpec.js
More file actions
114 lines (111 loc) · 3.42 KB
/
ChartViewSpec.js
File metadata and controls
114 lines (111 loc) · 3.42 KB
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
106
107
108
109
110
111
112
113
114
import { ChartView } from '../../../../src/common/widgets/chart/ChartView';
import '../../../resources/FeatureService';
describe('ChartView', () => {
var chartDiv = window.document.createElement("div");
chartDiv.setAttribute("id", "chart");
chartDiv.style.styleFloat = "left";
chartDiv.style.marginLeft = "8px";
chartDiv.style.marginTop = "50px";
chartDiv.style.width = "450px";
chartDiv.style.height = "350px";
window.document.body.appendChild(chartDiv);
var options = {
type: 'line',
datasets: {
type: 'iServer', //iServer iPortal
url: "http://support.supermap.com:8090/iserver/services/map-world/rest/maps/World/layers/Rivers@World@@World",
withCredentials: false,
queryInfo: {
attributeFilter: "SmID > 0"
}
},
chartOptions: [{
xAxis: {
field: "NAME",
name: "name"
},
yAxis: {
field: "KILOMETERS",
name: "Kilometers"
}
}]
}
var chartView = new ChartView("chart", options);
it('constructor, _fillDataToView', () => {
expect(chartView.domID).toBe("chart");
expect(chartView.chartType).toBe("line");
});
it('onAdd', () => {
let addChart = function () { }
chartView.onAdd(addChart);
expect(chartView.addChart).toBe(addChart);
});
it('setStyle', () => {
var style = {
backgroundColor: "#fff",
grid: {}
}
chartView.setStyle(style);
expect(chartView.echart).not.toBeNull();
});
it('changeType', () => {
chartView.changeType("bar");
expect(chartView.chartType).toBe("bar");
});
it('updateData', () => {
var url = "http://support.supermap.com:8090/iserver/services/map-world/rest/maps/World/layers/Rivers@World@@World";
var datasets = {
type: 'iServer', //iServer iPortal
url,
withCredentials: false,
queryInfo: {
attributeFilter: "SmID > 0"
}
};
var chartOption = [{
xAxis: {
field: "AREA",
name: "Area"
}
}]
chartView.updateData(datasets, chartOption);
});
it('_createChart', () => {
var recordsets = QueryBySQLService.result.recordsets[0];
var data = {
features: recordsets.features,
fieldCaptions: recordsets.fieldCaptions,
fieldTypes: recordsets.fieldTypes,
fieldValues: [[21, 21], [21.2, 22]]
}
chartView._createChart(data);
expect(chartView.echart).not.toBeNull();
});
it('_updateChart', () => {
let option = {
series: [{
data: [1, 2, 3],
type: "bar"
}],
xAxis: {
type: "category",
name: "X",
data: [1, 2, 3]
},
yAxis: {
type: "value",
name: "Y"
}
}
chartView._updateChart(option);
expect(chartView.echart).not.toBeNull();
});
it('getFeatures', () => {
var features = chartView.getFeatures();
expect(features).not.toBeNull();
});
it('getStyle', () => {
var style = chartView.getStyle();
expect(style).not.toBeNull();
});
});