diff --git a/packages/core/src/components/cartesian/markers/CartesianMarkersItem.js b/packages/core/src/components/cartesian/markers/CartesianMarkersItem.js
index 18cd34c3e..a45ea9bbd 100644
--- a/packages/core/src/components/cartesian/markers/CartesianMarkersItem.js
+++ b/packages/core/src/components/cartesian/markers/CartesianMarkersItem.js
@@ -171,6 +171,7 @@ const CartesianMarkersItem = ({
lineStyle,
textStyle,
legend,
+ legendNode,
legendPosition = 'top-right',
legendOffsetX = 14,
legendOffsetY = 14,
@@ -191,8 +192,7 @@ const CartesianMarkersItem = ({
y2 = height
}
- let legendNode = null
- if (legend) {
+ if (legend && !legendNode) {
const legendProps = computeLabel({
axis,
width,
diff --git a/packages/line/tests/Line.test.js b/packages/line/tests/Line.test.js
index b6c133d7a..49af2d27b 100644
--- a/packages/line/tests/Line.test.js
+++ b/packages/line/tests/Line.test.js
@@ -292,6 +292,43 @@ it('should call the custom label callback for each point', () => {
}
})
+it('should display a custom legendNode for marker', () => {
+ const data = [
+ {
+ id: 'A',
+ data: [
+ { x: 0, y: 3 },
+ { x: 1, y: 7 },
+ { x: 2, y: 11 },
+ { x: 3, y: 9 },
+ { x: 4, y: 8 },
+ ],
+ },
+ ]
+ const markers = [
+ {
+ axis: 'x',
+ lineStyle: {
+ stroke: 'lightblue',
+ strokeWidth: 5,
+ },
+ legendPosition: 'top',
+ legendNode: (
+