1

I am using Highchrt and i want click on lengend on load.

I am using angular ionic so how can i click .highcharts-legend-item class in ngOnInit() {} function.

I want click tthis class on page is load with angular ionic.

In javascript $(.highcharts-legend-item).click(); but i dont knw in anular ionic.

The edit

1 Answer 1

2

If you're using Ionic, you're still in a browser, so you can use the standard html-js API.

Pure JavaScript Approach

document.querySelector('.highcharts-legend-item').click()

Angular Approach

Use ElementRef and click the element programmatically

ts:

 constructor(private elem: ElementRef){}

 ngAfterViewInit(){
    this.elem.nativeElement.querySelector('.highcharts-legend-item').click();
 }
Sign up to request clarification or add additional context in comments.

3 Comments

Viewchild is not a solution for this scenario. highcharts-legend-item is not created by user. It is part of highcharts graph library @Marcell Kiss
im using class not id .highcharts-legend-item' is a class. default from highchart i cannt edit this so.
I see, I corrected my answer according to your feedback. You can still use ElementRef if you wanna go the Angular way

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.