Articles in this section
Category / Section

How to Add Images to Each Data Point in Angular Chart Component?

2 mins read

This article demonstrates how to add custom images to individual data points in the Angular Chart component. This approach is useful when you want to visually represent different states or categories using icons or images instead of standard shapes.

To achieve this, you need to:

Code Example

app.component.html

<ejs-chart
   (pointRender)="pointRender($event)"
 >
   <e-series-collection>
     <e-series
       [dataSource]="data"
       type="Line"
       xName="Period"
       yName="Banana_ProductionRate"
       width="2"
       [marker]="marker"
       opacity="1"
     >
     </e-series>
   </e-series-collection>
 </ejs-chart> 

app.component.ts

//Initializing Marker
 public marker: Object = {
   visible: true,
   shape: 'Image',
   imageUrl: './assets/sad.png',
   width: 40,
   height: 40,
 };

 public width: string = Browser.isDevice ? '100%' : '75%';
 public pointRender = (args: IPointEventArgs) => {
   if(args.point.index === 0) {
     args.point.marker.imageUrl = './assets/happy.png';
   }
   else if(args.point.index === 1) {
     args.point.marker.imageUrl = './assets/neutral.png';
   }
   else if(args.point.index === 2) {
     args.point.marker.imageUrl = './assets/sad.png';
   }
 } 

Output

image.png

Sample

Download a runnable sample

Conclusion

I hope you enjoyed learning about how to add images to each data point in Angular Chart component.

You can refer to our Angular Chart’s feature tour page to learn about its other groundbreaking feature representations. You can also explore our Angular Chart Documentation to understand how to present and manipulate data.

For current customers, you can check out our Angular components on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to explore our Angular Chart and other Angular 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!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied