Charts API
ww.chart()
ww.chart(
data=None,
type="bar",
labels=None,
title=None,
options=None,
datasets=None,
x=None,
y=None,
) -> ChartHandle
- data
- List of numbers, list-of-lists, dict, or pandas DataFrame.
- type : str
- Chart type:
"bar","line","pie","doughnut","radar","scatter","bubble","polarArea". - labels : list[str] | None
- X-axis labels.
- title : str | None
- Chart title.
- options : dict | None
- Raw Chart.js options object.
- datasets : list[dict] | None
- Multiple dataset definitions. Each dict has
"label"and"data"keys. - x : str | None
- Column name for x-axis (when data is a dict or DataFrame).
- y : str | list | None
- Column name(s) for y-axis.
Returns a ChartHandle with:
.update(data)— replace chart data
Examples
# Simple bar chart
ww.chart([10, 20, 30], type="bar", labels=["A", "B", "C"])
# Line chart with title
ww.chart([5, 10, 8, 15], type="line", labels=["W1", "W2", "W3", "W4"], title="Trend")
# Pie chart
ww.chart([40, 30, 20, 10], type="pie", labels=["Chrome", "Firefox", "Safari", "Edge"])
# Multiple datasets
ww.chart(
datasets=[
{"label": "2024", "data": [10, 20, 30]},
{"label": "2025", "data": [15, 25, 35]},
],
type="bar",
labels=["Q1", "Q2", "Q3"],
)
ww.plot()
ww.plot(
data,
x=None,
y=None,
type="line",
color=None,
title=None,
) -> ChartHandle
- data
- Dict or pandas DataFrame with column data.
- x : str | None
- Column for x-axis.
- y : str | list | None
- Column(s) for y-axis.
- type : str
- Chart type. Default
"line". - color : str | None
- Line/bar color.
- title : str | None
- Chart title.
Example
data = {
"month": ["Jan", "Feb", "Mar"],
"revenue": [100, 150, 130],
"costs": [80, 90, 85],
}
ww.plot(data, x="month", y=["revenue", "costs"], type="line", title="Financials")