Skip to content
daisyBlazor

HistogramChart

Raw values counted into equal-width bins, one bar per bin, to show the shape of a single measure such as response times or deployment durations. D3 (d3.bin) picks round bin edges.
Distribution
Cover · <HistogramChart>
Histogram20 to 40: 13; 40 to 60: 73; 60 to 80: 123; 80 to 100: 132; 100 to 120: 102; 120 to 140: 62; 140 to 160: 44; 160 to 180: 23; 180 to 200: 6; 200 to 220: 12; 220 to 240: 5; 240 to 260: 3; 260 to 280: 2. Median 95.05.10020002040608010012014020 to 40: 1340 to 60: 7360 to 80: 12380 to 100: 132100 to 120: 102120 to 140: 62140 to 160: 44160 to 180: 23180 to 200: 6200 to 220: 12220 to 240: 5240 to 260: 3260 to 280: 2Median: 95.05 Median 95.05

Examples

Basic

Values takes the raw numbers; without Bins the count of bins follows Sturges' rule. Hover a bar for its range and count.

API response times, last hour
API response times, last hour20 to 40: 37; 40 to 60: 140; 60 to 80: 194; 80 to 100: 186; 100 to 120: 165; 120 to 140: 100; 140 to 160: 64; 160 to 180: 47; 180 to 200: 25; 200 to 220: 9; 220 to 240: 14; 240 to 260: 10; 260 to 280: 5; 280 to 300: 2; 300 to 320: 2.50100150200250300020406080100120140160180200Response time (ms)Requests20 to 40: 37 requests40 to 60: 140 requests60 to 80: 194 requests80 to 100: 186 requests100 to 120: 165 requests120 to 140: 100 requests140 to 160: 64 requests160 to 180: 47 requests180 to 200: 25 requests200 to 220: 9 requests220 to 240: 14 requests240 to 260: 10 requests260 to 280: 5 requests280 to 300: 2 requests300 to 320: 2 requests
website/Examples/Charts/HistogramChartBasicExample.razor Source

Bins and median

Bins asks for about that many bins (D3 rounds to tidy edges) and ShowMedian marks the median with a dashed line.

Histogram of Deployment duration (min)0.0 min to 2.0 min: 0; 2.0 min to 4.0 min: 0; 4.0 min to 6.0 min: 8; 6.0 min to 8.0 min: 32; 8.0 min to 10.0 min: 62; 10.0 min to 12.0 min: 95; 12.0 min to 14.0 min: 112; 14.0 min to 16.0 min: 81; 16.0 min to 18.0 min: 86; 18.0 min to 20.0 min: 47; 20.0 min to 22.0 min: 28; 22.0 min to 24.0 min: 19; 24.0 min to 26.0 min: 11; 26.0 min to 28.0 min: 7; 28.0 min to 30.0 min: 3; 30.0 min to 32.0 min: 6; 32.0 min to 34.0 min: 1; 34.0 min to 36.0 min: 0; 36.0 min to 38.0 min: 0; 38.0 min to 40.0 min: 0; 40.0 min to 42.0 min: 1; 42.0 min to 44.0 min: 0; 44.0 min to 46.0 min: 0; 46.0 min to 48.0 min: 0; 48.0 min to 50.0 min: 0; 50.0 min to 52.0 min: 0; 52.0 min to 54.0 min: 1; 54.0 min to 55.0 min: 0. Median 13.8 min.0510152025303540455055020406080100120Deployment duration (min)Deployments0.0 min to 2.0 min: 02.0 min to 4.0 min: 04.0 min to 6.0 min: 86.0 min to 8.0 min: 328.0 min to 10.0 min: 6210.0 min to 12.0 min: 9512.0 min to 14.0 min: 11214.0 min to 16.0 min: 8116.0 min to 18.0 min: 8618.0 min to 20.0 min: 4720.0 min to 22.0 min: 2822.0 min to 24.0 min: 1924.0 min to 26.0 min: 1126.0 min to 28.0 min: 728.0 min to 30.0 min: 330.0 min to 32.0 min: 632.0 min to 34.0 min: 134.0 min to 36.0 min: 036.0 min to 38.0 min: 038.0 min to 40.0 min: 040.0 min to 42.0 min: 142.0 min to 44.0 min: 044.0 min to 46.0 min: 046.0 min to 48.0 min: 048.0 min to 50.0 min: 050.0 min to 52.0 min: 052.0 min to 54.0 min: 154.0 min to 55.0 min: 0Median: 13.8 min Median 13.8 min
website/Examples/Charts/HistogramChartMedianExample.razor Source

