return clist if __name__ == "__main__": at = AnnualTemperature() data = at.openfile('lab1\Temperature.html') dt = Database() dt.createTable() for items in data: if len(items) > 0 and int(items[0]) > 1959 and int(items[0]) < 2019): print(items) # dt.create(items[0],items[2]) graph = Graph() data = dt.get_all() x = [] y = [] for row in data: x.append(row[0]) y.append(row[1]) graph.thread_read(x, y) dt.delete_all_rows()
country = [] explode = (0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0) for cntry, pnt in data.items(): if count < 10 and cntry != "European Union": percentage.append(pnt) country.append(cntry) count += 1 plt.pie( percentage, labels=country, wedgeprops={'edgecolor': 'white'}, # autopct=lambda percentage: f'{percentage:.2f}%', autopct='%1.1f%%', shadow=True, explode=explode ) plt.title("Top 10 Country by C02 Emission In 2017") plt.axis('equal') plt.show() if __name__ == '__main__': graph = PieChart() graph.send_data() database = Database() data = graph.get_data() final_sort = dict(sorted(data.items(), key=lambda item: item[1], reverse=True)) graph.pie_chart(final_sort) database.delete_all_rows()