MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / initBaseParameter

Method initBaseParameter

src/common/overlay/Graph.js:257–342  ·  view source on GitHub ↗

* @function FeatureThemeGraph.prototype.initBaseParameter * @description 初始化专题要素(图表)基础参数。在调用此方法前,此类的图表模型相关属性都是不可用的 ,此方法在 assembleShapes 函数中调用。 * 调用此函数关系到 setting 对象的以下属性。 * @param {number} width - 专题要素(图表)宽度,单位为像素。 * @param {number} height - 专题要素(图表)高度,单位为像素。 *

()

Source from the content-addressed store, hash-verified

255 * @returns {boolean} 初始化参数是否成功。
256 */
257 initBaseParameter() {
258 // 参数初始化是否成功
259 var isSuccess = true;
260
261 // setting 属性是否已成功赋值
262 if (!this.setting) {
263 return false;
264 }
265 var sets = this.setting;
266 // 检测 setting 的必设参数
267 if (!(sets.width && sets.height && sets.codomain)) {
268 return false;
269 }
270
271 // 数据
272 var decimalNumber = (typeof(sets.decimalNumber) !== "undefined" && !isNaN(sets.decimalNumber)) ? sets.decimalNumber : -1;
273 var dataEffective = Theme.getDataValues(this.data, this.fields, decimalNumber);
274 this.dataValues = dataEffective ? dataEffective : [];
275
276 // 基础参数 width, height, codomain
277 this.width = parseFloat(sets.width);
278 this.height = parseFloat(sets.height);
279 this.DVBCodomain = sets.codomain;
280
281 // 图表偏移
282 // if(sets.XOffset) {this.XOffset = sets.XOffset};
283 // if(sets.YOffset) {this.YOffset = sets.YOffset};
284 this.XOffset = sets.XOffset ? sets.XOffset : 0;
285 this.YOffset = sets.YOffset ? sets.YOffset : 0;
286
287 // 其他默认值
288 this.origonPoint = [];
289 this.chartBox = [];
290 this.dataViewBox = [];
291
292 this.DVBParameter = sets.dataViewBoxParameter ? sets.dataViewBoxParameter : [0, 0, 0, 0];
293
294 this.DVBOrigonPoint = [];
295 this.DVBCenterPoint = [];
296 this.origonPointOffset = [];
297
298 // 图表位置
299 this.resetLocation();
300
301 // 专题要素宽度 w
302 var w = this.width;
303 // 专题要素高度 h
304 var h = this.height;
305 // 专题要素像素位置 loc
306 var loc = this.location;
307
308 // 专题要素像素位置 loc
309 this.origonPoint = [loc[0] - w / 2, loc[1] - h / 2];
310 // 专题要素原点(左上角)
311 var op = this.origonPoint;
312
313 // 图表框([left, bottom, right, top])
314 this.chartBox = [op[0], op[1] + h, op[0] + w, op[1]];

Callers 7

assembleShapesMethod · 0.45
assembleShapesMethod · 0.45
assembleShapesMethod · 0.45
assembleShapesMethod · 0.45
assembleShapesMethod · 0.45
assembleShapesMethod · 0.45
assembleShapesMethod · 0.45

Calls 1

resetLocationMethod · 0.95

Tested by

no test coverage detected