SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit cbaf41ad authored by George Katsikas's avatar George Katsikas :goat:
Browse files

add unique option prefixes to plot kinds

parent c9c53afe
No related branches found
No related tags found
No related merge requests found
...@@ -125,7 +125,7 @@ class TimelinePlot(PlotKind): ...@@ -125,7 +125,7 @@ class TimelinePlot(PlotKind):
return x, y return x, y
class Options(BaseOptions): class Options(BaseOptions):
prefix = PlotKind.Options.prefix prefix = "timeline_plot_"
y_key = forms.CharField(label="Y-axis key", required=False, initial="id") y_key = forms.CharField(label="Y-axis key", required=False, initial="id")
x_lim_min = forms.DateTimeField( x_lim_min = forms.DateTimeField(
label="X min", label="X min",
...@@ -242,11 +242,13 @@ class MapPlot(PlotKind): ...@@ -242,11 +242,13 @@ class MapPlot(PlotKind):
Return the a tuple of lists of countries and their counts. Return the a tuple of lists of countries and their counts.
""" """
qs = self.plotter.get_queryset() qs = self.plotter.get_queryset()
prefix = "map_plot_"
count_key = self.options.get("count_key", "id") count_key = self.options.get("count_key", "id")
group_by_country_count = ( group_by_country_count = (
qs.filter(Q(**{self.plotter.country_key + "__isnull": False})) qs.filter(Q(**{self.plotter.country_key + "__isnull": False}))
.values(self.plotter.country_key) .values(self.plotter.country_key)
.annotate(count=Count(count_key)) .annotate(count=Count(count_key))
prefix = "map_plot_"
) )
countries, count = zip( countries, count = zip(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment