Pyramid Chart
The Blazor Pyramid Chart displays values as horizontal segments that form a pyramid. Use it to visualize stages that increase toward a goal, levels in a hierarchy, or the distribution of values across ordered categories.
Each data item creates one pyramid segment. The Chart can calculate the segment heights from the data values or render all segments with equal heights.
This article assumes you are familiar with the chart basics and data binding.
Creating a Pyramid Chart
To create a Pyramid Chart:
- Add a
ChartSeriesto theChartSeriesItemscollection. - Set its
Typeparameter toChartSeriesType.Pyramid. - Provide a model collection to the series
Dataparameter. - Set
Fieldto the model property that contains the values. - Set
CategoryFieldto the model property that contains the segment names. - (Optional) Set
ColorFieldto the model property that contains the segment colors.
The following example compares proportional and equal segment heights. The first Chart sizes each segment according to its value. The second Chart uses the same height for all segments.
Pyramid Charts with proportional and equal segment heights
Pyramid Chart Specific Appearance Settings
The Pyramid series exposes the following parameters:
| Parameter | Type | Description |
|---|---|---|
DynamicHeight | bool? | Controls whether segment heights are proportional to their values. |
SegmentSpacing | double? | Sets the spacing between adjacent segments in pixels. |
Dynamic Segment Height
Set DynamicHeight to true to make the segment height proportional to its value. Larger values create taller segments.
Set DynamicHeight to false to use equal segment heights. The segment widths still represent the pyramid shape.
Segment Spacing
Use SegmentSpacing to separate adjacent segments. The value represents the distance in pixels.
Segment Colors
To set a color for each segment, add a string property to the data model and set the series ColorField to its name. Each property value can be any valid CSS color.
Other Settings
Customize Chart Elements - Nested Tags Settings
When configuring nested properties and child elements in your chart, the inner tags will contain their parent tag name and add specifics to its end. In general the structure of such nested tags will be <Chart*Category**Specifics*> where the Category can be one of the following:
- CategoryAxis
- ChartArea
- Legend
- PlotArea
- SeriesItems
- Title
- Tooltip
- ValueAxis
- XAxes
- YAxes
- and others
To customize the chart, look for nested tags and their properties - the inner tags will contain their parent tag name and add specifics to its end. For example, the
ChartSeriestag has aChartSeriesLabelstag that exposes configuration options and more child tags.
For example, for axis-free charts you can rotate their Labels, Title, Legend and others. Example for doing so is customizing the Chart Series Labels by using the parameters in the
ChartSeriesItems > ChartSeries > ChartSeriesLabels tag and its child tags.
This approach is not limited only to the Labels - it can be used with to all tags that are applicable for the chart type, for example the Chart Title ChartTitle > ChartTitleMargin.