You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/pages/docs/api.md
+79Lines changed: 79 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,85 @@ const data = React.useMemo(
58
58
59
59
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.
60
60
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
+
constdata= [
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:
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
+
61
140
## Axes
62
141
63
142
React Charts use axes to configure a fair amount of the charts. Axes handle many things like:
0 commit comments