Skip to content

Commit

Permalink
feat: group comparisons
Browse files Browse the repository at this point in the history
feat: group comparisons

fix : lint fix
  • Loading branch information
Patil committed Jul 7, 2022
1 parent 8e8ac00 commit f629aa7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
3 changes: 2 additions & 1 deletion popmon/visualization/histogram_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,15 @@ def transform(self, data_obj: dict, sections: Optional[list] = None):
plot_type_layouts["heatmap"] = hplots[0]["layout"]

plots = hplots + plots
# print(plot_types,layouts)

features_w_metrics.append(
{
"name": feature,
"plot_type_layouts": plot_type_layouts,
"plots": plots,
}
)

sections.append(
{
"section_title": self.section_name,
Expand Down
43 changes: 34 additions & 9 deletions popmon/visualization/section_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from popmon.analysis.profiling import Profiles

from ..base import Module
from ..config import Report
from ..config import Comparison, Report, Settings
from ..utils import filter_metrics, parallel, short_date
from ..visualization.utils import _prune, plot_bars

Expand Down Expand Up @@ -126,7 +126,6 @@ def __init__(
self.skip_empty_plots = settings.skip_empty_plots
self.description = description
self.show_stats = settings.show_stats if not settings.extended_report else None

self.primary_color = settings.primary_color
self.tl_colors = settings.tl_colors

Expand Down Expand Up @@ -205,13 +204,39 @@ def transform(
if "range" in layouts["yaxis"]:
del layouts["yaxis"]["range"]

features_w_metrics.append(
{
"name": feature,
"plot_type_layouts": {"barplot": layouts},
"plots": sorted(plots, key=lambda plot: plot["name"]),
}
)
# Group comparisons in Comparison section
if self.section_name == "Comparisons":
prev_key = (
"Rolling Reference "
+ "(window = "
+ str(Comparison().window)
+ ", Shift = "
+ str(Comparison().shift)
+ ")"
)
reference_key = Settings().reference_type + " Reference"
grouped_metrics = {reference_key: [], prev_key: []}
for plot in plots:
if "ref" in plot["name"]:
grouped_metrics[reference_key].append(plot)
else:
grouped_metrics[prev_key].append(plot)

features_w_metrics.append(
{
"name": feature,
"plot_type_layouts": {"barplot": layouts},
"plots": grouped_metrics,
}
)
else:
features_w_metrics.append(
{
"name": feature,
"plot_type_layouts": {"barplot": layouts},
"plots": plots,
}
)

sections.append(
{
Expand Down
5 changes: 5 additions & 0 deletions popmon/visualization/templates/assets/css/custom-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ section {
padding: 70px 0
}

h3 {
width: calc(100% - 100px);
margin: 20px 20px 20px 20px;
}

a.nav-link {
cursor: pointer;
font-weight: 300;
Expand Down
13 changes: 13 additions & 0 deletions popmon/visualization/templates/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,25 @@ <h2>{{ section_title }}</h2>
{%- endfor -%}
</script>
<div class="row section_feature" data-section-feature="{{ feature.name }}">
{%- if feature.plots is mapping -%}
{%- for ref,plots in feature.plots.items() -%}
{%- set count = (plots|length + 1)*(loop.index - 1) -%}
<h3> {{ref}} </h3>
{%- for metric in plots -%}
{%- set plt = count + loop.index -%}
{%- with metric=metric -%}
{%- include 'card.html' -%}
{%- endwith -%}
{%- endfor -%}
{%- endfor -%}
{%- else -%}
{%- for metric in feature.plots -%}
{%- set plt = loop.index -%}
{%- with metric=metric -%}
{%- include 'card.html' -%}
{%- endwith -%}
{%- endfor -%}
{%- endif-%}
</div>
{%- endfor -%}
{%- else -%}
Expand Down

0 comments on commit f629aa7

Please sign in to comment.