QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
BarSeries.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_BARSERIES_H
24#define QTRADINGVIEW_BARSERIES_H
25
26#include <QColor>
27#include <QList>
28
29#include "Series.h"
30#include "QTradingView/Data.h"
31#include "QTradingView/qtradingview_global.h"
32
33namespace QTradingView {
34
40class QTRADINGVIEW_EXPORT BarSeries : public Series
41{
42public:
47 explicit BarSeries(const QList<DataPoint>& data = {});
51 ~BarSeries() override;
52
57 void setData(const QList<DataPoint>& data);
62 const QList<DataPoint>& data() const;
68 qint64 timestampAt(int index) const override;
73 int dataCount() const override;
74
79 void setUpColor(const QColor& color);
84 void setDownColor(const QColor& color);
89 void setBarWidthRatio(double ratio);
94 void setLineWidth(double width);
99 void setAntialiasing(bool enabled);
100
101 // Rendering
102 void render(QPainter* painter, const ViewPort& viewport, IScale* scale) override;
103 bool hitTest(const QPointF& point, int& outIndex) const override;
104 void calculateRange(int startIndex, int endIndex, double& outMin, double& outMax) const override;
105
106private:
107 QList<DataPoint> m_data;
108
109 QColor m_upColor;
110 QColor m_downColor;
111 double m_barWidthRatio;
112 double m_lineWidth;
113 bool m_antialiasing;
114};
115
116} // namespace QTradingView
117
118#endif // QTRADINGVIEW_BARSERIES_H
119
Represents a bar chart series in QTradingView.
Definition BarSeries.h:41
~BarSeries() override
Destroys the BarSeries object.
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
Manages the visible range and pixel mapping for chart bars.
Definition ViewPort.h:39