Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
9262bd34
Commit
9262bd34
authored
Mar 18, 2010
by
Richard Mansfield
Browse files
Add legend to graph
Signed-off-by:
Richard Mansfield
<
richardm@catalyst.net.nz
>
parent
dcb95ee5
Changes
1
Show whitespace changes
Inline
Side-by-side
htdocs/lib/registration.php
View file @
9262bd34
...
...
@@ -647,18 +647,13 @@ function graph_site_data_weekly() {
WHERE ctime >= ? AND type IN (?,?,?)
ORDER BY ctime, type'
,
$values
);
if
(
!
$weekly
)
{
if
(
!
count
(
$weekly
)
>
1
)
{
return
;
}
$dataarray
=
array
(
'user-count'
=>
array
(
0
),
'group-count'
=>
array
(
0
),
'view-count'
=>
array
(
0
));
$dateindex
=
array
();
$key
=
1
;
$dataarray
=
array
();
foreach
(
$weekly
as
&
$r
)
{
if
(
!
isset
(
$dateindex
[
$r
->
ctime
]))
{
$dateindex
[
$r
->
ctime
]
=
$key
++
;
}
$dataarray
[
$r
->
type
][
$dateindex
[
$r
->
ctime
]]
=
$r
->
value
;
$dataarray
[
$r
->
type
][
strftime
(
"%d
\n
%b"
,
$r
->
ts
)]
=
$r
->
value
;
}
require_once
(
get_config
(
'libroot'
)
.
"pear/Image/Graph.php"
);
...
...
@@ -667,18 +662,28 @@ function graph_site_data_weekly() {
$Font
=&
$Graph
->
addNew
(
'font'
,
'Vera'
);
$Font
->
setSize
(
8
);
$Graph
->
setFont
(
$Font
);
$Plotarea
=&
$Graph
->
addNew
(
'plotarea'
);
$colors
=
array
(
'user-count'
=>
'blue@0.8'
,
'view-count'
=>
'blue@0.6'
,
'group-count'
=>
'blue@0.4'
,
$Graph
->
add
(
Image_Graph
::
vertical
(
$Plotarea
=
Image_Graph
::
factory
(
'plotarea'
),
$Legend
=
Image_Graph
::
factory
(
'legend'
),
88
)
);
$Legend
->
setPlotarea
(
$Plotarea
);
$datasetinfo
=
array
(
'user-count'
=>
array
(
'color'
=>
'red@0.4'
,
'name'
=>
get_string
(
'users'
)),
'view-count'
=>
array
(
'color'
=>
'green@0.4'
,
'name'
=>
get_string
(
'views'
)),
'group-count'
=>
array
(
'color'
=>
'blue@0.4'
,
'name'
=>
get_string
(
'groups'
)),
);
foreach
(
$dataarray
as
$k
=>
&
$line
)
{
$dataset
=&
Image_Graph
::
factory
(
'dataset'
,
array
(
$line
));
foreach
(
array_keys
(
$datasetinfo
)
as
$k
)
{
$dataset
=&
Image_Graph
::
factory
(
'dataset'
,
array
(
$dataarray
[
$k
]));
$dataset
->
setName
(
$datasetinfo
[
$k
][
'name'
]);
$plot
=&
$Plotarea
->
addNew
(
'line'
,
array
(
&
$dataset
));
$linestyle
=&
Image_Graph
::
factory
(
'Image_Graph_Line_Solid'
,
array
(
$color
s
[
$k
]));
$linestyle
=&
Image_Graph
::
factory
(
'Image_Graph_Line_Solid'
,
array
(
$
datasetinfo
[
$k
][
'
color
'
]));
$linestyle
->
setThickness
(
3
);
$plot
->
setLineStyle
(
$linestyle
);
}
...
...
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