Skip to content
View as Markdown

Chart

class Chart(BaseModel)

Represents a chart with metadata from matplotlib.

Attributes:

  • type ChartType - The type of chart
  • title str - The title of the chart
  • elements list[Any] - The elements of the chart
  • png str | None - The PNG representation of the chart encoded in base64

Chart.to_dict

def to_dict() -> dict[str, Any]

Return the metadata dictionary used to create the chart.

ChartType

class ChartType(str, Enum)

Chart types

Enum Members:

  • LINE (“line”)
  • SCATTER (“scatter”)
  • BAR (“bar”)
  • PIE (“pie”)
  • BOX_AND_WHISKER (“box_and_whisker”)
  • COMPOSITE_CHART (“composite_chart”)
  • UNKNOWN (“unknown”)

Chart2D

class Chart2D(Chart)

Represents a 2D chart with metadata.

Attributes:

  • x_label str | None - The label of the x-axis
  • y_label str | None - The label of the y-axis

PointData

class PointData(BaseModel)

Represents a point in a 2D chart.

Attributes:

  • label str - The label of the point
  • points list[tuple[str | float, str | float]] - The points of the chart

PointChart

class PointChart(Chart2D)

Represents a point chart with metadata.

Attributes:

  • x_ticks list[str | float] - The ticks of the x-axis
  • x_tick_labels list[str] - The labels of the x-axis
  • x_scale str - The scale of the x-axis
  • y_ticks list[str | float] - The ticks of the y-axis
  • y_tick_labels list[str] - The labels of the y-axis
  • y_scale str - The scale of the y-axis
  • elements list[PointData] - The points of the chart

LineChart

class LineChart(PointChart)

Represents a line chart with metadata.

Attributes:

  • type ChartType - The type of chart

ScatterChart

class ScatterChart(PointChart)

Represents a scatter chart with metadata.

Attributes:

  • type ChartType - The type of chart

BarData

class BarData(BaseModel)

Represents a bar in a bar chart.

Attributes:

  • label str - The label of the bar
  • group str - The group of the bar
  • value str - The value of the bar

BarChart

class BarChart(Chart2D)

Represents a bar chart with metadata.

Attributes:

  • type ChartType - The type of chart
  • elements list[BarData] - The bars of the chart

PieData

class PieData(BaseModel)

Represents a pie slice in a pie chart.

Attributes:

  • label str - The label of the pie slice
  • angle float - The angle of the pie slice
  • radius float - The radius of the pie slice
  • autopct str | float - The autopct value of the pie slice

PieChart

class PieChart(Chart)

Represents a pie chart with metadata.

Attributes:

  • type ChartType - The type of chart
  • elements list[PieData] - The pie slices of the chart

BoxAndWhiskerData

class BoxAndWhiskerData(BaseModel)

Represents a box and whisker in a box and whisker chart.

Attributes:

  • label str - The label of the box and whisker
  • min float - The minimum value of the box and whisker
  • first_quartile float - The first quartile of the box and whisker
  • median float - The median of the box and whisker
  • third_quartile float - The third quartile of the box and whisker
  • max float - The maximum value of the box and whisker
  • outliers list[float] - The outliers of the box and whisker

BoxAndWhiskerChart

class BoxAndWhiskerChart(Chart2D)

Represents a box and whisker chart with metadata.

Attributes:

  • type ChartType - The type of chart
  • elements list[BoxAndWhiskerData] - The box and whiskers of the chart

CompositeChart

class CompositeChart(Chart)

Represents a composite chart with metadata. A composite chart is a chart that contains multiple charts (subplots).

Attributes:

  • type ChartType - The type of chart
  • elements list[Chart] - The charts (subplots) of the composite chart