One Logo Pool Ball
wwwwwwwwwwwwwwwwwww

iOS Charts

Swift Charts under One.iOS.Chart

One.iOS.Chart draws a Swift Charts chart.

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 }}
/>
PropsTypeDescription
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 = trueShows both axes and their grid lines.
animateboolean = trueAnimates the marks when the number of points changes.
boolean = trueAnimates the marks when the number of points changes.
showLegendboolean = falseShows the legend for category colors.
boolean = falseShows 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.
LineChartStyleLine marks.
pointStylePointChartStylePoint marks.
PointChartStylePoint marks.
areaStyleAreaChartStyleArea marks.
AreaChartStyleArea marks.
barStyleBarChartStyleBar marks.
BarChartStyleBar marks.
pieStylePieChartStylePie sectors.
PieChartStylePie sectors.
rectangleStyleRectangleChartStyleRectangle marks.
RectangleChartStyleRectangle marks.
ruleStyleRuleChartStyleReference lines.
RuleChartStyleReference 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.

Styles

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.

LineChartStyleTypeDescription
dashArrayreadonly number[]Dash and gap lengths in points.
readonly number[]Dash and gap lengths in points.
widthnumber = 2Line width in points.
number = 2Line width in points.
pointStyleChartPointStyle = "circle"circle, square, or diamond.
ChartPointStyle = "circle"circle, square, or diamond.
pointSizenumber = 6Symbol size.
number = 6Symbol size.
colorColorValueThe line color.
ColorValueThe line color.
PointChartStyleTypeDescription
pointStyleChartPointStyle = "circle"circle, square, or diamond.
ChartPointStyle = "circle"circle, square, or diamond.
pointSizenumber = 6Symbol size.
number = 6Symbol size.
AreaChartStyleTypeDescription
colorColorValueThe fill color.
ColorValueThe fill color.
BarChartStyleTypeDescription
cornerRadiusnumber = 0Corner radius in points.
number = 0Corner radius in points.
widthnumberA fixed bar width in points. Swift Charts sizes bars when unset.
numberA fixed bar width in points. Swift Charts sizes bars when unset.
PieChartStyleTypeDescription
innerRadiusnumber = 0.3The hole as a fraction of the radius; 0 draws a full pie.
number = 0.3The hole as a fraction of the radius; 0 draws a full pie.
angularInsetnumber = 2The gap between sectors in points.
number = 2The gap between sectors in points.
RectangleChartStyleTypeDescription
colorColorValueThe fill when a point sets none.
ColorValueThe fill when a point sets none.
cornerRadiusnumber = 0Corner radius in points.
number = 0Corner radius in points.
RuleChartStyleTypeDescription
colorColorValueThe line color when a reference line sets none.
ColorValueThe line color when a reference line sets none.
lineWidthnumber = 2Line width in points.
number = 2Line 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.