Fix analysis calculations and add labels to pie chart