A histogram is a chart that displays data distribution, using bars to represent the frequency of data points within a certain range. The height (or length) of each bar represents the number of data points falling within a specific interval, the X-axis represents the range of data values, and the Y-axis represents the frequency or count. Histograms are primarily used to represent the distribution of continuous variables and help analyze the central tendency, dispersion, and shape of data. The difference between a histogram and a bar chart: a histogram reflects data distribution, while a bar chart only compares values. In terms of data structure, a bar chart requires a categorical variable that is discrete (e.g., Class 1, Class 2, Class 3), so there are gaps between bars. But histogram data consists of continuous numerical variables (e.g., scores), so there are no gaps between bars.
Distribution of 200 students exam scores (normal distribution)
Product weight distribution (150 samples), custom colors
Bimodal distribution data, custom colors
| Property | Type | Required | Description |
|---|---|---|---|
| type | string | required | Value must be "histogram". |
| data | number[] | required | Chart data. |
| binNumber | number | optional | Number of bins in the histogram. |
| title | string | optional | Chart title. |
| axisXTitle | string | optional | X-axis title. |
| axisYTitle | string | optional | Y-axis title. |
| theme | 'default' | 'dark' | 'academy' | optional | Chart theme, default is "default". |
| style | Object | optional | Chart style. |
| style.backgroundColor | string | optional | Must be a valid color value. |
| style.palette | string[] | optional | Must be an array of valid color values. |