Reflex Logo

Intro

Gallery

Hosting

Components

New

Learn

Components

API Reference

Onboarding

Library

/

Graphing

/

Radarchart

A radar chart shows multivariate data of three or more quantitative variables mapped onto an axis.

For a radar chart we must define an rx.recharts.radar() component for each set of values we wish to plot. Each rx.recharts.radar() component has a data_key which clearly states which variable in our data we are plotting. In this simple example we plot the A column of our data against the subject column which we set as the data_key in rx.recharts.polar_angle_axis.

rx.recharts.radar_chart(
    rx.recharts.radar(
        data_key="A",
        stroke="#8884d8",
        fill="#8884d8",
    ),
    rx.recharts.polar_grid(),
    rx.recharts.polar_angle_axis(data_key="subject"),
    data=data,
)

We can also add two radars on one chart by using two rx.recharts.radar components.

rx.recharts.radar_chart(
    rx.recharts.radar(
        data_key="A",
        stroke="#8884d8",
        fill="#8884d8",
    ),
    rx.recharts.radar(
        data_key="B",
        stroke="#82ca9d",
        fill="#82ca9d",
        fill_opacity=0.6,
    ),
    rx.recharts.polar_grid(),
    rx.recharts.polar_angle_axis(data_key="subject"),
    rx.recharts.legend(),
    data=data,
)

Chart data tied to a State var causes the chart to automatically update when the state changes, providing a nice way to visualize data in response to user interface elements. View the "Data" tab to see the substate driving this radar chart of character traits.

Strength

15

Dexterity

15

Constitution

15

Intelligence

15

Wisdom

15

Charisma

15

Remaining points: 10

rx.hstack(
    rx.recharts.radar_chart(
        rx.recharts.radar(
            data_key="value",
            stroke="#8884d8",
            fill="#8884d8",
        ),
        rx.recharts.polar_grid(),
        rx.recharts.polar_angle_axis(data_key="trait"),
        data=RadarChartState.traits,
    ),
    rx.vstack(
        rx.foreach(
            RadarChartState.trait_names,
            lambda trait_name, i: rx.hstack(
                rx.text(trait_name, width="7em"),
                rx.chakra.slider(
                    value=RadarChartState.traits[i][
                        "value"
                    ].to(int),
                    on_change=lambda value: RadarChartState.set_trait(
                        trait_name, value
                    ),
                    width="25vw",
                ),
                rx.text(RadarChartState.traits[i]["value"]),
            ),
        ),
        rx.text(
            "Remaining points: ",
            RadarChartState.remaining_points,
        ),
    ),
    width="100%",
    height="15em",
)

A Radar chart component in Recharts.

PropTypeDescriptionValues
cxUnion

The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage

cyUnion

The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage

start_angleint

The angle of first radial direction line.

end_angleint

The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'.

inner_radiusUnion

The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage

outer_radiusUnion

The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage

dataList

The source data, in which each element is an object.

sync_idstr

If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush.

sync_methodLiteral

When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function

widthUnion

The width of chart container. String or Integer

heightUnion

The height of chart container.

layoutLiteral

The layout of area in the chart. 'horizontal' | 'vertical'

marginDict

The sizes of whitespace around the chart.

stack_offsetLiteral

The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette'

Valid Children

  • PolarAngleAxis
  • PolarRadiusAxis
  • PolarGrid
  • Legend
  • GraphingTooltip
  • Radar
← PlotlyReference →

Did you find this useful?

HomeGalleryChangelogIntroductionHosting