Series
<Line> Section titled <Line>
import { Chart, Line } from 'solid-charts'
import { curveNatural } from 'solid-charts/curves'
const values = [0, 3, 2, 5, 3, 6, 2]
const data = values.map((value, index) => ({
xAxis: `Day ${index + 1}`,
value,
}))
const LineChart = () => {
return (
<div class="h-62.5 text-sm w-125 m-6">
<Chart data={data}>
<Line
curve={curveNatural}
dataKey="value"
class="stroke-sc-400"
stroke-linecap="round"
stroke-width={6}
/>
</Chart>
</div>
)
}
export default LineChart
<Area> Section titled <Area>
import { Area, Chart } from 'solid-charts'
import { curveNatural } from 'solid-charts/curves'
const values = [0, 3, 2, 5, 3, 6, 2]
const data = values.map((value, index) => ({
xAxis: `Day ${index + 1}`,
value,
}))
const AreaChart = () => {
return (
<div class="h-62.5 text-sm w-125 m-6">
<Chart data={data}>
<Area curve={curveNatural} dataKey="value" class="text-sc-400" />
</Chart>
</div>
)
}
export default AreaChart
<Point> Section titled <Point>
The point series is used to render <circle>
elements representing the values in the chart. Is often used in combination with the Line
or Area
series to highlight the data points on the chart.
import { Chart, Point } from 'solid-charts'
const values = [0, 3, 2, 5, 3, 6, 2]
const data = values.map((value, index) => ({
xAxis: `Day ${index + 1}`,
value,
}))
const PointChart = () => {
return (
<div class="h-62.5 text-sm w-125 m-6">
<Chart data={data}>
<Point dataKey="value" r={8} class="text-sc-400" />
</Chart>
</div>
)
}
export default PointChart
activeProps Section titled activeProps
The point series accepts the activeProps
object to customize the appearance of the currently active <circle>
element. This allows you to do things like animating the radius of an active point:
import { Axis, AxisCursor, AxisGrid, Chart, Point } from 'solid-charts'
const values = [1, 3, 2, 5, 3, 6, 2]
const ActivePointChart = () => {
return (
<div class="h-37.5 w-75">
<Chart data={values} inset={12}>
{/* // ... code truncated */}
<Point
r={4}
class="text-sc-400 transition-all"
activeProps={{ r: 10 }}
/>
</Chart>
</div>
)
}
export default ActivePointChart
Hover over the chart:
<Bar> Section titled <Bar>
import { Bar, Chart } from 'solid-charts'
const values = [0, 3, 2, 5, 3, 6, 2]
const data = values.map((value, index) => ({
xAxis: `Day ${index + 1}`,
value,
}))
const BarChart = () => {
return (
<div class="h-62.5 text-sm w-125 m-6">
<Chart data={data}>
<Bar dataKey="value" class="text-sc-400" />
</Chart>
</div>
)
}
export default BarChart
barConfig Section titled barConfig
For the bar series there is a global barConfig
object on the <Chart>
component that lets you modify the way multiple bar series are rendere together. It’s used to define values like the space between bars or their width. Have a look at the BarConfig
type in the Chart API reference.
API Reference Section titled API Reference
Line series component.
Props
Property | Default | Type/Description |
---|---|---|
dataKey | - | string The key in the data object used to render the line series. Don't provide a key if the data is a simple array of numbers. |
axisId | '0' | string The id of the y axis to use for the line series. |
stackId | - | string The id of the stack to use for the line series. |
curve | - | CurveFactory The curve function used to render the line series path. |
connectNulls | - | boolean Whether to connect null values in the line series path. |
Data attributes
Data attributes present on <Line />
components.
Property | Description |
---|---|
data-sc-line | Present on every line path element. |
Area series component.
Props
Property | Default | Type/Description |
---|---|---|
dataKey | - | string The key in the data object used to render the area series. Don't provide a key if the data is a simple array of numbers. |
axisId | '0' | string The id of the y axis to use for the area series. |
stackId | - | string The id of the stack to use for the area series. |
curve | - | CurveFactory The curve function used to render the area series path. |
connectNulls | - | boolean Whether to connect null values in the area series path. |
Data attributes
Data attributes present on <Area />
components.
Property | Description |
---|---|
data-sc-area | Present on every area path element. |
Point series component.
Props
Property | Default | Type/Description |
---|---|---|
dataKey | - | string The key in the data object used to render the point series. Don't provide a key if the data is a simple array of numbers. |
axisId | '0' | string The id of the y axis to use for the point series. |
stackId | - | string The id of the stack to use for the point series. |
activeProps | - | Omit<ComponentProps<'circle'>, 'cx' | 'cy'> <circle> element props to apply when the point is active. |
Data attributes
Data attributes present on <Point />
components.
Property | Description |
---|---|
data-sc-point-group | Present on every point group element. |
data-sc-point | Present on every point circle element. |
Bar series component.
Props
Property | Default | Type/Description |
---|---|---|
dataKey | - | string The key in the data object used to render the bar series. Don't provide a key if the data is a simple array of numbers. |
axisId | '0' | string The id of the y axis to use for the bar series. |
stackId | - | string The id of the stack to use for the bar series. |
Data attributes
Data attributes present on <Bar />
components.
Property | Description |
---|---|
data-sc-bar-group | Present on every bar group element. |
data-sc-bar | Present on every bar rect element. |
v0.0.1
Developed and designed by Jasmin