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

Method calculateXShapeInfo

src/common/overlay/Bar.js:233–277  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

231 *
232 */
233 calculateXShapeInfo() {
234 var dvb = this.dataViewBox; // 数据视图框
235 var sets = this.setting; // 图表配置对象
236 var fvc = this.dataValues.length; // 数组值个数
237
238 if (fvc < 1) {
239 return null;
240 }
241
242 var xBlank; // x 轴空白间隔参数
243 var xShapePositions = []; // x 轴上图形的位置
244 var xShapeWidth = 0; // x 轴上图形宽度(自适应)
245 var dvbWidth = this.DVBWidth; // 数据视图框宽度
246
247 // x 轴空白间隔参数处理
248 if (sets.xShapeBlank && sets.xShapeBlank.length && sets.xShapeBlank.length == 3) {
249 xBlank = sets.xShapeBlank;
250 var xsLen = dvbWidth - (xBlank[0] + xBlank[2] + (fvc - 1) * xBlank[1]);
251 if (xsLen <= fvc) {
252 return null;
253 }
254 xShapeWidth = xsLen / fvc
255 } else {
256 // 默认使用等距离空白间隔,空白间隔为图形宽度
257 xShapeWidth = dvbWidth / (2 * fvc + 1);
258 xBlank = [xShapeWidth, xShapeWidth, xShapeWidth];
259 }
260
261 // 图形 x 轴上的位置计算
262 var xOffset = 0
263 for (var i = 0; i < fvc; i++) {
264 if (i == 0) {
265 xOffset = xBlank[0] + xShapeWidth / 2;
266 } else {
267 xOffset += (xShapeWidth + xBlank[1]);
268 }
269
270 xShapePositions.push(dvb[0] + xOffset);
271 }
272
273 return {
274 "xPositions": xShapePositions,
275 "width": xShapeWidth
276 };
277 }
278
279 /**
280 * @function FeatureThemeBar.prototype.resetLinearGradient

Callers 1

assembleShapesMethod · 0.95

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected