* @function GraphThemeLayer.prototype.drawCharts * @description 绘制图表。包含压盖处理。 *
()
| 158 | * |
| 159 | */ |
| 160 | drawCharts() { |
| 161 | // 判断 rendere r就绪 |
| 162 | if (!this.renderer) { |
| 163 | return; |
| 164 | } |
| 165 | var charts = this.charts; |
| 166 | // 图表权重值处理des |
| 167 | if (this.overlayWeightField) { |
| 168 | charts.sort(function (cs, ce) { |
| 169 | if (typeof (cs["__overlayWeight"]) == "undefined" && typeof (ce["__overlayWeight"]) == "undefined") { |
| 170 | return 0; |
| 171 | } else if (typeof (cs["__overlayWeight"]) != "undefined" && typeof (ce["__overlayWeight"]) == "undefined") { |
| 172 | return -1; |
| 173 | } else if (typeof (cs["__overlayWeight"]) == "undefined" && typeof (ce["__overlayWeight"]) != "undefined") { |
| 174 | return 1; |
| 175 | } else if (typeof (cs["__overlayWeight"]) != "undefined" && typeof (ce["__overlayWeight"]) != "undefined") { |
| 176 | if (parseFloat(cs["__overlayWeight"]) < parseFloat(ce["__overlayWeight"])) { |
| 177 | return 1; |
| 178 | } else { |
| 179 | return -1; |
| 180 | } |
| 181 | } |
| 182 | return 0; |
| 183 | }); |
| 184 | } |
| 185 | // 不进行避让 |
| 186 | if (!this.isOverLay) { |
| 187 | for (var m = 0, len_m = charts.length; m < len_m; m++) { |
| 188 | var chart_m = charts[m]; |
| 189 | // 图形参考位置 (reSetLocation 会更新 chartBounds) |
| 190 | var shapeROP_m = chart_m.resetLocation(); |
| 191 | // 添加图形 |
| 192 | var shapes_m = chart_m.shapes; |
| 193 | for (var n = 0, slen_n = shapes_m.length; n < slen_n; n++) { |
| 194 | shapes_m[n].refOriginalPosition = shapeROP_m; |
| 195 | this.renderer.addShape(shapes_m[n]); |
| 196 | } |
| 197 | } |
| 198 | } else { |
| 199 | // 压盖判断所需 chartsBounds 集合 |
| 200 | var chartsBounds = []; |
| 201 | //var extent = this.map.getBounds(); |
| 202 | //var mapBounds = new Bounds(extent.getWest(), extent.getSouth(), extent.getEast(), extent.getNorth()); |
| 203 | // 获取地图像素 bounds |
| 204 | //var mapPxLT = this.getLocalXY(new LonLat(mapBounds.left, mapBounds.top)); |
| 205 | //var mapPxRB = this.getLocalXY(new LonLat(mapBounds.right, mapBounds.bottom)); |
| 206 | //var mBounds = new Bounds(mapPxLT[0], mapPxRB[1], mapPxRB[0], mapPxLT[1]); |
| 207 | // 压盖处理 & 添加图形 |
| 208 | for (let i = 0, len = charts.length; i < len; i++) { |
| 209 | var chart = charts[i]; |
| 210 | // 图形参考位置 (reSetLocation 会更新 chartBounds) |
| 211 | var shapeROP = chart.resetLocation(); |
| 212 | // 图表框 |
| 213 | var cbs = chart.chartBounds; |
| 214 | var cBounds = [{ |
| 215 | "x": cbs.left, |
| 216 | "y": cbs.top |
| 217 | }, { |
no test coverage detected