Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benjamin Jakimow
EO Time Series Viewer
Commits
e62af590
Commit
e62af590
authored
Aug 17, 2012
by
Luke Campagnola
Browse files
Added custom graphicsitem example
parent
e2148085
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/customGraphicsItem.py
0 → 100644
View file @
e62af590
import
pyqtgraph
as
pg
from
pyqtgraph
import
QtCore
,
QtGui
class
CandlestickItem
(
pg
.
GraphicsObject
):
def
__init__
(
self
,
data
):
pg
.
GraphicsObject
.
__init__
(
self
)
self
.
data
=
data
## data must have fields: time, open, close, min, max
self
.
generatePicture
()
def
generatePicture
(
self
):
self
.
picture
=
QtGui
.
QPicture
()
p
=
QtGui
.
QPainter
(
self
.
picture
)
p
.
setPen
(
pg
.
mkPen
(
'w'
))
w
=
(
self
.
data
[
1
][
0
]
-
self
.
data
[
0
][
0
])
/
3.
for
(
t
,
open
,
close
,
min
,
max
)
in
self
.
data
:
p
.
drawLine
(
QtCore
.
QPointF
(
t
,
min
),
QtCore
.
QPointF
(
t
,
max
))
if
open
>
close
:
p
.
setBrush
(
pg
.
mkBrush
(
'r'
))
else
:
p
.
setBrush
(
pg
.
mkBrush
(
'g'
))
p
.
drawRect
(
QtCore
.
QRectF
(
t
-
w
,
open
,
w
*
2
,
close
-
open
))
p
.
end
()
def
paint
(
self
,
p
,
*
args
):
p
.
drawPicture
(
0
,
0
,
self
.
picture
)
def
boundingRect
(
self
):
return
QtCore
.
QRectF
(
self
.
picture
.
boundingRect
())
data
=
[
## fields are (time, open, close, min, max).
(
1.
,
10
,
13
,
5
,
15
),
(
2.
,
13
,
17
,
9
,
20
),
(
3.
,
17
,
14
,
11
,
23
),
(
4.
,
14
,
15
,
5
,
19
),
(
5.
,
15
,
9
,
8
,
22
),
(
6.
,
9
,
15
,
8
,
16
),
]
item
=
CandlestickItem
(
data
)
plt
=
pg
.
plot
()
plt
.
addItem
(
item
)
QtGui
.
QApplication
.
exec_
()
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment