### Start Tradex Chart with Configuration Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/reference/01_getting_started/index.html Illustrates the process of initializing the Tradex Chart with a configuration object after it has been mounted on the DOM. The 'config' object should be defined according to the [Configuration](02_configuration) documentation. ```javascript chart.start(config) ``` -------------------------------- ### Install TradeX Chart using npm Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/reference/01_getting_started/index.html Instructions to install the TradeX Chart library using the npm package manager. This is a common method for managing project dependencies. ```bash npm install tradex-chart --save ``` -------------------------------- ### Install TradeX Chart using yarn Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/reference/01_getting_started/index.html Instructions to install the TradeX Chart library using the yarn package manager. Yarn is an alternative to npm for dependency management. ```bash yarn add tradex-chart ``` -------------------------------- ### Install Project Dependencies (Bash) Source: https://github.com/tradex-app/tradex-chart/blob/master/src/docs/src/content/docs/guides/development/local-setup.md Installs all necessary project dependencies using npm. This includes build tools like Vite, testing frameworks like Vitest, and libraries such as TALib-web. ```bash npm install ``` -------------------------------- ### Clone Repository and Install Dependencies (Shell) Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/guides/development/local-setup/index.html Clones the TradeX Chart repository and installs all necessary project dependencies using npm. This is the first step for local development. ```shell git clone https://github.com/tradex-app/TradeX-chart.git cd TradeX-chart npm install ``` -------------------------------- ### Run Development Commands for Astro Project Source: https://github.com/tradex-app/tradex-chart/blob/master/src/docs/README.md Common npm commands to manage and develop an Astro project. These include installing dependencies, starting a local development server, building the production site, and previewing the build. Ensure you are in the project's root directory when running these commands. ```bash npm install npm run dev npm run build npm run preview npm run astro ... npm run astro -- --help ``` -------------------------------- ### Start Development Server (Shell) Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/guides/development/local-setup/index.html Starts the Vite development server, enabling hot module replacement (HMR) for instant updates during development. Accessible at http://localhost:5173. ```shell npm run dev ``` -------------------------------- ### Example Chart Component Modification (JavaScript) Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/guides/development/local-setup/index.html An example illustrating how to modify a chart component within the 'src/components/' directory. ```javascript // src/components/chart.js export class Chart { // Your changes here } ``` -------------------------------- ### Troubleshooting: Port Already in Use (Shell) Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/guides/development/local-setup/index.html Instructions for handling port conflicts when starting the development server, either by letting Vite choose the next available port or specifying a custom port. ```shell # Vite will automatically try the next available port # Or specify a different port vite --port 3000 ``` -------------------------------- ### Install and Configure TALib Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/guides/faq/index.html Instructions for installing the talib-web library via npm and configuring it within the TradeX Chart. This is necessary for using indicators. ```javascript npm install talib-web import * as talib from 'talib-web' const config = { talib: talib } ``` -------------------------------- ### Create and Mount Tradex Chart using JavaScript Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/reference/01_getting_started/index.html Shows how to create a Tradex Chart element dynamically using JavaScript and append it to a specified DOM element. This method is useful for programmatic chart instantiation. ```javascript import { Chart } from 'tradex-chart' // Create an empty chart and insert it into the DOM let chart = document.createElement("tradex-chart") let mount = document.getElementById("mount") mount.appendChild(chart) ``` -------------------------------- ### JavaScript Naming Conventions Example Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/guides/development/contributing-code/index.html Provides examples of recommended naming conventions for variables, functions, classes, constants, private members, and boolean flags in JavaScript. ```javascript // Variables and functions: camelCase const chartData = [] function calculateAverage() {} // Classes: PascalCase class ChartIndicator {} // Constants: UPPER_SNAKE_CASE const MAX_CANDLES = 10000 const DEFAULT_TIMEFRAME = '1h' // Private members: prefix with underscore class Chart { constructor() { this._privateData = [] } _privateMethod() {} } // Boolean variables: use is/has/should prefix const isVisible = true const hasData = false const shouldUpdate = true ``` -------------------------------- ### Initialize and Start Dialogue in Tradex Chart Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/reference/widgets/index.html Demonstrates how to instantiate and start a Dialogue widget using a configuration object. The `insert` method creates the dialogue, and `start` initializes it. ```javascript const config = {dragBar: true, closeIcon: true, title: "My Dialogue", content: "
This is the dialogue content.
", position: {x: 100, y: 100}, styles: {window: {background: "#f0f0f0"}}}; const dialogue = chart.WidgetsG.insert("Dialogue", config); dialogue.start(); ``` -------------------------------- ### API Examples Source: https://github.com/tradex-app/tradex-chart/blob/master/src/docs/dist2/api/real-time-websocket/index.html Links to examples demonstrating various API functionalities within the TradeX chart. ```APIDOC ## API Examples Reference ### Description This section provides links to various examples showcasing how to use the TradeX chart API for different functionalities. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A **Examples:** - [Custom Drawing Tools API](/TradeX-chart/api/custom-drawing-tools/) - [Custom Theme Builder API](/TradeX-chart/api/custom-theme-builder/) - [Export Chart Image API](/TradeX-chart/api/export-chart-image/) - [Indicator Alerts API](/TradeX-chart/api/indicator-alerts/) - [Mobile Responsive API](/TradeX-chart/api/mobile-responsive/) - [Multi-Chart Sync API](/TradeX-chart/api/multi-chart-sync/) ``` -------------------------------- ### Check Git Version Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/guides/development/local-setup/index.html Confirms that Git is installed and accessible in your system's PATH. Git is essential for version control operations like cloning, committing, and managing branches. ```shell git --version ``` -------------------------------- ### Create Astro Starlight Project Source: https://github.com/tradex-app/tradex-chart/blob/master/src/docs/README.md This command initiates the creation of a new Astro project using the Starlight template. It requires Node.js and npm to be installed. The command will prompt for project details and set up the basic file structure. ```bash npm create astro@latest -- --template starlight ``` -------------------------------- ### TradeX Chart Reference Guides Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/api/core-old/index.html This section provides access to reference materials for TradeX Chart, including introductions, getting started guides, configuration details, and explanations of various chart components. ```APIDOC ## TradeX Chart Reference Guides This section contains comprehensive reference materials for understanding and utilizing the TradeX Chart effectively. ### General Reference - **/TradeX-chart/reference/**: General introduction to the reference documentation. - **/TradeX-chart/reference/00_introduction/**: Detailed introduction to TradeX Chart. - **/TradeX-chart/reference/01_getting_started/**: Guide to get started with TradeX Chart. - **/TradeX-chart/reference/02_configuration/**: Information on chart configuration options. - **/TradeX-chart/reference/glossary/**: Glossary of terms used in TradeX Chart. - **/TradeX-chart/reference/architecture/**: Explanation of the TradeX Chart architecture. ### Component and Feature References - **/TradeX-chart/reference/annotations/**: Documentation on chart annotations. - **/TradeX-chart/reference/api-examples/**: Examples of using the TradeX Chart API. - **/TradeX-chart/reference/canvas_extension_layers/**: Details on canvas extension layers. - **/TradeX-chart/reference/canvas_methods/**: Reference for canvas-related methods. - **/TradeX-chart/reference/datasource/**: Information on data sources for the chart. - **/TradeX-chart/reference/events/**: Documentation on chart events. - **/TradeX-chart/reference/hit_detection/**: Explanation of hit detection mechanisms. - **/TradeX-chart/reference/indicators/**: General information about indicators. - **/TradeX-chart/reference/indicators_custom/**: Guide to custom indicators. - **/TradeX-chart/reference/indicators_default/**: Documentation on default indicators. - **/TradeX-chart/reference/indicators_talib/**: Information on TA-Lib functions integration. - **/TradeX-chart/reference/legends/**: Documentation on chart legends. - **/TradeX-chart/reference/overlays/**: General information about chart overlays. - **/TradeX-chart/reference/overlays_custom/**: Guide to custom overlays. - **/TradeX-chart/reference/overlays_news_events/**: Documentation on overlaying news events. - **/TradeX-chart/reference/overlays_trades/**: Information on overlaying trade data. - **/TradeX-chart/reference/range/**: Details on managing the chart's range. - **/TradeX-chart/reference/state/**: Documentation on chart state management. - **/TradeX-chart/reference/state_machine/**: Explanation of the chart's state machine. - **/TradeX-chart/reference/streaming_price_data/**: Guide to streaming price data to the chart. - **/TradeX-chart/reference/themes/**: Documentation on chart themes. - **/TradeX-chart/reference/web_workers/**: Information on using web workers with the chart. - **/TradeX-chart/reference/widgets/**: Documentation on available chart widgets. ### Other References - **/TradeX-chart/reference/example/**: General example reference. - **/TradeX-chart/reference/changelog/**: Changelog for TradeX Chart. ``` -------------------------------- ### Astro Project Structure Overview Source: https://github.com/tradex-app/tradex-chart/blob/master/src/docs/README.md An overview of the standard file and folder structure for an Astro project utilizing Starlight. Key directories include `public/` for static assets, `src/content/docs/` for Markdown/MDX documentation files, and configuration files like `astro.config.mjs`. ```bash . ├── public/ ├── src/ │ ├── assets/ │ ├── content/ │ │ ├── docs/ │ │ └── config.ts │ └── env.d.ts ├── astro.config.mjs ├── package.json └── tsconfig.json ``` -------------------------------- ### Install Canvas Module Dependencies Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/guides/development/local-setup/index.html Installs necessary dependencies for the canvas module on Ubuntu/Debian and macOS systems. These dependencies are crucial for the canvas module to compile and function correctly. After installing these, the 'npm install canvas' command should be run. ```shell # On Ubuntu/Debian sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev # On macOS brew install pkg-config cairo pango libpng jpeg giflib librsvg # Then reinstall npm install canvas ``` -------------------------------- ### Start Tradex Chart Instance Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/reference/02_configuration/index.html Initializes and starts a Tradex Chart instance with a provided configuration object after the chart has been mounted to the DOM. This is the primary method for rendering the chart. ```javascript import { Chart } from 'tradex-chart' // After the chart has mounted on the DOM, // provide it with a configuration object chart.start(config) ``` -------------------------------- ### Indicator Visibility Source: https://github.com/tradex-app/tradex-chart/blob/master/src/docs/src/content/docs/reference/api-examples.md Set or get the visibility status of an indicator. ```APIDOC ## Set/Get Indicator Visibility ### Description Sets or gets the visibility status of an indicator. The method accepts a boolean to set the indicator visibility and also returns a boolean of the current state. ### Method `indicatorInstance.visible(visibility: boolean): boolean` ### Endpoint `indicatorInstance` (obtained via `chartInstance.ChartPanes.get(paneId).indicators[indicatorId].instance`) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript // Get current indicator visibility const isVisible = chart1.ChartPanes.get("TradeX_test-RSI__20_3").indicators["TradeX_test-RSI__20_3-RSI_5"].instance.visible() // Set indicator visibility to not visible (false) chart1.ChartPanes.get("TradeX_test-RSI__20_3").indicators["TradeX_test-RSI__20_3-RSI_5"].instance.visible(false) // Set indicator visibility to visible (true) chart1.ChartPanes.get("TradeX_test-RSI__20_3").indicators["TradeX_test-RSI__20_3-RSI_5"].instance.visible(true) ``` ### Response #### Success Response (boolean) Returns `true` if the indicator is visible, `false` otherwise. #### Response Example ```json true ``` ```json false ``` ``` -------------------------------- ### Configuration Example: Adding Optional Overlays Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/reference/overlays/index.html Demonstrates how to enable optional overlays like Scale Price Line, Chart High Low, and Chart Watermark through chart configuration. It shows the specific keys and values used in the configuration object. ```javascript { // ... other configuration options "stream": {}, "hightLow": true, "watermark": { "text": "text goes here" } } ``` -------------------------------- ### Create and Start DataSource Source: https://github.com/tradex-app/tradex-chart/blob/master/docs/reference/datasource/index.html Demonstrates how to create a DataSource instance with custom configuration, including a data source with a range limit past function, and then start real-time data streaming. ```javascript import DataSource from './dataSource.js'; // Create a data source const config = { symbol: 'BTC/USDT', timeFrameInit: 3600000, // 1 hour source: { name: 'binance', rangeLimitPast: async (event, symbol, tf, timestamp) => { // Fetch historical data return await fetchHistoricalData(symbol, tf, timestamp); } } }; const dataSource = DataSource.create(config, chartState); // Start real-time data dataSource.startTickerHistory({ symbol: 'BTC/USDT', tf: 3600000, rangeLimitPast: fetchHistoricalData, start: startTickerStream, stop: stopTickerStream }); ``` -------------------------------- ### Create Basic TradeX Chart Instance Source: https://context7.com/tradex-app/tradex-chart/llms.txt Demonstrates how to create and mount a basic TradeX chart instance using minimal configuration. It requires a DOM container, configuration object including title and TALib reference, and optional OHLCV price data. The code imports the Chart class and TALib, defines sample price data and configuration, then creates and initializes the chart element. ```javascript import { Chart } from 'tradex-chart'; import * as talib from 'talib-web'; // Minimal OHLCV price data: [timestamp, open, high, low, close, volume] const state = { ohlcv: [ [1543579200000, 4035.6, 4072.78, 3965.0, 4055.6, 2157.50], [1543582800000, 4055.6, 4100.0, 4035.0, 4059.17, 1660.61], [1543586400000, 4059.1, 4076.6, 4014.1, 4060.0, 1070.09], [1543590000000, 4060.5, 4060.5, 3987.2, 4049.2, 1530.46], [1543593600000, 4049.2, 4092.7, 4035.0, 4089.66, 922.84] ] }; const config = { id: "myChart", title: "BTC/USDT", symbol: "btcusdt", width: 1000, height: 600, timeFrame: "1h", talib: talib, wasm: `${window.location.origin}/talib.wasm`, state: state }; // Create and mount the chart const container = document.getElementById('chartContainer'); const chart = document.createElement('tradex-chart'); container.appendChild(chart); chart.start(config); // Access chart properties after initialization console.log('Chart ID:', chart.ID); console.log('Time Frame:', chart.timeFrameStr); console.log('Price Data Length:', chart.state.data.chart.data.length); ``` -------------------------------- ### Install Canvas Dependencies on macOS Source: https://github.com/tradex-app/tradex-chart/blob/master/src/docs/src/content/docs/guides/development/local-setup.md These bash commands install the necessary system dependencies for the 'canvas' module on macOS using Homebrew. This is a prerequisite for using the canvas module in projects. ```bash # On macOS brew install pkg-config cairo pango libpng jpeg giflib librsvg ``` -------------------------------- ### Install Canvas Dependencies on Ubuntu/Debian Source: https://github.com/tradex-app/tradex-chart/blob/master/src/docs/src/content/docs/guides/development/local-setup.md These bash commands install the necessary system dependencies for the 'canvas' module on Ubuntu or Debian-based Linux systems. This is often required for projects that use canvas for image manipulation or testing. ```bash # On Ubuntu/Debian sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev ``` -------------------------------- ### Markdown Documentation Example Source: https://github.com/tradex-app/tradex-chart/blob/master/src/docs/src/content/docs/guides/contributing.md Shows an example of Markdown documentation structure, including frontmatter for title and description, headings, and code blocks. Demonstrates how to embed JavaScript code snippets within documentation to illustrate usage. ```markdown --- title: Adding Indicators description: Learn how to add technical indicators to your chart --- # Adding Indicators Technical indicators help analyze price movements. ## Basic Usage ```javascript // Add an indicator chart.addIndicator('RSI', { period: 14 }) ``` ## Available Indicators - **RSI** - Relative Strength Index - **MACD** - Moving Average Convergence Divergence - **EMA** - Exponential Moving Average See [Indicators Reference](../reference/indicators) for the complete list. ``` -------------------------------- ### Create TradeX Chart element in HTML Source: https://github.com/tradex-app/tradex-chart/blob/master/src/docs/src/content/docs/reference/01_getting_started.md Use TradeX Chart as a custom HTML element directly within your HTML structure. ```html