Swift Charts under One.iOS.Chart
One.iOS.Chart draws a Swift Charts chart.
type.referenceLines draw horizontal rule marks at their y values..ios.tsx file.A chart fills the box React Native gives it, so give it a height.
import { One } from 'one'
<One.iOS.Chart type="bar" data={[ { x: 'Mon', y: 3 }, { x: 'Tue', y: 7 }, { x: 'Wed', y: 5 }, ]} referenceLines={[{ x: 'goal', y: 6 }]} barStyle={{ cornerRadius: 4 }} showLegend style={{ height: 220 }}/>| Props | Type | Description |
|---|---|---|
data (required)readonly ChartDataPoint[]Points, each { x, y, color }. A string x plots on a category axis, a number on a numeric axis. | readonly ChartDataPoint[] | Points, each { x, y, color }. A string x plots on a category axis, a number on a numeric axis. |
typeChartType = "line"line, point, bar, area, pie, or rectangle. | ChartType = "line" | line, point, bar, area, pie, or rectangle. |
showGridboolean = trueShows both axes and their grid lines. | boolean = true | Shows both axes and their grid lines. |
animateboolean = trueAnimates the marks when the number of points changes. | boolean = true | Animates the marks when the number of points changes. |
showLegendboolean = falseShows the legend for category colors. | boolean = false | Shows the legend for category colors. |
referenceLinesreadonly ChartDataPoint[] = []Horizontal rules at each y, red unless a color is set. | readonly ChartDataPoint[] = [] | Horizontal rules at each y, red unless a color is set. |
lineStyleLineChartStyleLine marks. | LineChartStyle | Line marks. |
pointStylePointChartStylePoint marks. | PointChartStyle | Point marks. |
areaStyleAreaChartStyleArea marks. | AreaChartStyle | Area marks. |
barStyleBarChartStyleBar marks. | BarChartStyle | Bar marks. |
pieStylePieChartStylePie sectors. | PieChartStyle | Pie sectors. |
rectangleStyleRectangleChartStyleRectangle marks. | RectangleChartStyle | Rectangle marks. |
ruleStyleRuleChartStyleReference lines. | RuleChartStyle | Reference lines. |
When no point sets color, bars and pie sectors take a category color for
each x and the legend names them. When any point sets color, every mark
uses its own point’s color and the rest are blue. Line, point, area, and
rectangle marks are blue unless their style or point names a color.
A style object takes only the keys of its own type; any other key throws. Colors take a color string or a processed color number.
| LineChartStyle | Type | Description |
|---|---|---|
dashArrayreadonly number[]Dash and gap lengths in points. | readonly number[] | Dash and gap lengths in points. |
widthnumber = 2Line width in points. | number = 2 | Line width in points. |
pointStyleChartPointStyle = "circle"circle, square, or diamond. | ChartPointStyle = "circle" | circle, square, or diamond. |
pointSizenumber = 6Symbol size. | number = 6 | Symbol size. |
colorColorValueThe line color. | ColorValue | The line color. |
| PointChartStyle | Type | Description |
|---|---|---|
pointStyleChartPointStyle = "circle"circle, square, or diamond. | ChartPointStyle = "circle" | circle, square, or diamond. |
pointSizenumber = 6Symbol size. | number = 6 | Symbol size. |
| AreaChartStyle | Type | Description |
|---|---|---|
colorColorValueThe fill color. | ColorValue | The fill color. |
| BarChartStyle | Type | Description |
|---|---|---|
cornerRadiusnumber = 0Corner radius in points. | number = 0 | Corner radius in points. |
widthnumberA fixed bar width in points. Swift Charts sizes bars when unset. | number | A fixed bar width in points. Swift Charts sizes bars when unset. |
| PieChartStyle | Type | Description |
|---|---|---|
innerRadiusnumber = 0.3The hole as a fraction of the radius; 0 draws a full pie. | number = 0.3 | The hole as a fraction of the radius; 0 draws a full pie. |
angularInsetnumber = 2The gap between sectors in points. | number = 2 | The gap between sectors in points. |
| RectangleChartStyle | Type | Description |
|---|---|---|
colorColorValueThe fill when a point sets none. | ColorValue | The fill when a point sets none. |
cornerRadiusnumber = 0Corner radius in points. | number = 0 | Corner radius in points. |
| RuleChartStyle | Type | Description |
|---|---|---|
colorColorValueThe line color when a reference line sets none. | ColorValue | The line color when a reference line sets none. |
lineWidthnumber = 2Line width in points. | number = 2 | Line width in points. |
dashArrayreadonly number[]Dash and gap lengths in points. | readonly number[] | Dash and gap lengths in points. |
The chart types are exported from one:
import type { ChartDataPoint } from 'one'.
Edit this page on GitHub.