k_chart_multiple
A production-ready Flutter candlestick charting library. Render multiple market charts on the same screen, combine dozens of indicators, and wire the output into trading overlays, callbacks, and custom UI.
Preview

Feature Highlights
- Manage multiple
KChartWidgetinstances with custom sizing and scroll behavior. - Built-in main chart overlays (MA, BOLL) and 50+ secondary indicators via
List<SecondaryState>. - Candlesticks, timeline view, trend-line drawing, market depth, and volume bars out of the box.
- Fine-grained appearance control with
ChartStyle,ChartColors, localization, and time formatting. - Probability engine, trading markers (
TradeMark), and callbacks for strategy integration. - Ships with a fully working example and local data so you can run it immediately.
Getting Started
-
Add the dependency
dependencies: k_chart_multiple: ^1.1.0 -
Import the package
import 'package:k_chart_multiple/flutter_k_chart.dart'; -
Prepare data
final raw = await rootBundle.loadString('assets/chatData.json'); final List<dynamic> list = json.decode(raw)['data']; final datas = list .map((e) => KLineEntity.fromJson(e as Map<String, dynamic>)) .toList() .reversed .toList(); DataUtil.calculate(datas); // required: computes MA, indicators, probabilities, etc. -
Render a single chart
final chart = KChartWidget( datas, ChartStyle(), ChartColors(), isTrendLine: false, mainState: MainState.MA, secondaryStates: const [SecondaryState.MACD, SecondaryState.RSI], volHidden: false, showNowPrice: true, timeFormat: TimeFormat.YEAR_MONTH_DAY_WITH_HOUR, translations: kChartTranslations, onLoadMore: (isRightEdge) { if (isRightEdge) fetchMore(); }, );
Multiple Charts on One Screen
KChartWidget behaves like any other Flutter widget. Place it inside a ListView, GridView, or TabBarView. The sample below renders several indicator combinations in a grid:
class MultipleCharts extends StatelessWidget {
final List<List<SecondaryState>> secondaryCombos;
final List<KLineEntity> source;
const MultipleCharts({
super.key,
required this.secondaryCombos,
required this.source,
});
@override
Widget build(BuildContext context) {
return GridView.builder(
padding: const EdgeInsets.all(12),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 12,
crossAxisSpacing: 12,
childAspectRatio: 0.75,
),
itemCount: secondaryCombos.length,
itemBuilder: (_, index) {
return Card(
color: Colors.black,
child: KChartWidget(
source,
ChartStyle()
..childPadding = 8,
ChartColors(),
isTrendLine: false,
mainState: MainState.MA,
secondaryStates: secondaryCombos[index],
volHidden: index.isEven,
showNowPrice: true,
fixedLength: 2,
timeFormat: TimeFormat.YEAR_MONTH_DAY,
mainHeight: 260,
secondaryHeight: 90,
onSecondaryTap: (i) {
debugPrint('Tapped secondary chart $i of card $index');
},
),
);
},
);
}
}
Tips:
- Sharing the same
dataskeeps zoom and computations in sync across widgets; pass separate lists for independent data feeds. - Use
ValueNotifier, Provider, or your state manager of choice to toggle indicators, themes, or refresh data.
Configuration Overview
- Main chart modes:
MainState.MA,MainState.BOLL,MainState.NONE. - Secondary indicators: combine any entries from
SecondaryStateto render multiple panes. - Line mode:
isLine = trueswitches to timeline;isTrendLine = trueenables drawing tools. - Volume & grid: toggle with
volHiddenandhideGrid. - Appearance: adjust point width, spacing, padding (
ChartStyle) and all colors (ChartColors). - Layout: control heights via
mainHeightandsecondaryHeightor let the widget auto-balance. - Localization & time: provide
translationsand choose atimeFormat; default maps include English and Chinese out of the box. - Interactions & loading:
onLoadMore(bool isRightEdge)triggers when the view hits either edge.isOnDrag,onSecondaryTapreport drag state and secondary chart taps.isTapShowInfoDialog,showInfoDialog,materialInfoDialogcontrol the info window behavior.
Indicator Catalog
Main Chart Overlays
- MA (Moving Average): classic multi-period moving averages to smooth price action.
- BOLL (Bollinger Bands): middle moving average with upper/lower bands describing volatility.
- NONE: hide all primary overlays.
Secondary Indicators
- MACD: EMA difference with histogram, highlighting momentum shifts.
- KDJ: stochastic oscillator variant with fast
%K, slow%D, and%Jfor spike detection. - RSI: relative strength index, measuring overbought/oversold momentum.
- WR (Williams %R): short-term reversal oscillator anchored at recent highs/lows.
- CCI: commodity channel index for mean reversion setups.
- DMI: directional movement lines (+DI/-DI) for trend confirmation.
- TRIX: triple-smoothed EMA to emphasize long-term momentum turns.
- PPO: percentage price oscillator, a normalized MACD variant.
- TSI: true strength index, smoothing momentum with double EMA.
- ICHIMOKU: five-line cloud with shaded spans for support/resistance and trend direction.
- SAR: parabolic stop-and-reverse, useful for trailing stops.
- AROON: up/down oscillators and optional Aroon oscillator to gauge trend maturity.
- VORTEX: +VI/-VI tracks actionable directional impulses.
- ATR: average true range for absolute volatility.
- HV: historical volatility based on log returns.
- VWAP: volume-weighted average price, often used as an intraday benchmark.
- OBV: on-balance volume with optional EMA smoothing.
- ADL: accumulation/distribution line approximating money flow.
- VIX: local volatility proxy derived from price data.
- ADX: strength component of DMI; higher values imply strong trends.
- STDDEV: rolling standard deviation to quantify price dispersion.
- STOCHASTIC: smoothed stochastic oscillator for range-bound trading.
- WPR: classic Williams %R implementation for quick reversals.
- DEMARKER: compares highs/lows to measure exhaustion and reversals.
- MOMENTUM: simple price difference as raw momentum.
- MFI: money flow index combining RSI logic with volume.
- ENVELOPES: fixed-percentage bands around a moving average.
- VOLATILITY (ATR / Close): ATR normalized by price, convenient for percentage-based measures.
- CMF: Chaikin money flow, assessing buy vs sell pressure.
- CHAIKIN_OSC: fast/slow EMA of ADL to reveal turning points.
- KLINGER: volume oscillator with signal line to capture long-term trends.
- VPT: volume price trend, cumulative volume adjusted by price change.
- FORCE: Elder's force index, combining price change with volume.
- ROC: rate of change with optional signal line smoothing.
- ULTIMATE: multi-timeframe momentum oscillator blending different windows.
- CONNORS_RSI: composite score using RSI, streak length, and percentile rank.
- STOCH_RSI: stochastic transformation of RSI to expose internal rhythms.
- RVI: relative vigor index with signal line, weighting close vs open.
- DPO: detrended price oscillator to isolate cyclical swings.
- KAMA: Kaufman adaptive moving average adjusting smoothness by efficiency ratio.
- HMA: Hull moving average, fast-reacting yet smooth.
- KELTNER: EMA midline with ATR-based upper/lower channels.
- DONCHIAN: rolling high/low channel used by turtle strategies.
- BOLL_BANDWIDTH: ratio of Bollinger band width to midline, useful for volatility squeezes.
- CHAIKIN_VOLATILITY: change rate of high-low range; highlights volatility expansion/contraction.
- HV_PERCENTILE: places current historical volatility within its rolling percentile.
- ATR_PERCENTILE: percentile ranking of ATR for relative comparison.
- ELDER_RAY: bull/bear power plotted against EMA for trend validation.
- ICHIMOKU_SPAN Δ: difference between Span A and Span B, illustrating cloud thickness.
- PIVOT: classic pivot points with multi-level support/resistance bands.
- GANN_FAN: normalized Gann fan ratios for angle/time analysis.
- SUPER_TREND: ATR-driven trailing channel that changes color with trend direction.
- STC (Schaff Trend Cycle): MACD and stochastic hybrid with faster turn detection.
- QQE (Quantitative Qualitative Estimation): double-smoothed RSI plus signal line for cleaner entries.
- WAVE_TREND: multi-smoothed typical price oscillator, popular in crypto for top/bottom spotting.
- CMO (Chande Momentum Oscillator): compares aggregated gains vs losses for agile momentum readings.
- EOM (Ease of Movement): blends price range with volume to show how easily price travels.
- PVI/NVI: positive/negative volume indexes that follow price when volume expands or contracts.
Trading Marks & Probability Callbacks
- Use
TradeMarkto annotate strategy events on the main chart:final trades = [ TradeMark(index: 50, price: 26800, side: TradeSide.long, action: TradeAction.entry, label: 'Entry'), TradeMark(index: 120, price: 28400, side: TradeSide.long, action: TradeAction.tp, label: 'TP1'), ]; KChartWidget( datas, ChartStyle(), ChartColors(), isTrendLine: false, tradeMarks: trades, showTradeMarks: true, onGoingUp: (prob) => debugPrint('Secondary chart up probability: $prob'), onMainGoingUp: (prob) => debugPrint('Main chart up probability: $prob'), onUpProbs: (report) => debugPrint(report.toString()), ); DataUtil.calculatewrites composite probabilities intoKLineEntity.probabilityand feeds theonGoingUp/onGoingDown/onUpProbscallbacks so you can bridge to your strategy engine.
Working with Signal Providers
The lib/provider directory contains indicator-aware signal calculators (for example macd_signal_provider.dart, sar_signal_provider.dart). Typical workflow:
- Update
KLineEntitywith your market feed. - Call the relevant provider to compute buy/sell points or alerts.
- Render the outcome with
TradeMarkor a custom overlay.
Example App
example/lib/main.dartshowcases full UI composition, indicator toggles, drawing tools, and the depth chart.- Run the sample:
flutter pub get cd example flutter run
FAQ
- Why are indicators empty? Ensure
DataUtil.calculate(list)is called before rendering. - Time axis is wrong.
KLineEntity.timeexpects a millisecond timestamp. Convert seconds to milliseconds if needed. - Need more locales? Extend
translationsor supply your ownChartTranslationsimplementation.
Contributions are welcome—issues and PRs help grow the indicator set and customization options.
Libraries
- chart_style
- chart_translations
- depth_chart
- entity/adl_entity
- entity/adx_entiry
- entity/aroon_entity
- entity/atr_entity
- entity/atr_percentile_entity
- entity/boll_bandwidth_entity
- entity/bssignal_entity
- entity/candle_entity
- entity/cci_entity
- entity/chaikin_osc_entity
- entity/chaikin_vol_entity
- entity/cmf_entity
- entity/cmo_entity
- entity/connors_rsi_entity
- entity/dem_entiry
- entity/depth_entity
- entity/dmi_entity
- entity/donchian_entity
- entity/dpo_entity
- entity/elder_ray_entity
- entity/env_entity
- entity/eom_entity
- entity/force_index_entity
- entity/gann_fan_entity
- entity/hma_entity
- entity/hv_entity
- entity/hv_percentile_entity
- entity/ichimoku_entity
- entity/ichimoku_extra_entity
- entity/index
- entity/info_window_entity
- entity/k_entity
- entity/k_line_entity
- entity/kama_entity
- entity/kdj_entity
- entity/keltner_entity
- entity/klinger_entity
- entity/macd_entity
- entity/mfi_entity
- entity/momentum_entity
- entity/obv_entiry
- entity/pivot_entity
- entity/ppo_entity
- entity/pvi_nvi_entity
- entity/qqe_entity
- entity/roc_entity
- entity/rsi_entity
- entity/rvi_entity
- entity/rw_entity
- entity/sar_entity
- entity/stc_entity
- entity/std_entiry
- entity/stoch_entity
- entity/stoch_rsi_entity
- entity/supertrend_entity
- entity/trade_mark
- entity/trix_entity
- entity/tsi_entity
- entity/ultimate_osc_entity
- entity/up_prob_report
- entity/vix_entiry
- entity/voli_entity
- entity/volume_entity
- entity/vortex_entity
- entity/vpt_entity
- entity/vwap_entiry
- entity/wave_trend_entity
- entity/wpr_entity
- extension/map_ext
- extension/num_ext
- flutter_k_chart
- k_chart_widget
- provider/adl_signal_provider
- provider/adx_only_signal_provider
- provider/aroon_signal_provider
- provider/atr_signal_provider
- provider/boll_signal_provider
- provider/bssignal_provider
- provider/cci_signal_provider
- provider/dem_signal_provider
- provider/dmi_signal_provider
- provider/envelopes_signal_provider
- provider/hv_signal_provider
- provider/ichimoku_signal_provider
- provider/kdj_signal_provider
- provider/ma_cross_signal_provider
- provider/macd_signal_provider
- provider/mfi_signal_provider
- provider/momentum_signal_provider
- provider/neutral_signal_provider
- provider/obv_signal_provider
- provider/ppo_signal_provider
- provider/rsi_signal_provider
- provider/sar_signal_provider
- provider/signal_provider
- provider/stddev_signal_provider
- provider/stoch_signal_provider
- provider/trix_signal_provider
- provider/tsi_signal_provider
- provider/vix_signal_provider
- provider/volatility_signal_provider
- provider/vortex_signal_provider
- provider/vwap_signal_provider
- provider/wpr_signal_provider
- provider/wr_signal_provider
- renderer/base_chart_painter
- renderer/base_chart_renderer
- renderer/chart_painter
- renderer/index
- renderer/main_renderer
- renderer/secondary_renderer
- renderer/trend_line_state
- renderer/vol_renderer
- utils/data_util
- utils/date_format_util
- utils/index
- utils/number_util