Skip to content

Commit 7178ba6

Browse files
docs: Chart options docs (#273)
* Chart options docs * removing node 10 from matrix * adding test placeholder * semantics improvement * remove size workflow * Chart additional options * clean up Chart options docs
1 parent 1853931 commit 7178ba6

File tree

5 files changed

+88
-27
lines changed

5 files changed

+88
-27
lines changed

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
node: [10, 12, 14, 16]
16+
node: [12, 14, 16]
1717
steps:
1818
- uses: actions/checkout@v2
1919
- uses: actions/setup-node@v2

.github/workflows/size.yml

-12
This file was deleted.

docs/src/pages/docs/api.md

+81-3
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ The individual datums in a series' `data` array can be anything you want! Just r
6060

6161
## Axes
6262

63-
React Charts uses axes to configure a fair amount of the chart. Axes handle many things like:
63+
React Charts use axes to configure a fair amount of the charts. Axes handle many things like:
6464

6565
- Accessing chart values from your series' `Datum`s
6666
- Optionally positioning your axis on the grid
67-
- Optionsally configuring the scale type for your axis
68-
- Optionsally configuring the element type for series that are tied to your axis
67+
- Optionally configuring the scale type for your axis
68+
- Optionally configuring the element type for series that are tied to your axis
6969

7070
To date, we have the following scale types available:
7171

@@ -151,6 +151,84 @@ const secondaryAxes = React.useMemo(
151151
)
152152
```
153153

154+
### Chart Component Props
155+
156+
The Chart component props can be passed in its **options** property object:
157+
158+
```javascript
159+
<Chart
160+
options={{
161+
data,
162+
primaryAxis,
163+
secondaryAxes,
164+
}}
165+
/>
166+
```
167+
168+
The data property should be an array of series, each series should be an array of objects.
169+
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.
170+
171+
```javascript
172+
const data = [
173+
{
174+
label: 'Series 1',
175+
data: [
176+
{
177+
primary: '2022-02-03T00:00:00.000Z',
178+
likes: 130,
179+
},
180+
{
181+
primary: '2022-03-03T00:00:00.000Z',
182+
likes: 150,
183+
},
184+
],
185+
},
186+
{
187+
label: 'Series 2',
188+
data: [
189+
{
190+
primary: '2022-04-03T00:00:00.000Z',
191+
likes: 200,
192+
},
193+
{
194+
primary: '2022-05-03T00:00:00.000Z',
195+
likes: 250,
196+
},
197+
],
198+
},
199+
]
200+
```
201+
202+
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:
203+
204+
```javascript
205+
const primaryAxis = React.useMemo(
206+
() => ({
207+
getValue: (datum: { primary: string }) => datum.primary,
208+
}),
209+
[]
210+
)
211+
const secondaryAxes = React.useMemo(
212+
() => [
213+
{
214+
getValue: (datum: { likes: number }) => datum.likes,
215+
elementType: 'area',
216+
},
217+
],
218+
[]
219+
)
220+
```
221+
222+
**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 onoly. 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
223+
224+
**interactionMode** expect an string wich can be "primary" or "closest". It's been using for the tooltip position. By default, primary is being set.
225+
226+
**showVoronoi** expect a boolean, it's a debug option to visualize the interaction click-map that sits on top of the chart.
227+
228+
**getSeriesOrder** expect a function, this option will allows you to reorder the series if you want.
229+
230+
**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.
231+
154232
### Curve Types
155233

156234
All element types that support lines or curves can be configured by passing any `curve` generator function as the `AxisOptions<TDatum>['curve']` option. By default, horizontal and vertical series default to using `monotoneX` and `monotoneY` curves, respectively. More information can be found at [`d3-shape curves`](https://github.com/d3/d3-shape#curves)

test/blah.test.tsx

-11
This file was deleted.

test/placeholder.test.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react'
2+
import * as ReactDOM from 'react-dom'
3+
4+
describe('Placeholder', () => {
5+
it('Will add some tests', () => {})
6+
})

0 commit comments

Comments
 (0)