Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 2.22 KB

File metadata and controls

51 lines (40 loc) · 2.22 KB

Histogram (type: "histogram")

The distribution of one numeric column, binned into equal-width bars.

Class: dl2_reports.Histogram · Legacy helper: row.add_histogram(...) · Example: 11_histogram.py

Quick start

from dl2_reports import Histogram

page.add_row(
    Histogram("survey", column="Score", bins=20,
              show_labels=True, x_axis_label="Score", y_axis_label="Count"),
)

Parameters

Parameter Type Description
dataset_id str Required. Dataset id (or a formula datasource).
column str | int Numeric column to bin.
bins int Number of bins (viewer default 10).
color str Bar color (viewer default #69b3a2).
show_labels bool Show count labels on top of bars.
x_axis_label / y_axis_label str Axis labels.
enable_export bool (dl2 0.5+) Right-click Export PNG / Export SVG image export (viewer default True).
export_file_name str (dl2 0.5+) Base file name for exported images, no extension (viewer falls back to title → dataset id → chart type).
context_menu bool (dl2 0.5+) Right-click context menu (viewer default True).
extra dict Passthrough props.
**common Common visual properties.

Notes

  • Binning happens in the browser from the raw values — no need to pre-bucket in pandas.
  • Trend annotations render on histograms (dl2 0.4.1+) in real axis units, but .add_trend() cannot auto-calculate here (the Y values are binned counts, not a column) — pass explicit coefficients. See Annotations.
  • Use a filter= or formula datasource (Histogram("survey[Score > 0]", column="Score")) to exclude outliers or sentinel values before binning.

Related

  • Box plot — quartile summary, better for comparing groups.
  • Bar — categorical counts you computed yourself.
  • Chart image export — PNG/SVG export details (dl2 0.5+).