Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
44936a9b
Commit
44936a9b
authored
Mar 07, 2019
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ge barchart, negative bars added
parent
ca126d0d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
152 additions
and
56 deletions
+152
-56
xtt/lib/glow/src/glow_growbarchart.cpp
xtt/lib/glow/src/glow_growbarchart.cpp
+152
-56
No files found.
xtt/lib/glow/src/glow_growbarchart.cpp
View file @
44936a9b
...
...
@@ -360,8 +360,10 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
int
skip
;
int
bar_ll_x
,
bar_ur_x
;
int
bar_ll_y
,
bar_ur_y
;
double
f_bar_ll_y
;
int
bar_up_ll_y
,
bar_up_ur_y
;
double
f_bar_up_ll_y
;
int
bar_down_ll_y
,
bar_down_ur_y
,
border_bar_down_ur_y
;
double
f_bar_down_ur_y
;
double
width
;
int
brect_ll_x
=
0
,
brect_ll_y
=
0
,
brect_width
=
0
,
brect_height
=
0
;
...
...
@@ -375,32 +377,99 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
else
bar_ur_x
=
ll_x
+
(
j
+
1
)
*
width
;
bar_ll_y
=
ur_y
;
f_bar_ll_y
=
ur_y
;
if
(
min_value
>=
0
)
{
bar_up_ll_y
=
ur_y
;
f_bar_up_ll_y
=
ur_y
;
}
else
{
bar_up_ll_y
=
ur_y
+
min_value
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
f_bar_up_ll_y
=
bar_up_ll_y
;
bar_down_ur_y
=
ur_y
+
min_value
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
f_bar_down_ur_y
=
bar_down_ur_y
;
}
for
(
int
i
=
0
;
i
<
barsegments
+
1
;
i
++
)
{
glow_eDrawType
fillcolor
=
glow_eDrawType_Line
;
if
(
min_value
>
0
||
bar_values
[
i
][
j
]
>
0
)
{
skip
=
0
;
bar_ur_y
=
bar
_ll_y
;
bar_up_ur_y
=
bar_up
_ll_y
;
if
(
i
==
barsegments
)
{
if
(
bar
_ll_y
<=
ll_y
)
if
(
bar_up
_ll_y
<=
ll_y
)
skip
=
1
;
else
bar
_ll_y
=
ll_y
;
bar_up
_ll_y
=
ll_y
;
fillcolor
=
ctx
->
get_drawtype
(
fill_drawtype
,
glow_eDrawType_FillHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
1
);
}
else
{
if
(
bar_values
[
i
][
j
]
<=
min_value
)
skip
=
1
;
else
if
(
bar
_ur_y
<=
ll_y
)
else
if
(
bar_up
_ur_y
<=
ll_y
)
skip
=
1
;
else
{
f_bar_ll_y
-=
(
bar_values
[
i
][
j
]
-
min_value
)
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
bar_ll_y
=
f_bar_ll_y
;
if
(
bar_ll_y
<
ll_y
)
bar_ll_y
=
ll_y
;
f_bar_up_ll_y
-=
bar_values
[
i
][
j
]
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
bar_up_ll_y
=
f_bar_up_ll_y
;
if
(
bar_up_ll_y
<
ll_y
)
bar_up_ll_y
=
ll_y
;
fillcolor
=
ctx
->
get_drawtype
(
bar_color
[
i
],
glow_eDrawType_FillHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
1
);
}
}
if
(
!
skip
)
{
if
(
grad
==
glow_eGradient_No
||
fillcolor
==
glow_eDrawType_ColorRed
||
i
==
barsegments
)
{
if
(
chot
)
drawtype
=
GlowColor
::
shift_drawtype
(
fillcolor
,
chot
,
0
);
else
drawtype
=
fillcolor
;
ctx
->
gdraw
->
fill_rect
(
w
,
bar_ll_x
,
bar_up_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_up_ur_y
-
bar_up_ll_y
,
drawtype
);
}
else
{
glow_eDrawType
f1
,
f2
;
if
(
gradient_contrast
>=
0
)
{
f2
=
GlowColor
::
shift_drawtype
(
fillcolor
,
-
gradient_contrast
/
2
+
chot
,
0
);
f1
=
GlowColor
::
shift_drawtype
(
fillcolor
,
int
(
float
(
gradient_contrast
)
/
2
+
0.6
)
+
chot
,
0
);
}
else
{
f2
=
GlowColor
::
shift_drawtype
(
fillcolor
,
-
int
(
float
(
gradient_contrast
)
/
2
-
0.6
)
+
chot
,
0
);
f1
=
GlowColor
::
shift_drawtype
(
fillcolor
,
gradient_contrast
/
2
+
chot
,
0
);
}
ctx
->
gdraw
->
gradient_fill_rect
(
w
,
bar_ll_x
,
bar_up_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_up_ur_y
-
bar_up_ll_y
,
fillcolor
,
f1
,
f2
,
grad
);
}
}
}
else
{
// negative value, draw bar downwards
skip
=
0
;
bar_down_ll_y
=
bar_down_ur_y
;
if
(
i
==
barsegments
)
{
border_bar_down_ur_y
=
bar_down_ur_y
;
if
(
bar_down_ur_y
>=
ur_y
)
skip
=
1
;
else
bar_down_ur_y
=
ur_y
;
fillcolor
=
ctx
->
get_drawtype
(
fill_drawtype
,
glow_eDrawType_FillHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
1
);
}
else
{
if
(
bar_values
[
i
][
j
]
>=
0
)
skip
=
1
;
else
if
(
bar_down_ll_y
>=
ur_y
)
skip
=
1
;
else
{
f_bar_down_ur_y
-=
bar_values
[
i
][
j
]
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
bar_down_ur_y
=
f_bar_down_ur_y
;
if
(
bar_down_ur_y
>
ur_y
)
bar_down_ur_y
=
ur_y
;
fillcolor
=
ctx
->
get_drawtype
(
bar_color
[
i
],
glow_eDrawType_FillHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
1
);
...
...
@@ -414,8 +483,8 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
drawtype
=
GlowColor
::
shift_drawtype
(
fillcolor
,
chot
,
0
);
else
drawtype
=
fillcolor
;
ctx
->
gdraw
->
fill_rect
(
w
,
bar_ll_x
,
bar
_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_ur_y
-
bar
_ll_y
,
drawtype
);
ctx
->
gdraw
->
fill_rect
(
w
,
bar_ll_x
,
bar_down
_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_down_ur_y
-
bar_down
_ll_y
,
drawtype
);
}
else
{
glow_eDrawType
f1
,
f2
;
if
(
gradient_contrast
>=
0
)
{
...
...
@@ -429,11 +498,13 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
f1
=
GlowColor
::
shift_drawtype
(
fillcolor
,
gradient_contrast
/
2
+
chot
,
0
);
}
ctx
->
gdraw
->
gradient_fill_rect
(
w
,
bar_ll_x
,
bar
_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_ur_y
-
bar
_ll_y
,
fillcolor
,
f1
,
f2
,
ctx
->
gdraw
->
gradient_fill_rect
(
w
,
bar_ll_x
,
bar_down
_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_down_ur_y
-
bar_down
_ll_y
,
fillcolor
,
f1
,
f2
,
grad
);
}
}
}
if
(
border
&&
i
==
barsegments
)
{
// Draw previous bar border
if
(
j
>
0
)
{
...
...
@@ -443,17 +514,40 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
ctx
->
gdraw
->
rect
(
w
,
brect_ll_x
,
brect_ll_y
,
brect_width
,
brect_height
,
drawtype
,
idx
,
0
);
}
if
(
!
skip
)
{
if
(
min_value
>=
0
)
{
brect_ll_x
=
bar_ll_x
;
brect_ll_y
=
bar_u
r
_y
;
brect_ll_y
=
bar_u
p_ll
_y
;
brect_width
=
bar_ur_x
-
bar_ll_x
;
brect_height
=
ur_y
-
bar_u
r
_y
;
brect_height
=
ur_y
-
bar_u
p_ll
_y
;
}
else
{
brect_ll_x
=
bar_ll_x
;
brect_ll_y
=
ll_y
;
brect_ll_y
=
bar_up_
ll_y
;
brect_width
=
bar_ur_x
-
bar_ll_x
;
brect_height
=
ur_y
-
ll_y
;
brect_height
=
ur_y
+
min_value
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
)
-
bar_up_ll_y
;
}
if
(
j
==
bars
-
1
)
{
// Draw last bar border
drawtype
=
ctx
->
get_drawtype
(
draw_type
,
glow_eDrawType_LineHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
0
);
ctx
->
gdraw
->
rect
(
w
,
brect_ll_x
,
brect_ll_y
,
brect_width
,
brect_height
,
drawtype
,
idx
,
0
);
}
// Draw negative bar border
if
(
min_value
<
0
)
{
if
(
j
>
0
)
{
drawtype
=
ctx
->
get_drawtype
(
draw_type
,
glow_eDrawType_LineHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
0
);
ctx
->
gdraw
->
rect
(
w
,
brect_ll_x
,
brect_ll_y
,
brect_width
,
brect_height
,
drawtype
,
idx
,
0
);
}
brect_ll_x
=
bar_ll_x
;
brect_ll_y
=
ur_y
+
min_value
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
brect_width
=
bar_ur_x
-
bar_ll_x
;
brect_height
=
border_bar_down_ur_y
-
brect_ll_y
;
if
(
j
==
bars
-
1
)
{
// Draw last bar border
drawtype
=
ctx
->
get_drawtype
(
draw_type
,
glow_eDrawType_LineHighlight
,
...
...
@@ -464,6 +558,8 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
}
}
}
}
}
drawtype
=
ctx
->
get_drawtype
(
line_color
,
glow_eDrawType_LineHighlight
,
...
...
Write
Preview
Markdown
is supported
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