protecting updateLegend call based on legend:show config to avoid js error.