SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
610eab2f
Commit
610eab2f
authored
5 months ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add timeline plot and publication date plotter
parent
cc331113
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scipost_django/graphs/graphs/plotkind.py
+23
-0
23 additions, 0 deletions
scipost_django/graphs/graphs/plotkind.py
scipost_django/graphs/graphs/plotter.py
+29
-0
29 additions, 0 deletions
scipost_django/graphs/graphs/plotter.py
with
52 additions
and
0 deletions
scipost_django/graphs/graphs/plotkind.py
+
23
−
0
View file @
610eab2f
...
...
@@ -65,3 +65,26 @@ class PlotKind:
x
,
y
=
self
.
get_data
(
plotter
)
ax
.
plot
(
x
,
y
)
return
fig
class
TimelinePlot
(
PlotKind
):
name
=
"
timeline
"
def
plot
(
self
,
plotter
:
"
ModelFieldPlotter
"
):
fig
=
super
().
plot
(
plotter
)
ax
=
fig
.
get_axes
()[
0
]
ax
.
set_xlabel
(
plotter
.
date_key
)
ax
.
set_ylabel
(
self
.
options
.
get
(
"
y_key
"
,
"
id
"
))
return
fig
def
get_data
(
self
,
plotter
:
"
ModelFieldPlotter
"
,
**
kwargs
):
y_key
=
self
.
options
.
get
(
"
y_key
"
,
"
id
"
)
x
,
y
=
zip
(
*
plotter
.
get_queryset
().
values_list
(
plotter
.
date_key
,
y_key
))
return
x
,
y
class
Options
(
BaseOptions
):
prefix
=
PlotKind
.
Options
.
prefix
y_key
=
forms
.
CharField
(
label
=
"
Y-axis key
"
,
required
=
False
,
initial
=
"
id
"
)
This diff is collapsed.
Click to expand it.
scipost_django/graphs/graphs/plotter.py
+
29
−
0
View file @
610eab2f
...
...
@@ -4,7 +4,11 @@ __license__ = "AGPL v3"
from
abc
import
ABC
from
typing
import
TYPE_CHECKING
,
Any
from
django
import
forms
from
matplotlib.figure
import
Figure
from
journals.models.journal
import
Journal
from
journals.models.publication
import
Publication
from
series.models
import
Collection
from
.options
import
BaseOptions
...
...
@@ -71,3 +75,28 @@ class ModelFieldPlotter(ABC):
fig
.
suptitle
(
options
.
get
(
"
title
"
,
None
))
return
fig
class
PublicationDatePlotter
(
ModelFieldPlotter
):
model
=
Publication
name
=
"
Publication Date
"
date_key
=
"
publication_date
"
class
Options
(
BaseOptions
):
prefix
=
ModelFieldPlotter
.
Options
.
prefix
journals
=
forms
.
ModelChoiceField
(
queryset
=
Journal
.
objects
.
all
().
active
(),
required
=
False
)
collections
=
forms
.
ModelChoiceField
(
queryset
=
Collection
.
objects
.
all
(),
required
=
False
)
def
get_queryset
(
self
):
qs
=
super
().
get_queryset
()
if
journal
:
=
self
.
options
.
get
(
"
journals
"
,
None
):
qs
=
qs
.
for_journal
(
journal
.
name
)
if
collections
:
=
self
.
options
.
get
(
"
collections
"
,
None
):
qs
=
qs
.
filter
(
collections__in
=
[
collections
])
return
qs
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment