Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
9d57a918
Commit
9d57a918
authored
Dec 30, 2005
by
karl%kornel.name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 248581: range of y-axis for graphs is double the max value - r=wicked a=justdave
parent
c1508f6d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
Chart.pm
Bugzilla/Chart.pm
+59
-0
chart.png.tmpl
template/en/default/reports/chart.png.tmpl
+1
-0
No files found.
Bugzilla/Chart.pm
View file @
9d57a918
...
...
@@ -18,6 +18,8 @@
# Rights Reserved.
#
# Contributor(s): Gervase Markham <gerv@gerv.net>
# Albert Ting <altlst@sonic.net>
# A. Karl Kornel <karl@kornel.name>
use
strict
;
use
lib
"."
;
...
...
@@ -207,6 +209,7 @@ sub data {
sub
readData
{
my
$self
=
shift
;
my
@data
;
my
@maxvals
;
# Note: you get a bad image if getSeriesIDs returns nothing
# We need to handle errors better.
...
...
@@ -254,10 +257,15 @@ sub readData {
my
$gt_index
=
$self
->
{
'gt'
}
?
scalar
(
@
{
$self
->
{
'lines'
}})
:
undef
;
my
$line_index
=
0
;
$maxvals
[
$gt_index
]
=
0
if
$gt_index
;
my
@datediff_total
;
foreach
my
$line
(
@
{
$self
->
{
'lines'
}})
{
# Even if we end up with no data, we need an empty arrayref to prevent
# errors in the PNG-generating code
$data
[
$line_index
]
=
[]
;
$maxvals
[
$line_index
]
=
0
;
foreach
my
$series
(
@$line
)
{
...
...
@@ -274,18 +282,69 @@ sub readData {
my
(
$datediff
,
$value
)
=
@$point
;
$data
[
$line_index
][
$datediff
]
||=
0
;
$data
[
$line_index
][
$datediff
]
+=
$value
;
if
(
$data
[
$line_index
][
$datediff
]
>
$maxvals
[
$line_index
])
{
$maxvals
[
$line_index
]
=
$data
[
$line_index
][
$datediff
];
}
$datediff_total
[
$datediff
]
+=
$value
;
# Add to the grand total, if we are doing that
if
(
$gt_index
)
{
$data
[
$gt_index
][
$datediff
]
||=
0
;
$data
[
$gt_index
][
$datediff
]
+=
$value
;
if
(
$data
[
$gt_index
][
$datediff
]
>
$maxvals
[
$gt_index
])
{
$maxvals
[
$gt_index
]
=
$data
[
$gt_index
][
$datediff
];
}
}
}
}
# We are done with the series making up this line, go to the next one
$line_index
++
;
}
# calculate maximum y value
if
(
$self
->
{
'cumulate'
})
{
# Make sure we do not try to take the max of an array with undef values
my
@processed_datediff
;
while
(
@datediff_total
)
{
my
$datediff
=
shift
@datediff_total
;
push
@processed_datediff
,
$datediff
if
defined
(
$datediff
);
}
$self
->
{
'y_max_value'
}
=
Bugzilla::Util::
max
(
@processed_datediff
);
}
else
{
$self
->
{
'y_max_value'
}
=
Bugzilla::Util::
max
(
@maxvals
);
}
$self
->
{
'y_max_value'
}
|=
1
;
# For log()
# Align the max y value:
# For one- or two-digit numbers, increase y_max_value until divisible by 8
# For larger numbers, see the comments below to figure out what's going on
if
(
$self
->
{
'y_max_value'
}
<
100
)
{
do
{
++
$self
->
{
'y_max_value'
};
}
while
(
$self
->
{
'y_max_value'
}
%
8
!=
0
);
}
else
{
# First, get the # of digits in the y_max_value
my
$num_digits
=
1
+
int
(
log
(
$self
->
{
'y_max_value'
})
/
log
(
10
));
# We want to zero out all but the top 2 digits
my
$mask_length
=
$num_digits
-
2
;
$self
->
{
'y_max_value'
}
/=
10
**
$mask_length
;
$self
->
{
'y_max_value'
}
=
int
(
$self
->
{
'y_max_value'
});
$self
->
{
'y_max_value'
}
*=
10
**
$mask_length
;
# Add 10^$mask_length to the max value
# Continue to increase until it's divisible by 8 * 10^($mask_length-1)
# (Throwing in the -1 keeps at least the smallest digit at zero)
do
{
$self
->
{
'y_max_value'
}
+=
10
**
$mask_length
;
}
while
(
$self
->
{
'y_max_value'
}
%
(
8
*
(
10
**
(
$mask_length
-
1
)))
!=
0
);
}
# Add the x-axis labels into the data structure
my
$date_progression
=
generateDateProgression
(
$datefrom
,
$dateto
);
unshift
(
@data
,
$date_progression
);
...
...
template/en/default/reports/chart.png.tmpl
View file @
9d57a918
...
...
@@ -35,6 +35,7 @@
graph.set(x_label => x_label,
y_label => y_label,
y_tick_number => 8,
y_max_value => chart.y_max_value,
x_label_position => 0.5,
x_labels_vertical => 1,
x_label_skip => x_label_skip,
...
...
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