You could use the data engine api, in the beforeFactory method, to find out how many groups you're dealing with. Then, you could either build your chart from scratch or have two built and drop the unneeded one, based on your findings.

For the issue of which chart to show, you could create a bar chart with the designer as the default chart in your report. If your check of the data shows less than x groups, you could build a pie chart from scratch and drop the bar chart: