✨ Announcing our seed funding led by Lux Capital! Read more about it on our blog
DocsBlogChangelog

Search documentation...

/

Star

12k+

[ Learn ]

[ Concepts ]

[ Reference ]

Line


Line is a wrapper component that renders a line graph.

Data


Line accepts a data prop, which is an array of dictionaries with x and y keys. You can contruct your own data array, or use the rx.data helper function to generate a data array from a x and y list.
data = rx.data(
    "line", x=[1, 2, 3, 4, 5], y=[1, 2, 3, 4, 10]
)
Which will render as:
data = [
    {"x": 1, "y": 1},
    {"x": 2, "y": 2},
    {"x": 3, "y": 3},
    {"x": 4, "y": 4},
    {"x": 5, "y": 10},
]

Examples


The following example shows a rx.line component.
1.02.03.04.05.024681012
rx.chart(
    rx.line(
        data=rx.data(
            "line", x=[1, 2, 3, 4, 5], y=[1, 2, 3, 4, 10]
        ),
    ),
    rx.line(
        data=rx.data(
            "line", x=[1, 2, 3, 4, 5], y=[5, 12, 4, 6, 1]
        ),
    ),
)
Line also accepts a style prop, which is an object of style properties. Additionally you can specify the interpolation prop, which determines how data points should be connected when creating a path.
1.02.03.04.05.024681012
rx.chart(
    rx.line(
        data=rx.data(
            "line", x=[1, 2, 3, 4, 5], y=[1, 2, 3, 4, 10]
        ),
    ),
    rx.line(
        data=rx.data(
            "line", x=[1, 2, 3, 4, 5], y=[5, 12, 4, 6, 1]
        ),
        interpolation="natural",
        style={"data": {"stroke": "red"}},
    ),
    domain_padding={"x": 0, "y": 3},
)

Line


Display a victory line.


  • Base Event Triggers

← ErrorBarBar →

Copyright © 2023 Pynecone, Inc.