QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
Series.h
1/*
2 * Copyright (c) 2025 Dhruvan Gnanadhandayuthapani
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23#ifndef QTRADINGVIEW_ISERIES_H
24#define QTRADINGVIEW_ISERIES_H
25
26#include "QTradingView/qtradingview_global.h"
27
28class QPainter;
29class QPointF;
30class QDateTime;
31
32namespace QTradingView {
33
34class IScale;
35class ViewPort;
36
37enum class SeriesType {
38 Line,
39 Bar,
40 CandleStick
41};
42
48class QTRADINGVIEW_EXPORT Series
49{
50public:
55 explicit Series(SeriesType type) : m_type(type) {};
56
60 virtual ~Series() = default;
61
66 SeriesType type() const;
67
73 virtual qint64 timestampAt(int index) const = 0;
74
79 virtual int dataCount() const = 0;
80
87 virtual void render(QPainter* painter, const ViewPort& viewport, IScale* scale) = 0;
88
95 virtual bool hitTest(const QPointF& point, int& outIndex) const = 0;
96
104 virtual void calculateRange(int startIndex, int endIndex, double& outMin, double& outMax) const = 0;
105
106protected:
107 SeriesType m_type;
108};
109
110} // namespace QTradingView
111
112#endif // QTRADINGVIEW_ISERIES_H
Abstract base class for value-to-pixel scaling in QTradingView.
Definition IScale.h:37
Abstract base class for data series in QTradingView charts.
Definition Series.h:49
virtual void calculateRange(int startIndex, int endIndex, double &outMin, double &outMax) const =0
Calculates the data range (min/max values) within the given index range.
virtual ~Series()=default
Virtual destructor for Series.
virtual int dataCount() const =0
Returns the number of data points in the series.
Series(SeriesType type)
Constructs a Series of the given type.
Definition Series.h:55
virtual void render(QPainter *painter, const ViewPort &viewport, IScale *scale)=0
Renders the series within the given viewport and scale.
virtual bool hitTest(const QPointF &point, int &outIndex) const =0
Performs hit testing to find the nearest data point to the given position.
SeriesType type() const
Returns the type of the series.
virtual qint64 timestampAt(int index) const =0
Returns the timestamp for the data point at the given index.
Manages the visible range and pixel mapping for chart bars.
Definition ViewPort.h:39