Skip to content
daisyBlazor

ShapeChart

Polygons and polylines given in data coordinates on shared X and Y axes: a floor plan, a site map, zones on a diagram. Closed shapes are filled (an inner ring is a hole), open ones are drawn as lines; shapes of the same Group share a colour and a legend entry.
Specialised
Cover · <ShapeChart>
Shape chartFull: Rack A1, Rack A4, Rack A7; Partial: Rack A2, Rack A3, Rack A5, Rack A6, Rack A8; Fibre run: Fibre run 02412345Rack A1 (Full)Rack A2 (Partial)Rack A3 (Partial)Rack A4 (Full)Rack A5 (Partial)Rack A6 (Partial)Rack A7 (Full)Rack A8 (Partial)Fibre run

Examples

Basic

Each ChartShape has a Name, its Rings of ShapePoint and an optional Group, here the rack's occupancy. KeepAspect makes a metre as long across as up.

Hall B, rack occupancy
Hall B, rack occupancyFull: Rack A1, Rack A2, Rack A4, Rack B2, Rack B6; Over 50%: Rack A3, Rack A6, Rack B3; Under 50%: Rack A5, Rack B4; Empty: Rack B1, Rack B5 012345671.01.52.02.53.03.54.04.55.0MetresMetresRack A1 (Full)Rack A2 (Full)Rack A3 (Over 50%)Rack A4 (Full)Rack A5 (Under 50%)Rack A6 (Over 50%)Rack B1 (Empty)Rack B2 (Full)Rack B3 (Over 50%)Rack B4 (Under 50%)Rack B5 (Empty)Rack B6 (Full)
Full Over 50% Under 50% Empty
website/Examples/Charts/ShapeChartBasicExample.razor Source

Holes and polylines

A second ring inside a closed shape cuts a hole; Closed: false draws each ring as an open line, such as a cable run. Color takes any CSS colour and ShowGrid="false" hides the grid.

Hall B, cages and cable runs
Hall B, cages and cable runsCustomer cage: Cage 1, Cage 2; Meet-me room: Meet-me room; Fibre: Fibre run 1, Fibre run 2; Power: Power feed 0246810121416−10123456MetresCage 1 (Customer cage)Cage 2 (Customer cage)Meet-me roomFibre run 1 (Fibre)Fibre run 2 (Fibre)Power feed (Power)
Customer cage Meet-me room Fibre Power
website/Examples/Charts/ShapeChartCablesExample.razor Source

Playground

Hall B, rack occupancy
Hall B, rack occupancyFull: Rack A1, Rack A2, Rack A4, Rack B2, Rack B6; Over 50%: Rack A3, Rack A6, Rack B3; Under 50%: Rack A5, Rack B4; Empty: Rack B1, Rack B5 012345671.01.52.02.53.03.54.04.55.0MetresMetresRack A1 (Full)Rack A2 (Full)Rack A3 (Over 50%)Rack A4 (Full)Rack A5 (Under 50%)Rack A6 (Over 50%)Rack B1 (Empty)Rack B2 (Full)Rack B3 (Over 50%)Rack B4 (Under 50%)Rack B5 (Empty)Rack B6 (Full)
Full Over 50% Under 50% Empty
<ShapeChart
            KeepAspect="true"
            XTitle="Metres"
            YTitle="Metres"
            Title="Hall B, rack occupancy"
            Shapes="@_racks" />

@code {
    // Two rows of racks (0.6 m × 1.2 m) facing a cold aisle; each rack is a polygon, coloured by occupancy.
    private readonly ChartShape[] _racks = Build();

    private static ChartShape[] Build()
    {
        string[] occupancy = ["Full", "Full", "Over 50%", "Full", "Under 50%", "Over 50%", "Empty", "Full", "Over 50%", "Under 50%", "Empty", "Full"];
        List<ChartShape> racks = [];
        for (int i = 0; i < 12; i++)
        {
            int row = i / 6;
            double x = 1 + (i % 6) * 0.8;
            double y = row == 0 ? 1 : 3.6;
            racks.Add(new ChartShape($"Rack {(row == 0 ? 'A' : 'B')}{i % 6 + 1}", [Rect(x, y, 0.6, 1.2)], Group: occupancy[i], Color: _colors[occupancy[i]]));
        }

        return [.. racks];
    }

    private static readonly Dictionary<string, string> _colors = new()
    {
        ["Full"] = "var(--color-error)",
        ["Over 50%"] = "var(--color-warning)",
        ["Under 50%"] = "var(--color-info)",
        ["Empty"] = "var(--color-success)",
    };

    private static ShapePoint[] Rect(double x, double y, double w, double h) => [new(x, y), new(x + w, y), new(x + w, y + h), new(x, y + h)];
}

API

<ShapeChart>

DaisyBlazor.Charts

Parameters

  • AspectRatio double
    = 1.78

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

  • KeepAspect bool
    = false

    Keep one unit as long across as up (widening one axis), so shapes are not stretched.

  • 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.

  • Shapes IReadOnlyList<ChartShape>
    = []

    The polygons and polylines to draw, back to front.

  • ShowGrid bool
    = true

    Draw grid lines across the plot at the ticks.

  • ShowLegend bool
    = true

    Show a legend when there is more than one group (or ungrouped shape).

  • 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.

  • Width string
    = "100%"

    CSS width of the chart wrapper.

  • XTitle string
    = null

    Title of the horizontal axis.

  • YTitle string
    = null

    Title of the vertical 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