@tradecanvas/commons
v0.6.0
Published
Shared types and utilities for @tradecanvas/chart
Downloads
1,169
Readme
@tradecanvas/commons
Shared types, utilities, constants, themes, i18n, and market presets for the @tradecanvas/chart library.
Live Demo | GitHub | Documentation
Install
You don't need to install this package directly. It's included as a dependency of @tradecanvas/chart.
npm install @tradecanvas/chartWhat's Inside
Types
All TypeScript interfaces and types used across the library:
OHLCBar,DataSeries,TimeFrame-- data formatChartOptions,ChartType,FeaturesConfig-- chart configurationTheme,ThemeName-- themingIndicatorPlugin,IndicatorDescriptor,IndicatorConfig-- indicatorsDrawingToolType,DrawingState,DrawingStyle-- drawing toolsTradingPosition,TradingOrder,TradingConfig-- trading overlayDataAdapter,StreamConfig,ConnectionState-- real-time streamingChartEventType,ChartEvent-- eventsMarketConfig,TradingSession-- market configuration
Themes
import { DARK_THEME, LIGHT_THEME } from '@tradecanvas/commons'19 customizable properties: background, text, candleUp, candleDown, grid, crosshair, volumeUp, volumeDown, and more.
Constants
- Default chart options and feature flags
- Market presets:
MARKET_HOSE,MARKET_HNX,MARKET_UPCOM,MARKET_CRYPTO,MARKET_NYSE - Vietnamese stock market color schemes
Utilities
computePriceRange()-- compute visible price range from OHLC datatimeframeToMs()-- convert timeframe string to millisecondsformatNumber(),formatVND(),formatVolumeLoc()-- number formatting- Color, math, precision, and data manipulation helpers
i18n
Built-in locales: English (en), Vietnamese (vi). Extensible via registerLocale().
Direct Usage
If you need just the types or utilities without the full chart:
import type { OHLCBar, TimeFrame, ChartType } from '@tradecanvas/commons'
import { DARK_THEME, computePriceRange, timeframeToMs } from '@tradecanvas/commons'