diff -r 3f36c53aa105 -r 9eff4c62579a Admin/lib/scripts/churn_pie --- a/Admin/lib/scripts/churn_pie Wed Jan 11 22:08:20 2017 +0100 +++ b/Admin/lib/scripts/churn_pie Wed Jan 11 22:30:11 2017 +0100 @@ -1,23 +1,22 @@ -#!/usr/bin/env python +#!/usr/bin/python3 -Es import re -from pychart import theme, pie_plot, area, fill_style, arrow, legend import sys +import matplotlib.pyplot as plt +from matplotlib.backends.backend_pdf import PdfPages + +output = PdfPages('chart.pdf') re_entry = re.compile(R'^(.*\S+)\s+(\d+)\s*\**\s*$') -theme.get_options() - -data = [] +labels = [] +values = [] for line in sys.stdin.readlines(): - match = re_entry.match(unicode(line, 'utf-8')) - data.append((match.group(1), int(match.group(2)))) + match = re_entry.match(line) + labels.append(match.group(1)) + values.append(match.group(2)) -plot = pie_plot.T(data = data, arc_offsets = [], - shadow = (2, -2, fill_style.gray50), label_offset = 10, arrow_style = arrow.a3) - -ar = area.T(size = (500, 500), legend = legend.T(), x_grid_style = None, y_grid_style = None) -ar.add_plot(plot) - -ar.draw() +plt.pie(values, labels = labels) +output.savefig() +output.close()