Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(radar): Radar series tooltip support dimensionIndex #20677

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion src/chart/radar/RadarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { VectorArray } from 'zrender/src/core/vector';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
import ZRImage from 'zrender/src/graphic/Image';
import { saveOldStyle } from '../../animation/basicTransition';
import { getECData } from '../../util/innerStore';

type RadarSymbol = ReturnType<typeof symbolUtil.createSymbol> & {
__dimIdx: number
Expand Down Expand Up @@ -241,9 +242,10 @@ class RadarView extends ChartView {
symbolPath.style.strokeNoScale = true;
}

const dimensionIndex = data.getDimensionIndex(symbolPath.__dimIdx);
const pathEmphasisState = symbolPath.ensureState('emphasis');
pathEmphasisState.style = zrUtil.clone(itemHoverStyle);
let defaultText = data.getStore().get(data.getDimensionIndex(symbolPath.__dimIdx), idx);
let defaultText = data.getStore().get(dimensionIndex, idx);
(defaultText == null || isNaN(defaultText as number)) && (defaultText = '');

setLabelStyle(
Expand All @@ -257,6 +259,11 @@ class RadarView extends ChartView {
defaultOpacity: itemStyle.opacity
}
);

// bind additional data to eventData
getECData(symbolPath).eventData = {
dimensionIndex,
};
});

toggleHoverEmphasis(
Expand Down
2 changes: 1 addition & 1 deletion src/component/tooltip/TooltipView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ class TooltipView extends ComponentView {
return;
}

const params = dataModel.getDataParams(dataIndex, dataType);
const params = dataModel.getDataParams(dataIndex, dataType, dispatcher);
const markupStyleCreator = new TooltipMarkupStyleCreator();
// Pre-create marker style for makers. Users can assemble richText
// text in `formatter` callback and use those markers style.
Expand Down
4 changes: 2 additions & 2 deletions src/core/echarts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,8 +1073,8 @@ class ECharts extends Eventful<ECEventDefinition> {
if (isGlobalOut) {
params = {} as ECElementEvent;
}
else {
el && findEventDispatcher(el, (parent) => {
else if (el) {
findEventDispatcher(el, (parent) => {
const ecData = getECData(parent);
if (ecData && ecData.dataIndex != null) {
const dataModel = ecData.dataModel || ecModel.getSeriesByIndex(ecData.seriesIndex);
Expand Down
7 changes: 5 additions & 2 deletions src/model/mixin/dataFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import {
ComponentMainType,
ComponentSubType,
DimensionLoose,
InterpolatableValue
InterpolatableValue,
ECElement
} from '../../util/types';
import GlobalModel from '../Global';
import { TooltipMarkupBlockFragment } from '../../component/tooltip/tooltipMarkup';
Expand All @@ -57,7 +58,8 @@ export class DataFormatMixin {
*/
getDataParams(
dataIndex: number,
dataType?: SeriesDataType
dataType?: SeriesDataType,
el?: ECElement
): CallbackDataParams {

const data = this.getData(dataType);
Expand Down Expand Up @@ -88,6 +90,7 @@ export class DataFormatMixin {
color: color,
borderColor: borderColor,
dimensionNames: userOutput ? userOutput.fullDimensions : null,
dimensionIndex: el ? el.__dimIdx : null,
encode: userOutput ? userOutput.encode : null,

// Param name list for mapping `a`, `b`, `c`, `d`, `e`
Expand Down
5 changes: 5 additions & 0 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ export interface ECElement extends Element {
* Force disable morphing
*/
disableMorphing?: boolean

/**
* From RadarSymbol
*/
__dimIdx?: number;
}

export interface DataHost {
Expand Down
Loading