-
Notifications
You must be signed in to change notification settings - Fork 5
Publish the experimental React Native chart host #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1a8b888
14417a0
710ffec
9037ce1
1d63a11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| '@tanstack/react-native-charts': minor | ||
| --- | ||
|
|
||
| Add the experimental React Native SVG host with responsive scene rendering, | ||
| focus, selection, accessibility actions, and an optional native tooltip entry. | ||
| Ship compiled ESM and declarations, and verify the packed package in bare React | ||
| Native and Expo Metro consumers. |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { scaleLinear } from 'd3-scale' | ||
| import { lineY } from '@tanstack/charts/line' | ||
| import { defineChart } from '@tanstack/charts/scene' | ||
|
|
||
| export { Chart } from '@tanstack/react-native-charts' | ||
|
|
||
| export const definition = defineChart({ | ||
| marks: [lineY([4, 9, 7])], | ||
| x: { scale: scaleLinear().domain([0, 2]) }, | ||
| y: { scale: scaleLinear().domain([0, 10]) }, | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { Chart } from '@tanstack/react-native-charts' | ||
| export { tooltip } from '@tanstack/react-native-charts/tooltip' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { Chart } from '@tanstack/react-native-charts' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,9 @@ Then add one adapter if the application needs it: | |
| # React | ||
| pnpm add @tanstack/react-charts react react-dom | ||
|
|
||
| # React Native | ||
| pnpm add @tanstack/react-native-charts react react-native react-native-svg | ||
|
|
||
| # Preact | ||
| pnpm add @tanstack/preact-charts preact | ||
|
|
||
|
|
@@ -46,22 +49,56 @@ The adapters intentionally do not replace the core package. Definitions and mark | |
|
|
||
| ## Framework compatibility | ||
|
|
||
| | Adapter package | Framework peers | | ||
| | -------------------------- | ---------------------------------------- | | ||
| | `@tanstack/react-charts` | React and React DOM `^19.0.0` | | ||
| | `@tanstack/preact-charts` | Preact `>=10` | | ||
| | `@tanstack/vue-charts` | Vue `>=3.5` | | ||
| | `@tanstack/solid-charts` | Solid `>=1.8` | | ||
| | `@tanstack/svelte-charts` | Svelte `^5.20.0` | | ||
| | `@tanstack/angular-charts` | Angular core and platform browser `>=19` | | ||
| | `@tanstack/lit-charts` | Lit `>=3.1.3` | | ||
| | `@tanstack/alpine-charts` | Alpine `>=3.15` | | ||
| | `@tanstack/octane-charts` | Octane `^0.1.13` | | ||
| | Adapter package | Framework peers | | ||
| | ------------------------------- | ------------------------------------------------------------------------------- | | ||
| | `@tanstack/react-charts` | React and React DOM `^19.0.0` | | ||
| | `@tanstack/react-native-charts` | React `^19.2.3`, React Native `^0.86.0`, and `react-native-svg` `>=15.15.4 <16` | | ||
| | `@tanstack/preact-charts` | Preact `>=10` | | ||
| | `@tanstack/vue-charts` | Vue `>=3.5` | | ||
| | `@tanstack/solid-charts` | Solid `>=1.8` | | ||
| | `@tanstack/svelte-charts` | Svelte `^5.20.0` | | ||
| | `@tanstack/angular-charts` | Angular core and platform browser `>=19` | | ||
| | `@tanstack/lit-charts` | Lit `>=3.1.3` | | ||
| | `@tanstack/alpine-charts` | Alpine `>=3.15` | | ||
| | `@tanstack/octane-charts` | Octane `^0.1.13` | | ||
|
|
||
| These ranges are the package peer contracts. Use the selected framework's | ||
| normal renderer or application package beside the adapter when the application | ||
| needs browser mounting or server rendering. | ||
|
|
||
| ## React Native and Expo | ||
|
|
||
| The React Native adapter is experimental and renders through | ||
| `react-native-svg`. Expo 57 applications can install the package and the SVG | ||
| version selected by Expo: | ||
|
|
||
| ```sh | ||
| pnpm add @tanstack/charts @tanstack/react-native-charts d3-scale | ||
| pnpm exec expo install react-native-svg | ||
| ``` | ||
|
|
||
| Bare React Native 0.86 applications install the renderer directly: | ||
|
|
||
| ```sh | ||
| pnpm add @tanstack/charts @tanstack/react-native-charts d3-scale react-native-svg | ||
| ``` | ||
|
|
||
| Run `bundle exec pod install` from `ios/` after adding it to a bare iOS | ||
| application. Import shared definitions through the universal entry and choose | ||
| the native host explicitly: | ||
|
|
||
| ```tsx | ||
| import { defineChart, lineY } from '@tanstack/charts/universal' | ||
| import { Chart } from '@tanstack/react-native-charts' | ||
| import { tooltip } from '@tanstack/react-native-charts/tooltip' | ||
| ``` | ||
|
|
||
| Packed tarballs are typechecked and bundled through default bare React Native | ||
| and Expo Metro configurations on iOS and Android. The workspace Expo 57 | ||
| fixture also renders in Expo Go on an iOS simulator. Bare-native and Android | ||
| simulators, physical devices, gestures, visual parity, and screen readers are | ||
| not yet support claims. | ||
|
Comment on lines
+96
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Correct the support-claim wording. The sentence says 🤖 Prompt for AI Agents |
||
|
|
||
| ## Install the D3 modules you import | ||
|
|
||
| TanStack Charts accepts D3 scale factories, configured scale instances, and | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import * as React from 'react' | ||
| import { SafeAreaView, View } from 'react-native' | ||
| import { scaleLinear } from 'd3-scale' | ||
| import { defineChart, lineY } from '@tanstack/charts/universal' | ||
| import { Chart } from '@tanstack/react-native-charts' | ||
| import { tooltip } from '@tanstack/react-native-charts/tooltip' | ||
|
|
||
| const rows = [ | ||
| { month: 1, revenue: 12 }, | ||
| { month: 2, revenue: 18 }, | ||
| { month: 3, revenue: 15 }, | ||
| { month: 4, revenue: 26 }, | ||
| { month: 5, revenue: 31 }, | ||
| ] | ||
|
|
||
| const definition = defineChart({ | ||
| marks: [ | ||
| lineY(rows, { | ||
| x: 'month', | ||
| y: 'revenue', | ||
| stroke: '#2563eb', | ||
| strokeWidth: 3, | ||
| points: true, | ||
| }), | ||
| ], | ||
| x: { label: 'Month', scale: scaleLinear().domain([1, 5]) }, | ||
| y: { label: 'Revenue', scale: scaleLinear().domain([0, 35]) }, | ||
| focus: 'nearest-x', | ||
| tooltip: { use: tooltip, sticky: true }, | ||
| }) | ||
|
|
||
| export default function App() { | ||
| return ( | ||
| <SafeAreaView style={{ flex: 1, backgroundColor: '#f8fafc' }}> | ||
| <View style={{ flex: 1, padding: 16, justifyContent: 'center' }}> | ||
| <Chart | ||
| definition={definition} | ||
| accessibilityLabel="Monthly revenue" | ||
| aspectRatio={1.5} | ||
| /> | ||
| </View> | ||
| </SafeAreaView> | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "expo": { | ||
| "name": "TanStack Charts Expo", | ||
| "slug": "tanstack-charts-expo" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { registerRootComponent } from 'expo' | ||
| import App from './App' | ||
|
|
||
| registerRootComponent(App) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| const { getDefaultConfig } = require('expo/metro-config') | ||
|
|
||
| module.exports = getDefaultConfig(__dirname) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "name": "@charts-poc/expo-example", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "license": "MIT", | ||
| "main": "index.ts", | ||
| "scripts": { | ||
| "start": "expo start", | ||
| "bundle": "expo export --platform all --output-dir dist --clear" | ||
| }, | ||
| "dependencies": { | ||
| "@tanstack/charts": "workspace:*", | ||
| "@tanstack/react-native-charts": "workspace:*", | ||
| "d3-scale": "4.0.2", | ||
| "expo": "~57.0.9", | ||
| "react": "19.2.3", | ||
| "react-native": "0.86.2", | ||
| "react-native-svg": "15.15.4" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/d3-scale": "^4.0.9", | ||
| "@types/react": "~19.2.2", | ||
| "typescript": "~6.0.3" | ||
| }, | ||
| "engines": { | ||
| "node": ">=22.13.0" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "extends": "expo/tsconfig.base", | ||
| "compilerOptions": { | ||
| "strict": true, | ||
| "skipLibCheck": true | ||
| }, | ||
| "include": ["App.tsx", "index.ts"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import * as React from 'react' | ||
| import { lineY } from '@tanstack/charts/line' | ||
| import { defineChart } from '@tanstack/charts/scene' | ||
| import { createRevenueDefinition, RevenueChart } from './RevenueChart' | ||
|
|
||
| const definition = createRevenueDefinition(defineChart, lineY) | ||
|
|
||
| export default function GranularApp() { | ||
| return <RevenueChart definition={definition} /> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import * as React from 'react' | ||
| import { defineChart, lineY } from '@tanstack/charts/universal' | ||
| import { createRevenueDefinition, RevenueChart } from './RevenueChart' | ||
|
|
||
| const definition = createRevenueDefinition(defineChart, lineY) | ||
|
|
||
| export default function App() { | ||
| return <RevenueChart definition={definition} /> | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: TanStack/charts
Length of output: 2855
Pin
react-native-svgin the bare React Native install command.@tanstack/react-native-chartsrequiresreact-native-svg>=15.15.4 <16, but the bare command installs the unqualified latest, which can resolve an incompatible major version. Use a version specifier that stays in the declared peer range, such asreact-native-svg@^15.15.4, and leave Expo installs withexpo installso Expo picks its compatible native version.Suggested documentation fix
📝 Committable suggestion
🤖 Prompt for AI Agents