Skip to content

Commit 94d3dae

Browse files
committed
Feature - Need to show custom tooltip only for actual index
1 parent f6ebee9 commit 94d3dae

File tree

3 files changed

+146
-2
lines changed

3 files changed

+146
-2
lines changed

src/chart/radar/RadarSeries.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
import GlobalModel from '../../model/Global';
3939
import SeriesData from '../../data/SeriesData';
4040
import Radar from '../../coord/radar/Radar';
41+
import IndicatorAxis from '../../coord/radar/IndicatorAxis';
4142
import {
4243
createTooltipMarkup, retrieveVisualColorForTooltipMarker
4344
} from '../../component/tooltip/tooltipMarkup';
@@ -71,6 +72,10 @@ export interface RadarSeriesOption
7172

7273
data?: (RadarSeriesDataItemOption | RadarSeriesDataValue)[]
7374
}
75+
export interface RadarCallbackDataParams extends CallbackDataParams {
76+
indicatorIndex: number,
77+
indicatorAxes: Array<IndicatorAxis>
78+
}
7479

7580
class RadarSeriesModel extends SeriesModel<RadarSeriesOption> {
7681

@@ -102,6 +107,17 @@ class RadarSeriesModel extends SeriesModel<RadarSeriesOption> {
102107
});
103108
}
104109

110+
/**
111+
* @overwrite
112+
*/
113+
getDataParams(dataIndex: number, dataType: any, el?: Element): RadarCallbackDataParams {
114+
const params = super.getDataParams(dataIndex) as RadarCallbackDataParams;
115+
// indicatorIndex && indicatorAxes
116+
params.indicatorIndex = (el && (el as any).__dimIdx) ?? null;
117+
params.indicatorAxes = this.coordinateSystem.getIndicatorAxes();
118+
return params;
119+
}
120+
105121
formatTooltip(
106122
dataIndex: number,
107123
multipleSeries?: boolean,

src/component/tooltip/TooltipView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,8 @@ class TooltipView extends ComponentView {
673673
if (tooltipTrigger != null && tooltipTrigger !== 'item') {
674674
return;
675675
}
676-
677-
const params = dataModel.getDataParams(dataIndex, dataType);
676+
const el = e.target;
677+
const params = dataModel.getDataParams(dataIndex, dataType, el);
678678
const markupStyleCreator = new TooltipMarkupStyleCreator();
679679
// Pre-create marker style for makers. Users can assemble richText
680680
// text in `formatter` callback and use those markers style.

test/radar-axis-indicatorIndex.html

Lines changed: 128 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)