Hi Majeed,
Would you be OK in creating multiple Charts (first with Legend shown and second with Legend hidden) and then Show/Hide different blocks (charts in this case) by creating a condition to check if data exists or not?
Check this out:
Dynamic visibility in webi | BI HAPPY
Thanks,
Mahboob Mohammed