how to call shortcode from php

In a custom template file, I need to call an affiliates shortcode if a condition is met:

if(some condition) echo do_shortcode('[affiliatestatschart]');

iow. I using the basic WordPress approach, but it does not work.

The white box for the chart is drawn, but the chart is not drawn.

How can I use affiliates shortcodes within a php page ?

( The chart is drawn correctly if I just add [affiliatestatschart]
to a post page in wp_admin. )