, [axisId, axisProps]: [string, BaseAxisProps]) => {
return { ...res, [axisId]: (axisProps as BaseAxisProps).scale };
},
{},
)
: null;
}
public getXScaleByAxisId(axisId: string) {
return this.state.xAxisMap?.[axisId]?.scale;
}
public getYScaleByAxisId(axisId: string) {
return this.state.yAxisMap?.[axisId]?.scale;
}
public getItemByXY(chartXY: { x: number; y: number }) {
const { formattedGraphicalItems } = this.state;
if (formattedGraphicalItems && formattedGraphicalItems.length) {
for (let i = 0, len = formattedGraphicalItems.length; i < len; i++) {
const graphicalItem = formattedGraphicalItems[i];
const { props, item } = graphicalItem;
const itemDisplayName = getDisplayName(item.type);
if (itemDisplayName === 'Bar') {
const activeBarItem = (props.data || []).find(
(entry: { x: number; y: number; width: number; height: number }) => {
return isInRectangle(chartXY, entry);
},
);
if (activeBarItem) {
return { graphicalItem, payload: activeBarItem };
}
} else if (itemDisplayName === 'RadialBar') {
const activeBarItem = (props.data || []).find((entry: GeometrySector) => {
return inRangeOfSector(chartXY, entry);
});
if (activeBarItem) {
return { graphicalItem, payload: activeBarItem };
}
}
}
}
return null;
}
render() {
if (!validateWidthHeight(this)) {
return null;
}
const { children, className, width, height, style, compact, title, desc, ...others } = this.props;
const attrs = filterProps(others);
const map = {
CartesianGrid: { handler: this.renderGrid, once: true },
ReferenceArea: { handler: this.renderReferenceElement },
ReferenceLine: { handler: this.renderReferenceElement },
ReferenceDot: { handler: this.renderReferenceElement },
XAxis: { handler: this.renderXAxis },
YAxis: { handler: this.renderYAxis },
Brush: { handler: this.renderBrush, once: true },
Bar: { handler: this.renderGraphicChild },
Line: { handler: this.renderGraphicChild },
Area: { handler: this.renderGraphicChild },
Radar: { handler: this.renderGraphicChild },
RadialBar: { handler: this.renderGraphicChild },
Scatter: { handler: this.renderGraphicChild },
Pie: { handler: this.renderGraphicChild },
Funnel: { handler: this.renderGraphicChild },
Tooltip: { handler: this.renderCursor, once: true },
PolarGrid: { handler: this.renderPolarGrid, once: true },
PolarAngleAxis: { handler: this.renderPolarAxis },
PolarRadiusAxis: { handler: this.renderPolarAxis },
Customized: { handler: this.renderCustomized },
} as any;
// The "compact" mode is mainly used as the panorama within Brush
if (compact) {
return (
{this.renderClipPath()}
{renderByOrder(children, map)}
);
}
const events = this.parseEventsOfWrapper();
return (
{
this.container = node;
}}
>
{this.renderClipPath()}
{renderByOrder(children, map)}
{this.renderLegend()}
{this.renderTooltip()}
);
}
};
};