MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / drawCharts

Method drawCharts

src/openlayers/overlay/Graph.js:180–282  ·  view source on GitHub ↗

* @function Graph.prototype.drawCharts * @description 绘制图表。包含压盖处理。 *

()

Source from the content-addressed store, hash-verified

178 *
179 */
180 drawCharts() {
181 // 判断 rendere r就绪
182 if (!this.renderer) {
183 return;
184 }
185 var charts = this.charts;
186 // 图表权重值处理
187 if (this.overlayWeightField) {
188 charts.sort(function (cs, ce) {
189 if (typeof (cs["__overlayWeight"]) == "undefined" && typeof (ce["__overlayWeight"]) == "undefined") {
190 return 0;
191 } else if (typeof (cs["__overlayWeight"]) != "undefined" && typeof (ce["__overlayWeight"]) == "undefined") {
192 return -1;
193 } else if (typeof (cs["__overlayWeight"]) == "undefined" && typeof (ce["__overlayWeight"]) != "undefined") {
194 return 1;
195 } else if (typeof (cs["__overlayWeight"]) != "undefined" && typeof (ce["__overlayWeight"]) != "undefined") {
196 if (parseFloat(cs["__overlayWeight"]) < parseFloat(ce["__overlayWeight"])) {
197 return 1;
198 } else {
199 return -1;
200 }
201 }
202 return 0;
203 });
204 }
205 // 不进行避让
206 if (!this.isOverLay) {
207 for (var m = 0, len_m = charts.length; m < len_m; m++) {
208 var chart_m = charts[m];
209 // 图形参考位置 (reSetLocation 会更新 chartBounds)
210 var shapeROP_m = chart_m.resetLocation();
211 // 添加图形
212 var shapes_m = chart_m.shapes;
213 for (var n = 0, slen_n = shapes_m.length; n < slen_n; n++) {
214 shapes_m[n].refOriginalPosition = shapeROP_m;
215 this.renderer.addShape(shapes_m[n]);
216 }
217 }
218 } else {
219 // 压盖判断所需 chartsBounds 集合
220 var chartsBounds = [];
221 var extent = this.map.getView().calculateExtent();
222 var mapBounds = new Bounds(extent[0], extent[1], extent[2], extent[3]);
223 // 获取地图像素 bounds
224 var mapPxLT = this.getLocalXY(new LonLat(mapBounds.left, mapBounds.top));
225 var mapPxRB = this.getLocalXY(new LonLat(mapBounds.right, mapBounds.bottom));
226 var mBounds = new Bounds(mapPxLT[0], mapPxRB[1], mapPxRB[0], mapPxLT[1]);
227 // 压盖处理 & 添加图形
228 for (var i = 0, len = charts.length; i < len; i++) {
229 var chart = charts[i];
230 // 图形参考位置 (reSetLocation 会更新 chartBounds)
231 var shapeROP = chart.resetLocation();
232 // 图表框
233 var cbs = chart.chartBounds;
234 var cBounds = [{
235 "x": cbs.left,
236 "y": cbs.top
237 }, {

Callers 5

GraphSpec.jsFile · 0.45
GraphThemeLayer.jsFile · 0.45

Calls 8

getLocalXYMethod · 0.95
isChartInMapMethod · 0.95
resetLocationMethod · 0.80
addShapeMethod · 0.80
getViewMethod · 0.80
pushMethod · 0.80
renderMethod · 0.65

Tested by

no test coverage detected