Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/component/legend/legendAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@
* under the License.
*/

// @ts-nocheck
import { curry, each } from 'zrender/src/core/util';
import { EChartsExtensionInstallRegisters } from '../../extension';
import GlobalModel from '../../model/Global';
import { Payload } from '../../util/types';
import LegendModel from './LegendModel';

import {curry, each} from 'zrender/src/core/util';

function legendSelectActionHandler(methodName, payload, ecModel) {
const selectedMap = {};
function legendSelectActionHandler(methodName: keyof LegendModel, payload: Payload, ecModel: GlobalModel) {
const selectedMap: {[key: string]: boolean} = {};
const isToggleSelect = methodName === 'toggleSelected';
let isSelected;
let isSelected: boolean;
// Update all legend components
ecModel.eachComponent('legend', function (legendModel) {
if (isToggleSelect && isSelected != null) {
ecModel.eachComponent('legend', function (legendModel: LegendModel) {
if (isToggleSelect && isSelected != null && legendModel.option.data.includes(payload.name)) {
// Force other legend has same selected status
// Or the first is toggled to true and other are toggled to false
// In the case one legend has some item unSelected in option. And if other legend
Expand All @@ -38,7 +40,7 @@ function legendSelectActionHandler(methodName, payload, ecModel) {
legendModel[methodName]();
}
else {
legendModel[methodName](payload.name);
(legendModel[methodName] as (name: string) => void)(payload.name);
isSelected = legendModel.isSelected(payload.name);
}
const legendData = legendModel.getData();
Expand Down Expand Up @@ -69,7 +71,7 @@ function legendSelectActionHandler(methodName, payload, ecModel) {
};
}

export function installLegendAction(registers) {
export function installLegendAction(registers: EChartsExtensionInstallRegisters) {
/**
* @event legendToggleSelect
* @type {Object}
Expand Down
136 changes: 136 additions & 0 deletions test/legend.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.