- matplotlib

Pie Chart





import matplotlib.pyplot as plt def my_function(*args, **kwargs): text = Element('test-input').element.value text_2 = Element('test-input-2').element.value text_3 = Element('test-input-3').element.value input_x = text list_x = input_x.split() input_y = text_2 list_y = input_y.split() map_object_y = map(int, list_y) listofint_num = list(map_object_y) Element('test-output').element.innerText = list_x Element('test-output-1').element.innerText = listofint_num Element('test-output-2').element.innerText = text_3 fig,ax = plt.subplots() title = text_3 plt.title(title) plt.pie (listofint_num , labels = list_x, autopct='%1.1f%%') plt.axis ('equal') fig buffer = io.BytesIO() plt.savefig(buffer, format='png') buffer.seek(0) image_data = buffer.getvalue() base64_image = base64.b64encode(image_data).decode('utf-8') image_url = f'data:image/png;base64,{base64_image}' Element('quad').element.innerText = image_url