# rn-chart URL: /docs/native/kiva/chart Comprehensive charting library with 13 chart types, VChart adapter, touch interactions, and animations. ## Installation ```bash pnpm dlx @kivacore/ui-cli add @kivacore/rn-chart ``` **Dependencies:** - [react-native-svg](https://www.npmjs.com/package/react-native-svg) ## Usage ```tsx import { KivaLineChart } from '@/components/kiva-native/chart'; const data = { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'], series: [ { name: 'Revenue', data: [30, 40, 35, 50, 49] }, { name: 'Expenses', data: [20, 25, 30, 28, 32] } ] }; ``` ## Chart Types ### Line Chart ```tsx import { KivaLineChart } from '@/components/kiva-native/chart'; ``` ### Bar Chart ```tsx import { KivaBarChart } from '@/components/kiva-native/chart'; ``` ### Pie Chart ```tsx import { KivaPieChart } from '@/components/kiva-native/chart'; ``` ### Area Chart ```tsx import { KivaAreaChart } from '@/components/kiva-native/chart'; ``` ### Scatter Chart ```tsx import { KivaScatterChart } from '@/components/kiva-native/chart'; ``` ### Radar Chart ```tsx import { KivaRadarChart } from '@/components/kiva-native/chart'; ``` ### Gauge Chart ```tsx import { KivaGaugeChart } from '@/components/kiva-native/chart'; ``` ### Funnel Chart ```tsx import { KivaFunnelChart } from '@/components/kiva-native/chart'; ``` ### Heatmap Chart ```tsx import { KivaHeatmapChart } from '@/components/kiva-native/chart'; ``` ### Treemap Chart ```tsx import { KivaTreemapChart } from '@/components/kiva-native/chart'; ``` ### Candlestick Chart ```tsx import { KivaCandlestickChart } from '@/components/kiva-native/chart'; ``` ### Sparkline Chart ```tsx import { KivaSparklineChart } from '@/components/kiva-native/chart'; ``` ### Combo Chart (Bar + Line) ```tsx import { KivaComboChart } from '@/components/kiva-native/chart'; ``` ## VChart Adapter The `KivaVChart` component accepts VChart-compatible spec format and renders the appropriate chart. ```tsx import { KivaVChart } from '@/components/kiva-native/chart'; ``` ## API Reference — Base Props All chart components share these base props: | Prop | Type | Default | Description | |------|------|---------|-------------| | `width` | `number` | screen width | Chart width in pixels | | `height` | `number` | `300` | Chart height in pixels | | `title` | `string` | — | Chart title text | | `description` | `string` | — | Chart description text | | `loading` | `boolean` | `false` | Show loading state | | `error` | `string` | — | Error message to display | | `className` | `string` | — | Additional CSS classes | | `config` | `ChartConfig` | — | Axis, grid, legend, tooltip configuration | | `animated` | `boolean` | `false` | Enable entry animations | | `animationDuration` | `number` | `500` | Animation duration in milliseconds | | `animationDelay` | `number` | `0` | Animation delay in milliseconds | ## API Reference — Touch Props Charts with touch support (Line, Area, Combo) accept: | Prop | Type | Default | Description | |------|------|---------|-------------| | `showCrosshair` | `boolean` | `false` | Show crosshair line on touch | | `showTooltip` | `boolean` | `false` | Show tooltip on touch | | `tooltipComponent` | `(data: TooltipData) => ReactNode` | — | Custom tooltip renderer | | `onTouch` | `(point: TooltipData \| null) => void` | — | Touch event callback | ## API Reference — Chart Config | Prop | Type | Default | Description | |------|------|---------|-------------| | `padding` | `{ top, right, bottom, left }` | `{ 20, 20, 50, 50 }` | Chart SVG internal padding | | `xAxis` | `ChartAxis` | — | X axis configuration | | `yAxis` | `ChartAxis` | — | Y axis configuration | | `grid` | `ChartGrid` | — | Grid line configuration | | `legend` | `ChartLegend` | — | Legend position and alignment | | `tooltip` | `ChartTooltip` | — | Tooltip formatting | ## Components | Component | Description | |-----------|-------------| | `KivaLineChart` | Line chart with smooth curves, area fill, crosshair | | `KivaBarChart` | Vertical/horizontal bar chart with stacking | | `KivaPieChart` | Pie/donut chart with labels | | `KivaAreaChart` | Stacked area chart with smooth curves | | `KivaScatterChart` | Scatter plot with grid | | `KivaRadarChart` | Radar/spider chart | | `KivaGaugeChart` | Semicircular gauge with value display | | `KivaFunnelChart` | Funnel/pyramid chart with labels | | `KivaHeatmapChart` | Color-encoded matrix chart | | `KivaTreemapChart` | Proportional rectangle layout | | `KivaCandlestickChart` | OHLC financial chart with volume | | `KivaSparklineChart` | Inline mini chart (no axes) | | `KivaComboChart` | Combined bar + line chart | | `KivaVChart` | VChart spec adapter | ## Core Sub-Components | Component | Description | |-----------|-------------| | `KivaChartAxis` | Axis labels and ticks | | `KivaChartGrid` | Background grid lines | | `KivaChartLegend` | Color legend with series names | | `KivaChartCrosshair` | Touch crosshair overlay | | `KivaChartTooltip` | Floating data tooltip | ## Hooks | Hook | Description | |------|-------------| | `useChartAnimation` | Returns animated progress value (0 → 1) for chart transitions | | `useChartTouch` | Pan responder for crosshair and tooltip interactions | ## Type Exports | Type | Description | |------|-------------| | `LineChartProps` | Props for KivaLineChart | | `BarChartProps` | Props for KivaBarChart | | `PieChartProps` | Props for KivaPieChart | | `AreaChartProps` | Props for KivaAreaChart | | `ScatterChartProps` | Props for KivaScatterChart | | `RadarChartProps` | Props for KivaRadarChart | | `GaugeChartProps` | Props for KivaGaugeChart | | `FunnelChartProps` | Props for KivaFunnelChart | | `HeatmapChartProps` | Props for KivaHeatmapChart | | `TreemapChartProps` | Props for KivaTreemapChart | | `CandlestickChartProps` | Props for KivaCandlestickChart | | `SparklineChartProps` | Props for KivaSparklineChart | | `ComboChartProps` | Props for KivaComboChart | | `KivaVChartProps` | Props for KivaVChart adapter | | `ChartConfig` | Chart configuration object | | `ChartData` | Generic chart data type | | `ChartSeries` | Series data definition | | `TooltipData` | Tooltip callback data | | `VChartSpec` | VChart-compatible spec type |