ecModel.eachSeries(function (seriesModel) { if (seriesModel.coordinateSystem === polar) { var data = seriesModel.getData(); zrUtil.each(data.mapDimension('radius', true), function (dim) { radiusAxis.scale.unionExtentFromData( data, getStackedDimension(data, dim) ); }); zrUtil.each(data.mapDimension('angle', true), function (dim) { angleAxis.scale.unionExtentFromData( data, getStackedDimension(data, dim) ); }); } });
function setEncodeAndDimensions(source, seriesModel) { // The mapping of parallelAxis dimension to data dimension can // be specified in parallelAxis.option.dim. For example, if // parallelAxis.option.dim is 'dim3', it mapping to the third // dimension of data. But `data.encode` has higher priority. // Moreover, parallelModel.dimension should not be regarded as data // dimensions. Consider dimensions = ['dim4', 'dim2', 'dim6']; if (source.encodeDefine) { return; } var parallelModel = seriesModel.ecModel.getComponent( 'parallel', seriesModel.get('parallelIndex') ); if (!parallelModel) { return; } var encodeDefine = source.encodeDefine = createHashMap(); each(parallelModel.dimensions, function (axisDim) { var dataDimIndex = convertDimNameToNumber(axisDim); encodeDefine.set(axisDim, dataDimIndex); }); }
zrUtil.each(groups, function (group) { if (opts.sortSub && opts.sortSub != 'none') { group.subGroups.sort(compareGroups); if (opts.sortSub === 'descending') { group.subGroups.reverse(); } } var endAngle = angle + sign * group.size * unitAngle; group.node.setLayout({ startAngle: -angle, endAngle: -endAngle, cx: opts.cx, cy: opts.cy, r0: opts.r0, r: opts.r, clockwise: opts.clockwise }); zrUtil.each(group.subGroups, function (subGroup) { var startAngle = angle; var endAngle = angle + sign * subGroup.size * unitAngle; var layout = subGroup.edge.getLayout() || { cx: opts.cx, cy: opts.cy, r: opts.r0, clockwise: opts.clockwise }; layout.startAngle = -startAngle; layout.endAngle = -endAngle; subGroup.edge.setLayout(layout); angle = endAngle; }); angle = endAngle + sign * opts.padding; });
function isSetLoc(obj, props) { var isSet; zrUtil.each(props, function (prop) { obj[prop] != null && obj[prop] !== 'auto' && (isSet = true); }); return isSet; }
zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) { var mapData = echarts.getMap(mapType); if (__DEV__) { if (!mapData) { mapNotExistsError(mapSeries[0].get('map')); } } var nameMapList = zrUtil.map(mapSeries, function (singleMapSeries) { return singleMapSeries.get('nameMap'); }); var geo = new Geo( mapType, mapType, mapData && mapData.geoJson, mapData && mapData.specialAreas, zrUtil.mergeAll(nameMapList) ); geo.zoomLimit = zrUtil.retrieve.apply(null, zrUtil.map(mapSeries, function (singleMapSeries) { return singleMapSeries.get('scaleLimit'); })); geoList.push(geo); // Inject resize method geo.resize = resizeGeo; geo.resize(mapSeries[0], api); zrUtil.each(mapSeries, function (singleMapSeries) { singleMapSeries.coordinateSystem = geo; setGeoCoords(geo, singleMapSeries); }); });
zrUtil.each(radioTypes, function (radio) { if (zrUtil.indexOf(radio, type) >= 0) { zrUtil.each(radio, function (item) { model.setIconStatus(item, 'normal'); }); } });
function compatLayoutProperties(option) { each(LAYOUT_PROPERTIES, function (prop) { if (prop[0] in option && !(prop[1] in option)) { option[prop[1]] = option[prop[0]]; } }); }
zrUtil.each(this.getTargetCoordInfo(), function (coordInfoList, coordSysName) { var allCoordIds = zrUtil.map(coordInfoList, function (coordInfo) { return roams.generateCoordId(coordInfo.model); }); zrUtil.each(coordInfoList, function (coordInfo) { var coordModel = coordInfo.model; var dataZoomOption = dataZoomModel.option; roams.register( api, { coordId: roams.generateCoordId(coordModel), allCoordIds: allCoordIds, containsPoint: function (e, x, y) { return coordModel.coordinateSystem.containPoint([x, y]); }, dataZoomId: dataZoomModel.id, throttleRate: dataZoomModel.get('throttle', true), panGetRange: bind(this._onPan, this, coordInfo, coordSysName), zoomGetRange: bind(this._onZoom, this, coordInfo, coordSysName), zoomLock: dataZoomOption.zoomLock, disabled: dataZoomOption.disabled, roamControllerOpt: { zoomOnMouseWheel: dataZoomOption.zoomOnMouseWheel, moveOnMouseMove: dataZoomOption.moveOnMouseMove, preventDefaultMouseMove: dataZoomOption.preventDefaultMouseMove } } ); }, this); }, this);
/** * Merge roamController settings when multiple dataZooms share one roamController. */ function mergeControllerParams(dataZoomInfos) { var controlType; var opt = {}; // DO NOT use reserved word (true, false, undefined) as key literally. Even if encapsulated // as string, it is probably revert to reserved word by compress tool. See #7411. var prefix = 'type_'; var typePriority = { 'type_true': 2, 'type_move': 1, 'type_false': 0, 'type_undefined': -1 }; zrUtil.each(dataZoomInfos, function (dataZoomInfo) { var oneType = dataZoomInfo.disabled ? false : dataZoomInfo.zoomLock ? 'move' : true; if (typePriority[prefix + oneType] > typePriority[prefix + controlType]) { controlType = oneType; } // Do not support that different 'shift'/'ctrl'/'alt' setting used in one coord sys. zrUtil.extend(opt, dataZoomInfo.roamControllerOpt); }); return { controlType: controlType, opt: opt }; }
function cleanStore(store) { zrUtil.each(store, function (record, coordId) { if (!record.count) { record.controller.dispose(); delete store[coordId]; } }); }
optionUpdated: function () { ToolboxModel.superApply(this, 'optionUpdated', arguments); zrUtil.each(this.option.feature, function (featureOpt, featureName) { var Feature = featureManager.get(featureName); Feature && zrUtil.merge(featureOpt, Feature.defaultOption); }); },
ecModel.eachSeries(function (seriesModel) { if (seriesModel.coordinateSystem === this) { var data = seriesModel.getData(); each(data.mapDimension(this.dimension, true), function (dim) { this._axis.scale.unionExtentFromData(data, dim); }, this); axisHelper.niceScaleExtent(this._axis.scale, this._axis.model); } }, this);
appendData: function (newData) { var data = this._data; each(newData, function (newCol, key) { var oldCol = data[key] || (data[key] = []); for (var i = 0; i < (newCol || []).length; i++) { oldCol.push(newCol[i]); } }); }
export default function (option, isTheme) { compatStyle(option, isTheme); // Make sure series array for model initialization. option.series = normalizeToArray(option.series); each(option.series, function (seriesOpt) { if (!isObject(seriesOpt)) { return; } var seriesType = seriesOpt.type; if (seriesType === 'pie' || seriesType === 'gauge') { if (seriesOpt.clockWise != null) { seriesOpt.clockwise = seriesOpt.clockWise; } } if (seriesType === 'gauge') { var pointerColor = get(seriesOpt, 'pointer.color'); pointerColor != null && set(seriesOpt, 'itemStyle.normal.color', pointerColor); } compatLayoutProperties(seriesOpt); }); // dataRange has changed to visualMap if (option.dataRange) { option.visualMap = option.dataRange; } each(COMPATITABLE_COMPONENTS, function (componentName) { var options = option[componentName]; if (options) { if (!isArray(options)) { options = [options]; } each(options, function (option) { compatLayoutProperties(option); }); } }); }
// Remove unnecessary props to avoid potential problems. function getCleanedElOption(elOption) { elOption = zrUtil.extend({}, elOption); zrUtil.each( ['id', 'parentId', '$action', 'hv', 'bounding'].concat(layoutUtil.LOCATION_PARAMS), function (name) { delete elOption[name]; } ); return elOption; }
proto.getIcons = function () { var model = this.model; var availableIcons = model.get('icon'); var icons = {}; zrUtil.each(model.get('type'), function (type) { if (availableIcons[type]) { icons[type] = availableIcons[type]; } }); return icons; };
select: function (name) { var selected = this.option.selected; var selectedMode = this.get('selectedMode'); if (selectedMode === 'single') { var data = this._data; zrUtil.each(data, function (dataItem) { selected[dataItem.get('name')] = false; }); } selected[name] = true; },
ecModel.eachSeriesByType('radar', function (radarSeries, idx) { if (radarSeries.get('coordinateSystem') !== 'radar' || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel ) { return; } var data = radarSeries.getData(); zrUtil.each(indicatorAxes, function (indicatorAxis) { indicatorAxis.scale.unionExtentFromData(data, data.mapDimension(indicatorAxis.dim)); }); }, this);
each(COMPATITABLE_COMPONENTS, function (componentName) { var options = option[componentName]; if (options) { if (!isArray(options)) { options = [options]; } each(options, function (option) { compatLayoutProperties(option); }); } });
function propsEqual(lastProps, newProps) { if (zrUtil.isObject(lastProps) && zrUtil.isObject(newProps)) { var equals = true; zrUtil.each(newProps, function (item, key) { equals = equals && propsEqual(lastProps[key], item); }); return !!equals; } else { return lastProps === newProps; } }
export default function (option) { if (!option || !zrUtil.isArray(option.series)) { return; } // Translate 'k' to 'candlestick'. zrUtil.each(option.series, function (seriesItem) { if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') { seriesItem.type = 'candlestick'; } }); }
encodeDef.each(function (dataDims, coordDim) { dataDims = normalizeToArray(dataDims).slice(); var validDataDims = encodeDef.set(coordDim, []); each(dataDims, function (resultDimIdx, idx) { // The input resultDimIdx can be dim name or index. isString(resultDimIdx) && (resultDimIdx = dataDimNameMap.get(resultDimIdx)); if (resultDimIdx != null && resultDimIdx < dimCount) { validDataDims[idx] = resultDimIdx; applyDim(result[resultDimIdx], coordDim, idx); } }); });
function objectRowsCollectDimensions(data) { var firstIndex = 0; var obj; while (firstIndex < data.length && !(obj = data[firstIndex++])) {} // jshint ignore: line if (obj) { var dimensions = []; each(obj, function (value, key) { dimensions.push(key); }); return dimensions; } }
function wrapAndDispatch(record, getRange) { var batch = []; zrUtil.each(record.dataZoomInfos, function (info) { var range = getRange(info); !info.disabled && range && batch.push({ dataZoomId: info.dataZoomId, start: range[0], end: range[1] }); }); batch.length && record.dispatchAction(batch); }
optionUpdated: function (newOption, isInit) { var thisOption = this.option; var newList = (isInit ? thisOption : newOption).elements; var existList = thisOption.elements = isInit ? [] : thisOption.elements; var flattenedList = []; this._flatten(newList, flattenedList); var mappingResult = modelUtil.mappingToExists(existList, flattenedList); modelUtil.makeIdAndName(mappingResult); // Clear elOptionsToUpdate var elOptionsToUpdate = this._elOptionsToUpdate = []; zrUtil.each(mappingResult, function (resultItem, index) { var newElOption = resultItem.option; if (__DEV__) { zrUtil.assert( zrUtil.isObject(newElOption) || resultItem.exist, 'Empty graphic option definition' ); } if (!newElOption) { return; } elOptionsToUpdate.push(newElOption); setKeyInfoToNewElOption(resultItem, newElOption); mergeNewElOptionToExist(existList, index, newElOption); setLayoutInfoToExist(existList[index], newElOption); }, this); // Clean for (var i = existList.length - 1; i >= 0; i--) { if (existList[i] == null) { existList.splice(i, 1); } else { // $action should be volatile, otherwise option gotten from // `getOption` will contain unexpected $action. delete existList[i].$action; } } },
export function unregister(api, dataZoomId) { var store = giveStore(api); zrUtil.each(store, function (record) { record.controller.dispose(); var dataZoomInfos = record.dataZoomInfos; if (dataZoomInfos[dataZoomId]) { delete dataZoomInfos[dataZoomId]; record.count--; } }); cleanStore(store); }
function replace(str, keyValues) { if (typeof str !== 'string') { return str; } var result = str; zrUtil.each(keyValues, function (value, key) { result = result.replace( new RegExp('\\{\\s*' + key + '\\s*\\}', 'g'), value ); }); return result; }
export function register(api, dataZoomInfo) { var store = giveStore(api); var theDataZoomId = dataZoomInfo.dataZoomId; var theCoordId = dataZoomInfo.coordId; // Do clean when a dataZoom changes its target coordnate system. // Avoid memory leak, dispose all not-used-registered. zrUtil.each(store, function (record, coordId) { var dataZoomInfos = record.dataZoomInfos; if (dataZoomInfos[theDataZoomId] && zrUtil.indexOf(dataZoomInfo.allCoordIds, theCoordId) < 0 ) { delete dataZoomInfos[theDataZoomId]; record.count--; } }); cleanStore(store); var record = store[theCoordId]; // Create if needed. if (!record) { record = store[theCoordId] = { coordId: theCoordId, dataZoomInfos: {}, count: 0 }; record.controller = createController(api, record); record.dispatchAction = zrUtil.curry(dispatchAction, api); } // Update reference of dataZoom. !(record.dataZoomInfos[theDataZoomId]) && record.count++; record.dataZoomInfos[theDataZoomId] = dataZoomInfo; var controllerParams = mergeControllerParams(record.dataZoomInfos); record.controller.enable(controllerParams.controlType, controllerParams.opt); // Consider resize, area should be always updated. record.controller.setPointerChecker(dataZoomInfo.containsPoint); // Update throttle. throttleUtil.createOrUpdate( record, 'dispatchAction', dataZoomInfo.throttleRate, 'fixRate' ); }
// ??? TODO // Originally detect dimCount by data[0]. Should we // optimize it to only by sysDims and dimensions and encode. // So only necessary dims will be initialized. // But // (1) custom series should be considered. where other dims // may be visited. // (2) sometimes user need to calcualte bubble size or use visualMap // on other dimensions besides coordSys needed. // So, dims that is not used by system, should be shared in storage? function getDimCount(source, sysDims, dimsDef, optDimCount) { // Note that the result dimCount should not small than columns count // of data, otherwise `dataDimNameMap` checking will be incorrect. var dimCount = Math.max( source.dimensionsDetectCount || 1, sysDims.length, dimsDef.length, optDimCount || 0 ); each(sysDims, function (sysDimItem) { var sysDimItemDimsDef = sysDimItem.dimsDef; sysDimItemDimsDef && (dimCount = Math.max(dimCount, sysDimItemDimsDef.length)); }); return dimCount; }
ecModel.eachSeriesByType('map', function (mapSeries) { var mapType = mapSeries.getMapType(); if (mapSeries.getHostGeoModel() || processedMapType[mapType]) { return; } var mapSymbolOffsets = {}; zrUtil.each(mapSeries.seriesGroup, function (subMapSeries) { var geo = subMapSeries.coordinateSystem; var data = subMapSeries.originalData; if (subMapSeries.get('showLegendSymbol') && ecModel.getComponent('legend')) { data.each(data.mapDimension('value'), function (value, idx) { var name = data.getName(idx); var region = geo.getRegion(name); // If input series.data is [11, 22, '-'/null/undefined, 44], // it will be filled with NaN: [11, 22, NaN, 44] and NaN will // not be drawn. So here must validate if value is NaN. if (!region || isNaN(value)) { return; } var offset = mapSymbolOffsets[name] || 0; var point = geo.dataToPoint(region.center); mapSymbolOffsets[name] = offset + 1; data.setItemLayout(idx, { point: point, offset: offset }); }); } }); // Show label of those region not has legendSymbol(which is offset 0) var data = mapSeries.getData(); data.each(function (idx) { var name = data.getName(idx); var layout = data.getItemLayout(idx) || {}; layout.showLabel = !mapSymbolOffsets[name]; data.setItemLayout(idx, layout); }); processedMapType[mapType] = true; });