How to Highlight a Marker in Multicolored Line Series in React Chart?
This article demonstrates how to selectively display a single marker in a multicolored line chart using React Charts. You can use the pointRender event to cancel rendering for all points except the one you want to highlight. In the sample below, the specific point is highlighted when args.point.index equals 20, and a fill color is applied. All other points are hidden by cancelling the point render event.
Code Example
const pointRender = (args) => {
if (args.point.index === 20) {
args.fill = 'red';
} else {
args.cancel = true;
}
};
return (
<div className="control-pane">
<ChartComponent
id="charts"
pointRender={pointRender}
>
<SeriesCollectionDirective>
<SeriesDirective
dataSource={chartValues}
xName="XValue"
width={2}
yName="YValue"
name="Risks"
type="MultiColoredLine"
segmentAxis="Y"
marker={{ visible: true, width: 15, height: 15 }}
>
<SegmentsDirective>
<SegmentDirective value={35} color="green"></SegmentDirective>
<SegmentDirective value={45} color="orange"></SegmentDirective>
<SegmentDirective color="red"></SegmentDirective>
</SegmentsDirective>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
</div>
);
Output
Live Sample
Conclusion
I hope you enjoyed learning about how to highlight a marker in multicolored line series in React Chart.
You can refer to our React Chart’s feature tour page to learn about its other groundbreaking feature representations. You can also explore our React Chart Documentation to understand how to present and manipulate data.
For current customers, you can check out our React components on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to explore our React Chart and other React components.
If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our support forums, Direct-Trac or feedback portal, or the feedback portal. We are always happy to assist you!