QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
LineSeries.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_LINESERIES_H
24#define QTRADINGVIEW_LINESERIES_H
25
26#include <QColor>
27#include <memory>
28#include "Series.h"
29#include "QTradingView/qtradingview_global.h"
30
31class QPainter;
32
33namespace QTradingView {
34
35struct DataPoint;
36class Viewport;
37class IScale;
38
44class QTRADINGVIEW_EXPORT LineSeries : public Series
45{
46public:
51 explicit LineSeries(const QList<DataPoint>& data = {});
55 ~LineSeries() override;
56
61 void setData(const QList<DataPoint>& data);
66 const QList<DataPoint>& data() const;
72 qint64 timestampAt(int index) const override;
77 int dataCount() const override;
78
79 // Style
80 void setColor(const QColor& color);
81 void setLineWidth(double width);
82 void setLineStyle(Qt::PenStyle style);
83 void setAntialiasing(bool enabled);
84
85 // Rendering
86 void render(QPainter* painter, const ViewPort& viewport, IScale* scale) override;
87 bool hitTest(const QPointF& point, int& outIndex) const override;
88 void calculateRange(int startIndex, int endIndex, double& outMin, double& outMax) const override;
89
90private:
91 QList<DataPoint> m_data;
92
93 QColor m_color;
94 double m_width;
95 Qt::PenStyle m_lineStyle;
96 bool m_antialiasing;
97};
98
99} // namespace QTradingView
100
101#endif // QTRADINGVIEW_LINESERIES_H
Abstract base class for value-to-pixel scaling in QTradingView.
Definition IScale.h:37
Represents a line chart series in QTradingView.
Definition LineSeries.h:45
~LineSeries() override
Destroys the LineSeries object.
Abstract base class for data series in QTradingView charts.
Definition Series.h:49
Manages the visible range and pixel mapping for chart bars.
Definition ViewPort.h:39