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

Method calculateXShapeInfo

src/common/overlay/Point.js:183–228  ·  view source on GitHub ↗

* @function FeatureThemePoint.prototype.calculateXShapeInfo * @description 计算 X 轴方向上的图形信息,此信息是一个对象,包含两个属性, * 属性 xPositions 是一个一维数组,该数组元素表示图形在 x 轴方向上的像素坐标值, * 如果图形在 x 方向上有一定宽度,通常取图形在 x 方向上的中心点为图形在 x 方向上的坐标值。 * width 表示图形的宽度(特别注意:点的宽度始终为 0,而不是

()

Source from the content-addressed store, hash-verified

181 * width - {number}表示图形的宽度(特别注意:点的宽度始终为 0,而不是其直径)。
182 */
183 calculateXShapeInfo() {
184 var dvb = this.dataViewBox; // 数据视图框
185 var sets = this.setting; // 图表配置对象
186 var fvc = this.dataValues.length; // 数组值个数
187
188 if (fvc < 1) {
189 return null;
190 }
191
192 var xBlank; // x 轴空白间隔参数
193 var xShapePositions = []; // x 轴上图形的位置
194 var xShapeWidth = 0; // x 轴上图形宽度(自适应)
195 var dvbWidth = this.DVBWidth; // 数据视图框宽度
196 var unitOffset = 0; // 单位偏移量
197
198 // x 轴空白间隔参数处理
199 if (sets.xShapeBlank && sets.xShapeBlank.length && sets.xShapeBlank.length == 2) {
200 xBlank = sets.xShapeBlank;
201 var xsLen = dvbWidth - (xBlank[0] + xBlank[1]);
202 if (xsLen <= fvc) {
203 return null;
204 }
205 unitOffset = xsLen / (fvc - 1);
206 } else {
207 // 默认使用等距离空白间隔,空白间隔为图形宽度
208 unitOffset = dvbWidth / (fvc + 1);
209 xBlank = [unitOffset, unitOffset, unitOffset];
210 }
211
212 // 图形 x 轴上的位置计算
213 var xOffset = 0
214 for (var i = 0; i < fvc; i++) {
215 if (i == 0) {
216 xOffset = xBlank[0];
217 } else {
218 xOffset += unitOffset;
219 }
220
221 xShapePositions.push(dvb[0] + xOffset);
222 }
223
224 return {
225 "xPositions": xShapePositions,
226 "width": xShapeWidth
227 };
228 }
229
230}

Callers 1

assembleShapesMethod · 0.95

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected