Period ratio compare
This commit is contained in:
parent
7143972341
commit
625bd9dd82
1
TODO.md
1
TODO.md
|
|
@ -15,7 +15,6 @@ List of TODO items for Panoramix
|
||||||
* Contribution to total (added to line chart already)
|
* Contribution to total (added to line chart already)
|
||||||
* Time comparison
|
* Time comparison
|
||||||
* Time ratios
|
* Time ratios
|
||||||
* Use legend shapes that match line markers (useful?)
|
|
||||||
* Line types (dash, dotted)
|
* Line types (dash, dotted)
|
||||||
|
|
||||||
## New Features
|
## New Features
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from wtforms import (
|
from wtforms import (
|
||||||
Field, Form, SelectMultipleField, SelectField, TextField, TextAreaField,
|
Field, Form, SelectMultipleField, SelectField, TextField, TextAreaField,
|
||||||
BooleanField)
|
BooleanField, IntegerField)
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -138,6 +138,11 @@ def form_factory(viz):
|
||||||
'contribution': BooleanField(
|
'contribution': BooleanField(
|
||||||
"Contribution", default=False,
|
"Contribution", default=False,
|
||||||
description="Compute the contribution to the total"),
|
description="Compute the contribution to the total"),
|
||||||
|
'num_period_compare': IntegerField(
|
||||||
|
"Period Ratio", default=None,
|
||||||
|
description=(
|
||||||
|
"Number of period to compare against, "
|
||||||
|
"this is relative to the granularity selected")),
|
||||||
}
|
}
|
||||||
field_css_classes = {k: ['form-control'] for k in px_form_fields.keys()}
|
field_css_classes = {k: ['form-control'] for k in px_form_fields.keys()}
|
||||||
select2 = [
|
select2 = [
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,17 @@
|
||||||
img.loading {
|
img.loading {
|
||||||
width: 30px;
|
width: 30px;
|
||||||
}
|
}
|
||||||
|
.row {
|
||||||
|
margin-right: -5px;
|
||||||
|
margin-left: -5px;
|
||||||
|
}
|
||||||
|
.col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
|
||||||
|
position: relative;
|
||||||
|
min-height: 1px;
|
||||||
|
padding-right: 5px;
|
||||||
|
padding-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
@ -167,7 +178,7 @@
|
||||||
|
|
||||||
$(".select2").select2();
|
$(".select2").select2();
|
||||||
$("form").slideDown("slow");
|
$("form").slideDown("slow");
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip({container: 'body'});
|
||||||
|
|
||||||
function set_filters(){
|
function set_filters(){
|
||||||
for (var i=1; i<10; i++){
|
for (var i=1; i<10; i++){
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,9 @@
|
||||||
.tickFormat(function (d) {return tickMultiFormat(new Date(d)); });
|
.tickFormat(function (d) {return tickMultiFormat(new Date(d)); });
|
||||||
chart.showLegend({{ "{}".format(viz.args.show_legend=='y')|lower }});
|
chart.showLegend({{ "{}".format(viz.args.show_legend=='y')|lower }});
|
||||||
chart.yAxis.tickFormat(d3.format('.3s'));
|
chart.yAxis.tickFormat(d3.format('.3s'));
|
||||||
{% if viz.args.contribution=='y' %}
|
{% if viz.args.contribution=='y' or viz.args.get("num_period_compare") %}
|
||||||
chart.yAxis.tickFormat(d3.format('.3p'));
|
chart.yAxis.tickFormat(d3.format('.3p'));
|
||||||
|
chart.y2Axis.tickFormat(d3.format('.3p'));
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% elif viz.chart_type == 'nvd3_bar' %}
|
{% elif viz.chart_type == 'nvd3_bar' %}
|
||||||
|
|
|
||||||
|
|
@ -322,6 +322,7 @@ class NVD3TimeSeriesViz(NVD3Viz):
|
||||||
'metrics',
|
'metrics',
|
||||||
'groupby', 'limit',
|
'groupby', 'limit',
|
||||||
('rolling_type', 'rolling_periods'),
|
('rolling_type', 'rolling_periods'),
|
||||||
|
('num_period_compare', None),
|
||||||
('show_brush', 'show_legend'),
|
('show_brush', 'show_legend'),
|
||||||
('rich_tooltip', 'y_axis_zero'),
|
('rich_tooltip', 'y_axis_zero'),
|
||||||
('y_log_scale', 'contribution')
|
('y_log_scale', 'contribution')
|
||||||
|
|
@ -346,6 +347,12 @@ class NVD3TimeSeriesViz(NVD3Viz):
|
||||||
dft = df.T
|
dft = df.T
|
||||||
df = (dft / dft.sum()).T
|
df = (dft / dft.sum()).T
|
||||||
|
|
||||||
|
num_period_compare = self.form_data.get("num_period_compare")
|
||||||
|
if num_period_compare:
|
||||||
|
num_period_compare = int(num_period_compare)
|
||||||
|
df = df / df.shift(num_period_compare)
|
||||||
|
df = df[num_period_compare:]
|
||||||
|
|
||||||
rolling_periods = args.get("rolling_periods")
|
rolling_periods = args.get("rolling_periods")
|
||||||
rolling_type = args.get("rolling_type")
|
rolling_type = args.get("rolling_type")
|
||||||
if rolling_periods and rolling_type:
|
if rolling_periods and rolling_type:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue