|
| 1 | +## PolygonSeries: |
| 2 | + |
| 3 | +<!-- INJECT:"TriangleExample" --> |
| 4 | + |
| 5 | +The polygon series allows users to specify arbitrary polygons in coordinates. This may seem un-useful, but it allows for |
| 6 | +easy creation of radar charts, fancy mark series dots, and any variety of additional things you might need polygons for! |
| 7 | + |
| 8 | +```javascript |
| 9 | +<XYPlot |
| 10 | + width={300} |
| 11 | + height={300}> |
| 12 | + <XAxis /> |
| 13 | + <YAxis /> |
| 14 | + <PolygonSeries |
| 15 | + className="polygon-series-example" |
| 16 | + data={myData}/> |
| 17 | +</XYPlot> |
| 18 | +``` |
| 19 | + |
| 20 | +Each series corresponds to exactly **one** svg path. It is perfectly okay to many series to express many polygons! |
| 21 | + |
| 22 | +## Data format Reference |
| 23 | + |
| 24 | +Like other series, it is required that the data be an array of objects, formatted like so: |
| 25 | + |
| 26 | + |
| 27 | +```javascript |
| 28 | +const myData = [ |
| 29 | + {x: 0, y: 0}, |
| 30 | + {x: 1, y: 0}, |
| 31 | + {x: 0, y: 1} |
| 32 | +] |
| 33 | +``` |
| 34 | + |
| 35 | +Which would render a triangle. |
| 36 | + |
| 37 | +#### x |
| 38 | +Type: `number` |
| 39 | +The x position in coordinates of the box to be used. |
| 40 | + |
| 41 | +#### y |
| 42 | +Type: `number` |
| 43 | +The y position in coordinates of the box to be used. |
| 44 | + |
| 45 | + |
| 46 | +## Series API Reference |
| 47 | + |
| 48 | +#### animation (optional) |
| 49 | +See the [XYPlot](xy-plot.md)'s `animation` section for more information. |
| 50 | + |
| 51 | +#### color |
| 52 | +Type: `string` |
| 53 | +The color for all elements in the series, this property will be over-ridden by color specified in the data attribute. |
| 54 | + |
| 55 | +#### className (optional) |
| 56 | +Type: `string` |
| 57 | +Provide an additional class name for the series. |
| 58 | + |
| 59 | +#### data |
| 60 | +Type: `Array<Object>` |
| 61 | +Array of data for the series. See above data format reference. |
| 62 | + |
| 63 | +#### onNearestX (optional) |
| 64 | +Type: `function(value, {event, innerX, index})` |
| 65 | +A callback function which is triggered each time when the mouse pointer gets close to some X value. |
| 66 | +Callback is triggered with two arguments. `value` is the data point, `info` object has following properties: |
| 67 | +- `innerX` is the left position of the value; |
| 68 | +- `index` is the index of the data point in the array of data; |
| 69 | +- `event` is the event object. |
| 70 | + |
| 71 | +#### onSeriesMouseOver (optional) |
| 72 | +Type: `function(d, {event})` |
| 73 | +`mouseover` event handler for the elements corresponding separate data points. First argument received is, `d`, the relevant data point, and second an object with the only `event` property. |
| 74 | + |
| 75 | +#### onSeriesMouseOut (optional) |
| 76 | +Type: `function(d, {event})` |
| 77 | +`mouseout` event handler for the elements corresponding separate data points. First argument received is, `d`, the relevant data point, and second an object with the only `event` property. |
| 78 | + |
| 79 | +#### onSeriesClick (optional) |
| 80 | +Type: `function(d, {event})` |
| 81 | +`click` event handler for the elements corresponding separate data points. First argument received is, `d`, the relevant data point, and second an object with the only `event` property. |
| 82 | + |
| 83 | +#### style |
| 84 | +Type: `object` |
| 85 | +Paths accept a ton of different styles, so rather than prescribe every single one we just accept a general grab bag pf the styles. check out the [w3](https://www.w3schools.com/graphics/svg_path.asp) page for more details. |
0 commit comments