Repository navigation
Expand file tree
/
Copy pathOHLCGraph2D.cpp
More file actions
90 lines (78 loc) · 2.14 KB
/
Copy pathOHLCGraph2D.cpp
File metadata and controls
90 lines (78 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "wplot/OHLCGraph2D.h"
#include "wplot/Plot2D.h"
namespace WPlot {
///////////////////////////////////////////////////////////////////////////////
// PUBLIC SECTION //
///////////////////////////////////////////////////////////////////////////////
OHLCGraph2D::OHLCGraph2D() :
FinancialGraph2D(),
m_ohlcBar()
{
m_ohlcBar.setPivotCoordinates(Item2D::COORDINATE_PLOT, Item2D::AXIS_BOTH);
}
/**
* Set the color that the ohlc bar must assume when positive (close > open).
*
* @param[in] color Color.
*/
void OHLCGraph2D::setPositiveColor(const QColor &color) {
m_ohlcBar.setPositiveColor(color);
}
/**
* Set the color that the ohlc bar must assume when negative (close < open).
*
* @param[in] color Color.
*/
void OHLCGraph2D::setNegativeColor(const QColor &color) {
m_ohlcBar.setNegativeColor(color);
}
/**
* Set the color that the ohlc bar must assume when positive and negative.
*
* @param[in] positive Color assumed when positive.
* @param[in] negative Color assumed when negative.
*/
void OHLCGraph2D::setColor(const QColor &positive, const QColor &negative) {
m_ohlcBar.setColor(positive, negative);
}
/**
* Set ohlc bar line width.
*
* @param[in] width Width.
*/
void OHLCGraph2D::setLineWidth(const double &width) {
m_ohlcBar.setLineWidth(width);
}
/**
* Set ohlc bar line style.
*
* @param[in] style Style.
*/
void OHLCGraph2D::setStyle(const Qt::PenStyle &style) {
m_ohlcBar.setStyle(style);
}
/**
* Set ticks width.
*
* @param[in] width Width.
*/
void OHLCGraph2D::setTickWidth(const double &width) {
m_ohlcBar.setTickWidth(width);
}
///////////////////////////////////////////////////////////////////////////////
// VIRTUAL PUBLIC SECTION //
///////////////////////////////////////////////////////////////////////////////
/**
* Draw the graph.
*
* @param[in] plot Plot2D where graph must be plotted.
*/
void OHLCGraph2D::draw(Plot2D *plot) {
m_ohlcBar.setDrawingInPaddingArea(true);
for (auto& it : m_data) {
m_ohlcBar.setXValue(it.x);
m_ohlcBar.setOHLC(it.ohlc);
m_ohlcBar.draw(plot);
}
}
} // namespace WPlot