Hi kalpanas_techcedence!
Welcome to our forum and thanks for contacting us with your question!
Unfortunatelly, I am not sure, what do you want to show by this chart, so it is hard to suggest to you something clear. What I have found is that the issue is related to your function
adjustChartSize(), which is changing the chart height to be a higher value, than the container's height, which is not a proper way of hiding the legend. It is better to not use
chart.marginBottom and use
legend.enabled to show/hide legend instead of making chart height bigger to hide legend.
Demo: https://jsfiddle.net/BlackLabel/ofqbuxj5/
Regards!