Playground

API response times, last hour
API response times, last hour20 to 40: 37; 40 to 60: 140; 60 to 80: 194; 80 to 100: 186; 100 to 120: 165; 120 to 140: 100; 140 to 160: 64; 160 to 180: 47; 180 to 200: 25; 200 to 220: 9; 220 to 240: 14; 240 to 260: 10; 260 to 280: 5; 280 to 300: 2; 300 to 320: 2.50100150200250300050100150200Response time (ms)Requests20 to 40: 37 requests40 to 60: 140 requests60 to 80: 194 requests80 to 100: 186 requests100 to 120: 165 requests120 to 140: 100 requests140 to 160: 64 requests160 to 180: 47 requests180 to 200: 25 requests200 to 220: 9 requests220 to 240: 14 requests240 to 260: 10 requests260 to 280: 5 requests280 to 300: 2 requests300 to 320: 2 requests
<HistogramChart
                XTitle="Response time (ms)"
                YTitle="Requests"
                CountFormat="{0:N0} requests"
                Title="API response times, last hour"
                Values="@_responseTimes" />

@code {
    // Bins are picked by Sturges' rule unless you set Bins.
    private readonly double[] _responseTimes = DistributionSamples.Skewed(seed: 61, count: 1_000, median: 90, spread: 0.45);
}

API

<HistogramChart>

DaisyBlazor.Charts

Parameters

  • AspectRatio double
    = 1.78

    Width divided by height. The chart keeps this shape at any width; its text keeps its size.

  • Bins int
    = 0

    About how many bins to use; D3 picks round bin edges near it. 0 uses Sturges' rule.

  • Color string
    = "var(--color-primary)"

    Colour of the bars (any CSS colour).

  • CountFormat string
    = "{0:N0}"

    Format string for a bin's count in its tooltip, e.g. "{0:N0} deployments".

  • MedianLabel string
    = "Median"

    Text before the median's value on its line, in its tooltip and the description.

  • RowHeight double?
    = null

    Height of each row in px, for a chart that lays its categories out as rows (horizontal bars, a Gantt's lanes, a heatmap's rows…): its height then follows its number of rows instead of AspectRatio, so a long list keeps readable rows at any width. A chart, or an orientation, without rows ignores it.

  • ShowMedian bool
    = false

    Mark the median with a dashed line and its value.

  • ShowTitle bool
    = true

    Draw Title as a visible heading above the chart (the default); false keeps it only as the chart's accessible name, for a chart inside a card that already has a heading.

  • Title string
    = null

    Optional heading rendered above the chart; it is also the chart's accessible name.

  • ValueFormat string
    = "{0:#,0.##}"

    Format string for bin edges and the median, e.g. "{0:N0} ms".

  • Values IReadOnlyList<double>
    = []

    The raw values to count. Values that are not finite numbers are ignored.

  • Width string
    = "100%"

    CSS width of the chart wrapper.

  • XTitle string
    = null

    Title of the horizontal (value) axis.

  • YTitle string
    = "Count"

    Title of the vertical (count) axis.

  • Class string
    = null

    Additional CSS classes merged onto the w-full wrapper.

  • Style string
    = null

    Inline styles appended after the width on the wrapper.

Something went wrong while running the docs. Reload