123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- var zrUtil = require("zrender/lib/core/util");
- var _default = {
-
- updateSelectedMap: function (targetList) {
- this._targetList = zrUtil.isArray(targetList) ? targetList.slice() : [];
- this._selectTargetMap = zrUtil.reduce(targetList || [], function (targetMap, target) {
- targetMap.set(target.name, target);
- return targetMap;
- }, zrUtil.createHashMap());
- },
-
-
- select: function (name, id) {
- var target = id != null ? this._targetList[id] : this._selectTargetMap.get(name);
- var selectedMode = this.get('selectedMode');
- if (selectedMode === 'single') {
- this._selectTargetMap.each(function (target) {
- target.selected = false;
- });
- }
- target && (target.selected = true);
- },
-
- unSelect: function (name, id) {
- var target = id != null ? this._targetList[id] : this._selectTargetMap.get(name);
-
- target && (target.selected = false);
- },
-
- toggleSelected: function (name, id) {
- var target = id != null ? this._targetList[id] : this._selectTargetMap.get(name);
- if (target != null) {
- this[target.selected ? 'unSelect' : 'select'](name, id);
- return target.selected;
- }
- },
-
- isSelected: function (name, id) {
- var target = id != null ? this._targetList[id] : this._selectTargetMap.get(name);
- return target && target.selected;
- }
- };
- module.exports = _default;
|