QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
AxisRenderer.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_AXISRENDERER_H
24#define QTRADINGVIEW_AXISRENDERER_H
25
26#include <QPainter>
27#include <QRectF>
28#include <QColor>
29#include <QDateTime>
30
31#include "QTradingView/ViewPort.h"
32#include "QTradingView/Pane.h"
33#include "QTradingView/qtradingview_global.h"
34
35namespace QTradingView {
36
42struct TimeLabel {
50 QString label;
55};
56
62class QTRADINGVIEW_EXPORT AxisRenderer
63{
64public:
69
74 void setTextColor(const QColor& color);
75
80 void setTickColor(const QColor& color);
81
86 void setBorderColor(const QColor& color);
87
92 void setBackgroundColor(const QColor& color);
93
98 void setAxisWidth(int width);
99
107 void drawXAxis(QPainter* painter, const QRectF& axisRect,
108 const ViewPort& viewport, const Series* series);
109
117 void drawYAxis(QPainter* painter, const QRectF& leftAxisRect,
118 const QRectF& rightAxisRect, const Pane* pane);
119
126 static std::vector<TimeLabel> calculateXAxisLabels(const ViewPort& viewport, const Series* series);
127
128private:
129 QColor m_textColor;
130 QColor m_tickColor;
131 QColor m_borderColor;
132 QColor m_backgroundColor;
133 int m_axisWidth;
134};
135
136} // namespace QTradingView
137
138#endif // QTRADINGVIEW_AXISRENDERER_H
Renders chart axes, ticks, and labels for QTradingView.
Definition AxisRenderer.h:63
Represents a chart pane that contains one or more data series.
Definition Pane.h:44
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
Represents a label for a specific time on the X-axis.
Definition AxisRenderer.h:42
QString label
The text to display for the label.
Definition AxisRenderer.h:50
qint64 msSecsSinceEpoch
Milliseconds since epoch for the label position.
Definition AxisRenderer.h:46
int dataIndex
The index in the data series corresponding to this label.
Definition AxisRenderer.h:54