0

I am Using d3 heatmap with angular newer version in 14. i don't know how to use this keyword in my project.

    .attr('opacity', function(event:any): any {
        
         const myItem: any = this;
         const matchingSelected = myItem.className.baseVal
         .split(' ')
         .filter((f: any) => legendSelected.indexOf(f) > -1);
         return matchingSelected.length === 0 ? 0 : 1;
     });
Subash
  • 1
  • 2
  • I don't know what your 'this' really is, but in case it's an Element, you can make a function signature like this: `function(this: Element, event:any)` – qrsngky Aug 04 '22 at 05:59
  • typescript is warning you that myItem is typed with any. Consider adding a proper type or disable your tslint any check: noImplicitAny to false in tsconfig.json – jo-chris Aug 04 '22 at 05:59
  • Judging from the usage, I am guessing that the types can be specified better, like `function(this: SVGElement, event: Event): number { ... ` and `((f: string) => ...` – qrsngky Aug 04 '22 at 06:02

0 Answers0