Architecture¶
QTradingView is designed as a small, modular charting library with a clear separation between layout, rendering and data. The main concepts are:
- Chart — top-level container that manages panes, input events, layout and a shared viewport. It owns the main render loop.
- Pane — a rectangular area inside a
Chartthat has its own Y-scale and renders one or moreSeries(candles, lines, bars). - ViewPort — shared viewport that tracks visible indices, bar width, and translates from data indices to pixel coordinates.
- Series — pluggable renderers that draw data to a
QPainterusing the pane's scale and the viewport for X-axis mapping. - Scales & Renderers — scale implementations (linear/log) implement the
IScaleinterface. Renderers such asAxisRenderer,GridRendererandCrosshairRendererdraw overlays and axis labels.
This separation enables partial redraws (only panes that changed are repainted), easy addition of new series types, and different scale strategies per pane.
For a class-level view, see the Doxygen-generated API under docs/api/ and the diagram in the repository README.
Typical flow¶
- User creates a
Chartand adds one or morePaneobjects. - The user attaches
Seriesinstances to panes and provides data containers. ViewPortdetermines which indices are visible; the chart requests each pane to render using that viewport.- Renderers convert data points to pixel coordinates using the pane's
IScaleimplementation and draw primitives withQPainter.
Extending the library¶
- To add a new series type, inherit from
QTradingView::Seriesand implement therendermethod. - To add a new scale, implement
IScaleand plug it into aPanewithsetScale.
Check the API docs (docs/api/) for interfaces, header-level documentation and examples in docs/examples/.