LegendView.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /**
  20. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21. */
  22. /*
  23. * Licensed to the Apache Software Foundation (ASF) under one
  24. * or more contributor license agreements. See the NOTICE file
  25. * distributed with this work for additional information
  26. * regarding copyright ownership. The ASF licenses this file
  27. * to you under the Apache License, Version 2.0 (the
  28. * "License"); you may not use this file except in compliance
  29. * with the License. You may obtain a copy of the License at
  30. *
  31. * http://www.apache.org/licenses/LICENSE-2.0
  32. *
  33. * Unless required by applicable law or agreed to in writing,
  34. * software distributed under the License is distributed on an
  35. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36. * KIND, either express or implied. See the License for the
  37. * specific language governing permissions and limitations
  38. * under the License.
  39. */
  40. import { __extends } from "tslib";
  41. import * as zrUtil from 'zrender/lib/core/util.js';
  42. import { parse, stringify } from 'zrender/lib/tool/color.js';
  43. import * as graphic from '../../util/graphic.js';
  44. import { enableHoverEmphasis } from '../../util/states.js';
  45. import { setLabelStyle, createTextStyle } from '../../label/labelStyle.js';
  46. import { makeBackground } from '../helper/listComponent.js';
  47. import * as layoutUtil from '../../util/layout.js';
  48. import ComponentView from '../../view/Component.js';
  49. import { createSymbol } from '../../util/symbol.js';
  50. import { createOrUpdatePatternFromDecal } from '../../util/decal.js';
  51. import { getECData } from '../../util/innerStore.js';
  52. var curry = zrUtil.curry;
  53. var each = zrUtil.each;
  54. var Group = graphic.Group;
  55. var LegendView = /** @class */function (_super) {
  56. __extends(LegendView, _super);
  57. function LegendView() {
  58. var _this = _super !== null && _super.apply(this, arguments) || this;
  59. _this.type = LegendView.type;
  60. _this.newlineDisabled = false;
  61. return _this;
  62. }
  63. LegendView.prototype.init = function () {
  64. this.group.add(this._contentGroup = new Group());
  65. this.group.add(this._selectorGroup = new Group());
  66. this._isFirstRender = true;
  67. };
  68. /**
  69. * @protected
  70. */
  71. LegendView.prototype.getContentGroup = function () {
  72. return this._contentGroup;
  73. };
  74. /**
  75. * @protected
  76. */
  77. LegendView.prototype.getSelectorGroup = function () {
  78. return this._selectorGroup;
  79. };
  80. /**
  81. * @override
  82. */
  83. LegendView.prototype.render = function (legendModel, ecModel, api) {
  84. var isFirstRender = this._isFirstRender;
  85. this._isFirstRender = false;
  86. this.resetInner();
  87. if (!legendModel.get('show', true)) {
  88. return;
  89. }
  90. var itemAlign = legendModel.get('align');
  91. var orient = legendModel.get('orient');
  92. if (!itemAlign || itemAlign === 'auto') {
  93. itemAlign = legendModel.get('left') === 'right' && orient === 'vertical' ? 'right' : 'left';
  94. }
  95. // selector has been normalized to an array in model
  96. var selector = legendModel.get('selector', true);
  97. var selectorPosition = legendModel.get('selectorPosition', true);
  98. if (selector && (!selectorPosition || selectorPosition === 'auto')) {
  99. selectorPosition = orient === 'horizontal' ? 'end' : 'start';
  100. }
  101. this.renderInner(itemAlign, legendModel, ecModel, api, selector, orient, selectorPosition);
  102. // Perform layout.
  103. var positionInfo = legendModel.getBoxLayoutParams();
  104. var viewportSize = {
  105. width: api.getWidth(),
  106. height: api.getHeight()
  107. };
  108. var padding = legendModel.get('padding');
  109. var maxSize = layoutUtil.getLayoutRect(positionInfo, viewportSize, padding);
  110. var mainRect = this.layoutInner(legendModel, itemAlign, maxSize, isFirstRender, selector, selectorPosition);
  111. // Place mainGroup, based on the calculated `mainRect`.
  112. var layoutRect = layoutUtil.getLayoutRect(zrUtil.defaults({
  113. width: mainRect.width,
  114. height: mainRect.height
  115. }, positionInfo), viewportSize, padding);
  116. this.group.x = layoutRect.x - mainRect.x;
  117. this.group.y = layoutRect.y - mainRect.y;
  118. this.group.markRedraw();
  119. // Render background after group is layout.
  120. this.group.add(this._backgroundEl = makeBackground(mainRect, legendModel));
  121. };
  122. LegendView.prototype.resetInner = function () {
  123. this.getContentGroup().removeAll();
  124. this._backgroundEl && this.group.remove(this._backgroundEl);
  125. this.getSelectorGroup().removeAll();
  126. };
  127. LegendView.prototype.renderInner = function (itemAlign, legendModel, ecModel, api, selector, orient, selectorPosition) {
  128. var contentGroup = this.getContentGroup();
  129. var legendDrawnMap = zrUtil.createHashMap();
  130. var selectMode = legendModel.get('selectedMode');
  131. var excludeSeriesId = [];
  132. ecModel.eachRawSeries(function (seriesModel) {
  133. !seriesModel.get('legendHoverLink') && excludeSeriesId.push(seriesModel.id);
  134. });
  135. each(legendModel.getData(), function (legendItemModel, dataIndex) {
  136. var name = legendItemModel.get('name');
  137. // Use empty string or \n as a newline string
  138. if (!this.newlineDisabled && (name === '' || name === '\n')) {
  139. var g = new Group();
  140. // @ts-ignore
  141. g.newline = true;
  142. contentGroup.add(g);
  143. return;
  144. }
  145. // Representitive series.
  146. var seriesModel = ecModel.getSeriesByName(name)[0];
  147. if (legendDrawnMap.get(name)) {
  148. // Have been drawn
  149. return;
  150. }
  151. // Legend to control series.
  152. if (seriesModel) {
  153. var data = seriesModel.getData();
  154. var lineVisualStyle = data.getVisual('legendLineStyle') || {};
  155. var legendIcon = data.getVisual('legendIcon');
  156. /**
  157. * `data.getVisual('style')` may be the color from the register
  158. * in series. For example, for line series,
  159. */
  160. var style = data.getVisual('style');
  161. var itemGroup = this._createItem(seriesModel, name, dataIndex, legendItemModel, legendModel, itemAlign, lineVisualStyle, style, legendIcon, selectMode, api);
  162. itemGroup.on('click', curry(dispatchSelectAction, name, null, api, excludeSeriesId)).on('mouseover', curry(dispatchHighlightAction, seriesModel.name, null, api, excludeSeriesId)).on('mouseout', curry(dispatchDownplayAction, seriesModel.name, null, api, excludeSeriesId));
  163. if (ecModel.ssr) {
  164. itemGroup.eachChild(function (child) {
  165. var ecData = getECData(child);
  166. ecData.seriesIndex = seriesModel.seriesIndex;
  167. ecData.dataIndex = dataIndex;
  168. ecData.ssrType = 'legend';
  169. });
  170. }
  171. legendDrawnMap.set(name, true);
  172. } else {
  173. // Legend to control data. In pie and funnel.
  174. ecModel.eachRawSeries(function (seriesModel) {
  175. // In case multiple series has same data name
  176. if (legendDrawnMap.get(name)) {
  177. return;
  178. }
  179. if (seriesModel.legendVisualProvider) {
  180. var provider = seriesModel.legendVisualProvider;
  181. if (!provider.containName(name)) {
  182. return;
  183. }
  184. var idx = provider.indexOfName(name);
  185. var style = provider.getItemVisual(idx, 'style');
  186. var legendIcon = provider.getItemVisual(idx, 'legendIcon');
  187. var colorArr = parse(style.fill);
  188. // Color may be set to transparent in visualMap when data is out of range.
  189. // Do not show nothing.
  190. if (colorArr && colorArr[3] === 0) {
  191. colorArr[3] = 0.2;
  192. // TODO color is set to 0, 0, 0, 0. Should show correct RGBA
  193. style = zrUtil.extend(zrUtil.extend({}, style), {
  194. fill: stringify(colorArr, 'rgba')
  195. });
  196. }
  197. var itemGroup = this._createItem(seriesModel, name, dataIndex, legendItemModel, legendModel, itemAlign, {}, style, legendIcon, selectMode, api);
  198. // FIXME: consider different series has items with the same name.
  199. itemGroup.on('click', curry(dispatchSelectAction, null, name, api, excludeSeriesId))
  200. // Should not specify the series name, consider legend controls
  201. // more than one pie series.
  202. .on('mouseover', curry(dispatchHighlightAction, null, name, api, excludeSeriesId)).on('mouseout', curry(dispatchDownplayAction, null, name, api, excludeSeriesId));
  203. if (ecModel.ssr) {
  204. itemGroup.eachChild(function (child) {
  205. var ecData = getECData(child);
  206. ecData.seriesIndex = seriesModel.seriesIndex;
  207. ecData.dataIndex = dataIndex;
  208. ecData.ssrType = 'legend';
  209. });
  210. }
  211. legendDrawnMap.set(name, true);
  212. }
  213. }, this);
  214. }
  215. if (process.env.NODE_ENV !== 'production') {
  216. if (!legendDrawnMap.get(name)) {
  217. console.warn(name + ' series not exists. Legend data should be same with series name or data name.');
  218. }
  219. }
  220. }, this);
  221. if (selector) {
  222. this._createSelector(selector, legendModel, api, orient, selectorPosition);
  223. }
  224. };
  225. LegendView.prototype._createSelector = function (selector, legendModel, api, orient, selectorPosition) {
  226. var selectorGroup = this.getSelectorGroup();
  227. each(selector, function createSelectorButton(selectorItem) {
  228. var type = selectorItem.type;
  229. var labelText = new graphic.Text({
  230. style: {
  231. x: 0,
  232. y: 0,
  233. align: 'center',
  234. verticalAlign: 'middle'
  235. },
  236. onclick: function () {
  237. api.dispatchAction({
  238. type: type === 'all' ? 'legendAllSelect' : 'legendInverseSelect'
  239. });
  240. }
  241. });
  242. selectorGroup.add(labelText);
  243. var labelModel = legendModel.getModel('selectorLabel');
  244. var emphasisLabelModel = legendModel.getModel(['emphasis', 'selectorLabel']);
  245. setLabelStyle(labelText, {
  246. normal: labelModel,
  247. emphasis: emphasisLabelModel
  248. }, {
  249. defaultText: selectorItem.title
  250. });
  251. enableHoverEmphasis(labelText);
  252. });
  253. };
  254. LegendView.prototype._createItem = function (seriesModel, name, dataIndex, legendItemModel, legendModel, itemAlign, lineVisualStyle, itemVisualStyle, legendIcon, selectMode, api) {
  255. var drawType = seriesModel.visualDrawType;
  256. var itemWidth = legendModel.get('itemWidth');
  257. var itemHeight = legendModel.get('itemHeight');
  258. var isSelected = legendModel.isSelected(name);
  259. var iconRotate = legendItemModel.get('symbolRotate');
  260. var symbolKeepAspect = legendItemModel.get('symbolKeepAspect');
  261. var legendIconType = legendItemModel.get('icon');
  262. legendIcon = legendIconType || legendIcon || 'roundRect';
  263. var style = getLegendStyle(legendIcon, legendItemModel, lineVisualStyle, itemVisualStyle, drawType, isSelected, api);
  264. var itemGroup = new Group();
  265. var textStyleModel = legendItemModel.getModel('textStyle');
  266. if (zrUtil.isFunction(seriesModel.getLegendIcon) && (!legendIconType || legendIconType === 'inherit')) {
  267. // Series has specific way to define legend icon
  268. itemGroup.add(seriesModel.getLegendIcon({
  269. itemWidth: itemWidth,
  270. itemHeight: itemHeight,
  271. icon: legendIcon,
  272. iconRotate: iconRotate,
  273. itemStyle: style.itemStyle,
  274. lineStyle: style.lineStyle,
  275. symbolKeepAspect: symbolKeepAspect
  276. }));
  277. } else {
  278. // Use default legend icon policy for most series
  279. var rotate = legendIconType === 'inherit' && seriesModel.getData().getVisual('symbol') ? iconRotate === 'inherit' ? seriesModel.getData().getVisual('symbolRotate') : iconRotate : 0; // No rotation for no icon
  280. itemGroup.add(getDefaultLegendIcon({
  281. itemWidth: itemWidth,
  282. itemHeight: itemHeight,
  283. icon: legendIcon,
  284. iconRotate: rotate,
  285. itemStyle: style.itemStyle,
  286. lineStyle: style.lineStyle,
  287. symbolKeepAspect: symbolKeepAspect
  288. }));
  289. }
  290. var textX = itemAlign === 'left' ? itemWidth + 5 : -5;
  291. var textAlign = itemAlign;
  292. var formatter = legendModel.get('formatter');
  293. var content = name;
  294. if (zrUtil.isString(formatter) && formatter) {
  295. content = formatter.replace('{name}', name != null ? name : '');
  296. } else if (zrUtil.isFunction(formatter)) {
  297. content = formatter(name);
  298. }
  299. var textColor = isSelected ? textStyleModel.getTextColor() : legendItemModel.get('inactiveColor');
  300. itemGroup.add(new graphic.Text({
  301. style: createTextStyle(textStyleModel, {
  302. text: content,
  303. x: textX,
  304. y: itemHeight / 2,
  305. fill: textColor,
  306. align: textAlign,
  307. verticalAlign: 'middle'
  308. }, {
  309. inheritColor: textColor
  310. })
  311. }));
  312. // Add a invisible rect to increase the area of mouse hover
  313. var hitRect = new graphic.Rect({
  314. shape: itemGroup.getBoundingRect(),
  315. style: {
  316. // Cannot use 'invisible' because SVG SSR will miss the node
  317. fill: 'transparent'
  318. }
  319. });
  320. var tooltipModel = legendItemModel.getModel('tooltip');
  321. if (tooltipModel.get('show')) {
  322. graphic.setTooltipConfig({
  323. el: hitRect,
  324. componentModel: legendModel,
  325. itemName: name,
  326. itemTooltipOption: tooltipModel.option
  327. });
  328. }
  329. itemGroup.add(hitRect);
  330. itemGroup.eachChild(function (child) {
  331. child.silent = true;
  332. });
  333. hitRect.silent = !selectMode;
  334. this.getContentGroup().add(itemGroup);
  335. enableHoverEmphasis(itemGroup);
  336. // @ts-ignore
  337. itemGroup.__legendDataIndex = dataIndex;
  338. return itemGroup;
  339. };
  340. LegendView.prototype.layoutInner = function (legendModel, itemAlign, maxSize, isFirstRender, selector, selectorPosition) {
  341. var contentGroup = this.getContentGroup();
  342. var selectorGroup = this.getSelectorGroup();
  343. // Place items in contentGroup.
  344. layoutUtil.box(legendModel.get('orient'), contentGroup, legendModel.get('itemGap'), maxSize.width, maxSize.height);
  345. var contentRect = contentGroup.getBoundingRect();
  346. var contentPos = [-contentRect.x, -contentRect.y];
  347. selectorGroup.markRedraw();
  348. contentGroup.markRedraw();
  349. if (selector) {
  350. // Place buttons in selectorGroup
  351. layoutUtil.box(
  352. // Buttons in selectorGroup always layout horizontally
  353. 'horizontal', selectorGroup, legendModel.get('selectorItemGap', true));
  354. var selectorRect = selectorGroup.getBoundingRect();
  355. var selectorPos = [-selectorRect.x, -selectorRect.y];
  356. var selectorButtonGap = legendModel.get('selectorButtonGap', true);
  357. var orientIdx = legendModel.getOrient().index;
  358. var wh = orientIdx === 0 ? 'width' : 'height';
  359. var hw = orientIdx === 0 ? 'height' : 'width';
  360. var yx = orientIdx === 0 ? 'y' : 'x';
  361. if (selectorPosition === 'end') {
  362. selectorPos[orientIdx] += contentRect[wh] + selectorButtonGap;
  363. } else {
  364. contentPos[orientIdx] += selectorRect[wh] + selectorButtonGap;
  365. }
  366. // Always align selector to content as 'middle'
  367. selectorPos[1 - orientIdx] += contentRect[hw] / 2 - selectorRect[hw] / 2;
  368. selectorGroup.x = selectorPos[0];
  369. selectorGroup.y = selectorPos[1];
  370. contentGroup.x = contentPos[0];
  371. contentGroup.y = contentPos[1];
  372. var mainRect = {
  373. x: 0,
  374. y: 0
  375. };
  376. mainRect[wh] = contentRect[wh] + selectorButtonGap + selectorRect[wh];
  377. mainRect[hw] = Math.max(contentRect[hw], selectorRect[hw]);
  378. mainRect[yx] = Math.min(0, selectorRect[yx] + selectorPos[1 - orientIdx]);
  379. return mainRect;
  380. } else {
  381. contentGroup.x = contentPos[0];
  382. contentGroup.y = contentPos[1];
  383. return this.group.getBoundingRect();
  384. }
  385. };
  386. /**
  387. * @protected
  388. */
  389. LegendView.prototype.remove = function () {
  390. this.getContentGroup().removeAll();
  391. this._isFirstRender = true;
  392. };
  393. LegendView.type = 'legend.plain';
  394. return LegendView;
  395. }(ComponentView);
  396. function getLegendStyle(iconType, legendItemModel, lineVisualStyle, itemVisualStyle, drawType, isSelected, api) {
  397. /**
  398. * Use series style if is inherit;
  399. * elsewise, use legend style
  400. */
  401. function handleCommonProps(style, visualStyle) {
  402. // If lineStyle.width is 'auto', it is set to be 2 if series has border
  403. if (style.lineWidth === 'auto') {
  404. style.lineWidth = visualStyle.lineWidth > 0 ? 2 : 0;
  405. }
  406. each(style, function (propVal, propName) {
  407. style[propName] === 'inherit' && (style[propName] = visualStyle[propName]);
  408. });
  409. }
  410. // itemStyle
  411. var itemStyleModel = legendItemModel.getModel('itemStyle');
  412. var itemStyle = itemStyleModel.getItemStyle();
  413. var iconBrushType = iconType.lastIndexOf('empty', 0) === 0 ? 'fill' : 'stroke';
  414. var decalStyle = itemStyleModel.getShallow('decal');
  415. itemStyle.decal = !decalStyle || decalStyle === 'inherit' ? itemVisualStyle.decal : createOrUpdatePatternFromDecal(decalStyle, api);
  416. if (itemStyle.fill === 'inherit') {
  417. /**
  418. * Series with visualDrawType as 'stroke' should have
  419. * series stroke as legend fill
  420. */
  421. itemStyle.fill = itemVisualStyle[drawType];
  422. }
  423. if (itemStyle.stroke === 'inherit') {
  424. /**
  425. * icon type with "emptyXXX" should use fill color
  426. * in visual style
  427. */
  428. itemStyle.stroke = itemVisualStyle[iconBrushType];
  429. }
  430. if (itemStyle.opacity === 'inherit') {
  431. /**
  432. * Use lineStyle.opacity if drawType is stroke
  433. */
  434. itemStyle.opacity = (drawType === 'fill' ? itemVisualStyle : lineVisualStyle).opacity;
  435. }
  436. handleCommonProps(itemStyle, itemVisualStyle);
  437. // lineStyle
  438. var legendLineModel = legendItemModel.getModel('lineStyle');
  439. var lineStyle = legendLineModel.getLineStyle();
  440. handleCommonProps(lineStyle, lineVisualStyle);
  441. // Fix auto color to real color
  442. itemStyle.fill === 'auto' && (itemStyle.fill = itemVisualStyle.fill);
  443. itemStyle.stroke === 'auto' && (itemStyle.stroke = itemVisualStyle.fill);
  444. lineStyle.stroke === 'auto' && (lineStyle.stroke = itemVisualStyle.fill);
  445. if (!isSelected) {
  446. var borderWidth = legendItemModel.get('inactiveBorderWidth');
  447. /**
  448. * Since stroke is set to be inactiveBorderColor, it may occur that
  449. * there is no border in series but border in legend, so we need to
  450. * use border only when series has border if is set to be auto
  451. */
  452. var visualHasBorder = itemStyle[iconBrushType];
  453. itemStyle.lineWidth = borderWidth === 'auto' ? itemVisualStyle.lineWidth > 0 && visualHasBorder ? 2 : 0 : itemStyle.lineWidth;
  454. itemStyle.fill = legendItemModel.get('inactiveColor');
  455. itemStyle.stroke = legendItemModel.get('inactiveBorderColor');
  456. lineStyle.stroke = legendLineModel.get('inactiveColor');
  457. lineStyle.lineWidth = legendLineModel.get('inactiveWidth');
  458. }
  459. return {
  460. itemStyle: itemStyle,
  461. lineStyle: lineStyle
  462. };
  463. }
  464. function getDefaultLegendIcon(opt) {
  465. var symboType = opt.icon || 'roundRect';
  466. var icon = createSymbol(symboType, 0, 0, opt.itemWidth, opt.itemHeight, opt.itemStyle.fill, opt.symbolKeepAspect);
  467. icon.setStyle(opt.itemStyle);
  468. icon.rotation = (opt.iconRotate || 0) * Math.PI / 180;
  469. icon.setOrigin([opt.itemWidth / 2, opt.itemHeight / 2]);
  470. if (symboType.indexOf('empty') > -1) {
  471. icon.style.stroke = icon.style.fill;
  472. icon.style.fill = '#fff';
  473. icon.style.lineWidth = 2;
  474. }
  475. return icon;
  476. }
  477. function dispatchSelectAction(seriesName, dataName, api, excludeSeriesId) {
  478. // downplay before unselect
  479. dispatchDownplayAction(seriesName, dataName, api, excludeSeriesId);
  480. api.dispatchAction({
  481. type: 'legendToggleSelect',
  482. name: seriesName != null ? seriesName : dataName
  483. });
  484. // highlight after select
  485. // TODO highlight immediately may cause animation loss.
  486. dispatchHighlightAction(seriesName, dataName, api, excludeSeriesId);
  487. }
  488. function isUseHoverLayer(api) {
  489. var list = api.getZr().storage.getDisplayList();
  490. var emphasisState;
  491. var i = 0;
  492. var len = list.length;
  493. while (i < len && !(emphasisState = list[i].states.emphasis)) {
  494. i++;
  495. }
  496. return emphasisState && emphasisState.hoverLayer;
  497. }
  498. function dispatchHighlightAction(seriesName, dataName, api, excludeSeriesId) {
  499. // If element hover will move to a hoverLayer.
  500. if (!isUseHoverLayer(api)) {
  501. api.dispatchAction({
  502. type: 'highlight',
  503. seriesName: seriesName,
  504. name: dataName,
  505. excludeSeriesId: excludeSeriesId
  506. });
  507. }
  508. }
  509. function dispatchDownplayAction(seriesName, dataName, api, excludeSeriesId) {
  510. // If element hover will move to a hoverLayer.
  511. if (!isUseHoverLayer(api)) {
  512. api.dispatchAction({
  513. type: 'downplay',
  514. seriesName: seriesName,
  515. name: dataName,
  516. excludeSeriesId: excludeSeriesId
  517. });
  518. }
  519. }
  520. export default LegendView;