TradingView Charting Library Examples
repository·master·Indexed 23 days ago
https://github.com/tradingview/charting-library-examplesIntegration examples for the TradingView Charting Library across various web frameworks (React, Vue, Angular, Next.js, Nuxt.js), mobile platforms (Android, iOS, React Native), and meta-frameworks. The repository provides setup guides for incorporating the standalone charting library into different environments, including dependency installation and library file configuration.
What's inside tradingview-charting-library-examples
- The TradingView Charting Library is a standalone, free, and downloadable solution for displaying charts. Unlike hosted widgets, this library is hosted on your own servers and connects directly to your own data feed, allowing you to integrate professional-grade charting into your website or application.
Explore Charting Library integration examples
masterThis repository provides integration examples for various frameworks and platforms. Use these examples to understand how to implement the Charting Library in your specific tech stack.
Available Integration Examples:
- Mobile:
- Android (via WebView)
- iOS (via WKWebView)
- React Native
- Web Frameworks:
- Angular (Angular 5 example)
- React (JavaScript and TypeScript examples)
- Vue.js (v2 and v3 examples)
- Solid.js (TypeScript example)
- Meta-Frameworks:
- Next.js (Examples for Next.js up to v12 and Next.js v13+)
- Nuxt.js (Examples for Nuxt.js up to v2.x and Nuxt.js v3.x)
- Backend/Other:
- Ruby on Rails
- Mobile:
Understand the TradingView Charting Library
masterThe Charting Library is a standalone, downloadable solution for displaying charts. It is hosted on your own servers and must be connected to your own data feed to function within a website or application.
Note: Access to the library is not public. You must request access via the official TradingView page to download and use it.
Run the Next.js integration in production mode
masterTo build the project for production and start the server, use the following commands:
npm run build npm run startSet up the TradingView Charting Library React Integration Example
masterTo run this React integration example, follow these steps:
- Access the Library: Ensure you have access to the TradingView Charting Library repository. If you do not have access, you must request it here.
- Install Dependencies: Run
npm installin the project root. - Copy Library Files: You must manually or via script move the library files into the project structure:
- Option A (Script): Run the
copy_charting_library_files.shscript to copy the current stable version's files automatically. - Option B (Manual):
- Copy the
charting_libraryfolder from the official repository to both the/publicand/srcdirectories of this project. - Copy the
datafeedsfolder from the official repository to the/publicdirectory.
- Copy the
- Option A (Script): Run the
- Start the Application: Run
npm startto build the project and launch the library in your default browser.
npm install ./copy_charting_library_files.sh npm startSetup the React Native Example for Android
masterTo run the React Native integration on Android, follow these steps:
- Environment Setup: Follow the React Native Docs to install
node,watchman,Java development kit, and theAndroid development environment. - Install Dependencies: Run
npm installin the project root. - Integrate Charting Library Assets:
- Open
android/app/src/main/assets. - Copy all files from the charting_library repo into this directory.
- Note: Do not just copy
datafeedsandcharting_library; you must copy the entire repository content. The earliest supported version is 23. - The resulting structure must be:
android/app/src/main/assets/index.htmlandroid/app/src/main/assets/charting_library/android/app/src/main/assets/datafeeds/
- Open
- Run Application: Execute
npx react-native run-androidto install and start the app on a device.
npm install npx react-native run-android- Environment Setup: Follow the React Native Docs to install
Setup the TradingView Charting Library with Angular
masterTo use the TradingView Charting Library within this Angular integration example, follow these steps:
- Access the Library: Ensure you have access to the official charting library repository. If you do not have access, you must request it here.
- Install Dependencies: Run
npm installin the project root. - Copy Library Files: The library files must be placed in the
/src/assetsdirectory. You can do this in two ways:- Automated: Run the
copy_charting_library_files.shscript to copy the current stable version's files. - Manual: Copy the
charting_libraryfolder and thedatafeedsfolder from the officialcharting_libraryrepository into the/src/assetsfolder of this project.
- Automated: Run the
- Start the Dev Server: Run the Angular development server.
Note: The earliest supported version of the charting library for these examples is
v28.0.0.Set up the TradingView Charting Library Next.js Integration Example
masterTo use this Next.js integration example, you must first ensure you have access to the private TradingView Charting Library repository. Follow these steps to set up the environment:
- Access Check: Verify you can view
https://github.com/tradingview/charting_library/. If not, request access here. - Install Dependencies: Run
npm installin the project root. - Copy Library Files: You must manually or via script move the library files into the project's public directory so they are served correctly.
- Option A (Bash): Run the
copy_charting_library_files.shscript to copy the current stable version's files. - Option B (Manual):
- Copy the
charting_libraryfolder from thecharting_libraryrepository to/public/static. - Copy the
datafeedsfolder from thecharting_libraryrepository to/public/static.
- Copy the
- Option A (Bash): Run the
- Build and Run: Run
npm run buildfollowed bynpm run startto build the project and launch it in your default browser.
Note: The earliest supported version of the charting library for these examples is
v28.0.0.- Access Check: Verify you can view
Setup the TradingView Charting Library with Nuxt 3
masterTo use this integration example, you must first ensure you have access to the private TradingView Charting Library repository. Follow these steps to set up the local environment:
- Access the Library: Verify you can view https://github.com/tradingview/charting_library/. If not, request access here.
- Install Dependencies: Run
npm installin the project root. - Copy Library Files: The library files must be placed in the
/publicdirectory of the Nuxt project. You can do this in two ways:- Using the script: Run the
copy_charting_library_files.shscript to automatically copy the current stable version's files. - Manual Copy: Manually copy the
charting_libraryfolder and thedatafeedsfolder from the<https://github.com/tradingview/charting_library/>repository into your project's/publicfolder.
- Using the script: Run the
- Start Development Server: Run
npm run devto build the project and launch the library in your default browser.
Setup the TradingView Charting Library with Vue.js 2
masterTo use this integration example, you must first ensure you have access to the private TradingView Charting Library repository. This example uses Charting Library version
v28.0.0and is specifically designed for Vue 2.Prerequisites
- Verify access to https://github.com/tradingview/charting_library/. If you cannot access it, request access here.
Installation Steps
- Install dependencies: Run
npm installto install the necessary Node packages. - Copy Charting Library files: The library files must be placed in the
/publicdirectory of this project. You can do this in two ways:- Automated: Run the
copy_charting_library_files.shscript to copy the current stable version's files. - Manual:
- Copy the
charting_libraryfolder from the official TradingView repository to the/publicfolder. - Copy the
datafeedsfolder from the official TradingView repository to the/publicfolder.
- Copy the
- Automated: Run the
- Start development server: Run
npm run devto build the project and open the Charting Library in your default browser. - Build for production: Run
npm run buildwhen you are ready to generate the production-ready Vue application.
Setup the TradingView Charting Library with Vue.js 3
masterTo use this integration example, you must first ensure you have access to the private TradingView Charting Library repository. Follow these steps to set up the local development environment:
- Access Check: Verify you can access https://github.com/tradingview/charting_library/. If not, request access here.
- Install Dependencies: Run
npm installto install the necessary Vue 3 and project dependencies. - Copy Library Files: The Charting Library files must be placed in the
/publicdirectory of this project. You can do this in two ways:- Automated: Run the
copy_charting_library_files.shscript to copy the current stable version's files. - Manual: Copy the
charting_libraryfolder and thedatafeedsfolder from the official charting_library repository directly into the/publicfolder.
- Automated: Run the
- Start Development Server: Run
npm run devto build the project and launch the Charting Library in your default browser. - Production Build: Run
npm run buildto generate the production-ready Vue application.
Setup the React Native Example for iOS
masterTo run the React Native integration on iOS, follow these steps:
- Environment Setup: Follow the React Native Docs to install
node,watchman,ruby(ensure the correct version),xCode, andcocoaPods. - Install Dependencies: Run
npm installin the project root. - Configure Xcode Project:
- Open
/ios/ChartingLibraryExample.xcodeprojin Xcode. - Right-click on the
charting_libraryfolder and select "Add Files to ...". - Select all files from the charting_library repo (including
htmlfiles,charting_library, anddatafeedsfolders). - CRITICAL: You must select the "Create folder references" option when adding files. This preserves the folder structure required to handle files with identical names located in different directories.
- Open
- Install Pods: Run
pod installwithin theiosfolder. - Run Application: Execute
npx react-native run-iosto install and start the app on a device.
npm install cd ios && pod install && cd .. npx react-native run-ios- Environment Setup: Follow the React Native Docs to install