Installation
Get started with @nstudio/ncharts in your NativeScript project.
Prerequisites
- NativeScript 9.0 or higher
- iOS 12.0+ / Android API 21+
Install the Package
bash
npm install @nstudio/nchartsbash
yarn add @nstudio/nchartsbash
pnpm add @nstudio/nchartsbash
bun add @nstudio/nchartsPlatform Requirements
iOS
The plugin uses DGCharts via Swift Package Manager. No additional setup is required - the dependency is automatically resolved during the build.
iOS Minimum Version
iOS 12.0 or higher is required.
Android
The plugin includes MPAndroidChart. The Gradle dependency is automatically configured.
Android Minimum SDK
API level 21 (Android 5.0) or higher is required.
Framework Integration
1. Register the chart elements in your main.ts:
typescript
import { registerNchartsElements } from '@nstudio/ncharts/angular';
registerNchartsElements();2. Import the directives in your component:
typescript
import { Component } from '@angular/core';
import { LineChartDirective, BarChartDirective, PieChartDirective } from '@nstudio/ncharts/angular';
import type { LineChartData } from '@nstudio/ncharts';
@Component({
selector: 'app-chart',
template: `
<LineChart
[data]="chartData"
[animation]="animation"
class="h-80">
</LineChart>
`,
imports: [LineChartDirective],
})
export class ChartComponent {
chartData: LineChartData = { /* ... */ };
}Verify Installation
Create a simple chart to verify everything is working:
typescript
import type { LineChartData } from '@nstudio/ncharts';
const testData: LineChartData = {
dataSets: [
{
label: 'Test Data',
values: [
{ x: 0, y: 10 },
{ x: 1, y: 20 },
{ x: 2, y: 15 },
{ x: 3, y: 30 },
],
config: {
color: '#3B82F6',
lineWidth: 2,
drawCircles: true,
},
},
],
};If the chart renders without errors, you're all set!
Next Steps
- Quick Start Guide - Build your first chart
- Chart Types - Explore available charts
- Configuration - Customize your charts