Skip to content

Commit 4135ff5

Browse files
docs: Chart options docs (#275)
* Chart options docs * removing node 10 from matrix * adding test placeholder * semantics improvement * remove size workflow * Chart additional options * clean up Chart options docs * Chart Component Props Docs * semantics
1 parent 7a1a419 commit 4135ff5

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

docs/src/pages/docs/api.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,85 @@ const data = React.useMemo(
5858

5959
The individual datums in a series' `data` array can be anything you want! Just remember that most of the types for React Charts will require you to pass the type of your `Datum`s as the first generic type to work correctly.
6060

61+
## Chart Component Props
62+
63+
The Chart component props can be passed in its `options` property object:
64+
65+
```javascript
66+
<Chart
67+
options={{
68+
data,
69+
primaryAxis,
70+
secondaryAxes,
71+
}}
72+
/>
73+
```
74+
75+
The data property should be an array of series, each series should be an array of objects.
76+
Each object should have two properties, by convention called primary and secondary, but it can be named as you want. One of these properties will be used as the primary axis and the other as the secondary axes.
77+
78+
```javascript
79+
const data = [
80+
{
81+
label: 'Series 1',
82+
data: [
83+
{
84+
primary: '2022-02-03T00:00:00.000Z',
85+
likes: 130,
86+
},
87+
{
88+
primary: '2022-03-03T00:00:00.000Z',
89+
likes: 150,
90+
},
91+
],
92+
},
93+
{
94+
label: 'Series 2',
95+
data: [
96+
{
97+
primary: '2022-04-03T00:00:00.000Z',
98+
likes: 200,
99+
},
100+
{
101+
primary: '2022-05-03T00:00:00.000Z',
102+
likes: 250,
103+
},
104+
],
105+
},
106+
]
107+
```
108+
109+
The `primaryAxis` and `secondaryAxes` options, should have a prop called getValue, which is a getter function that returns the axis value for the datum. Example:
110+
111+
```javascript
112+
const primaryAxis = React.useMemo(
113+
() => ({
114+
getValue: (datum: { primary: string }) => datum.primary,
115+
}),
116+
[]
117+
)
118+
const secondaryAxes = React.useMemo(
119+
() => [
120+
{
121+
getValue: (datum: { likes: number }) => datum.likes,
122+
elementType: 'area',
123+
},
124+
],
125+
[]
126+
)
127+
```
128+
129+
The `initialHeight` and `initialWidth` expect a number, a default value is applied for each of those, 300 and 200 respectively. It's important to mention that these options are available SSR only.
130+
If you'd like to have a custom height and width in the client side you may have a wrapper div that sets the width and height CSS attributes
131+
132+
`interactionMode` expect an string wich can be "primary" or "closest". It's been using for the tooltip position. By default, primary is being set.
133+
134+
`showVoronoi` expect a boolean, it's a debug option to visualize the interaction click-map that sits on top of the chart.
135+
136+
`getSeriesOrder` expect a function, this option will allows you to reorder the series if you want.
137+
138+
`primaryCursor` and `secundaryCursor` take the options that configure the line/rectangle that is drawn underneath your cursor when you hover over the chart. When both are used, it produces a kind of cross-hair. Both are set to true by default.
139+
61140
## Axes
62141

63142
React Charts use axes to configure a fair amount of the charts. Axes handle many things like:

0 commit comments

Comments
 (0)