Pie chart#
Inspired from this Highcharts demo
import easychart
labels = ["O", "A", "B", "AB"]
values = [45, 40, 11, 4]
chart = easychart.new("pie", title="Distribution of blood type in the US")
chart.subtitle = "Source: American Red Cross"
chart.tooltip = "{point.percentage:.0f}%"
chart.plot([{"name": label, "y": value} for label, value in zip(labels, values)])
chart
With data labels#
import easychart
labels = ["O", "A", "B", "AB"]
values = [45, 40, 11, 4]
chart = easychart.new("pie", title="Distribution of blood type in the US")
chart.subtitle = "Source: American Red Cross"
chart.tooltip = "{point.percentage:.0f}%"
chart.plot(values, index=labels, labels="{point.name} ({point.y}%)")
chart
With slice#
import easychart
data = [
{"name": "Chrome", "y": 61.41, "sliced": True},
{"name": "Internet Explorer", "y": 11.84},
{"name": "Firefox", "y": 10.85},
{"name": "Edge", "y": 4.67},
{"name": "Safari", "y": 4.18},
{"name": "Other", "y": 7.05},
]
chart = easychart.new("pie")
chart.title = "Browser market shares in January, 2018"
chart.tooltip = "{point.name}: <b>{point.percentage:.1f}%</b>"
chart.plot(data, name="browser")
With pandas Series#
import easychart
import pandas as pd
data = pd.Series([45, 40, 11, 4], index=["O", "A", "B", "AB"])
chart = easychart.new("pie", title="Distribution of blood type in the US")
chart.subtitle = "Source: American Red Cross"
chart.tooltip = "{point.percentage:.0f}%"
chart.plot(data)
chart