File tree Expand file tree Collapse file tree
erpnext/selling/report/sales_analytics Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,6 +73,18 @@ frappe.query_reports["Sales Analytics"] = {
7373 default : "Monthly" ,
7474 reqd : 1 ,
7575 } ,
76+ {
77+ fieldname : "curves" ,
78+ label : __ ( "Curves" ) ,
79+ fieldtype : "Select" ,
80+ options : [
81+ { value : "all" , label : __ ( "All" ) } ,
82+ { value : "non-zeros" , label : __ ( "Non-Zeros" ) } ,
83+ { value : "total" , label : __ ( "Total Only" ) } ,
84+ ] ,
85+ default : "all" ,
86+ reqd : 1 ,
87+ } ,
7688 {
7789 fieldname : "show_aggregate_value_from_subsidiary_companies" ,
7890 label : __ ( "Show Aggregate Value from Subsidiary Companies" ) ,
Original file line number Diff line number Diff line change @@ -460,7 +460,31 @@ def get_chart_data(self):
460460 labels = [d .get ("label" ) for d in self .columns [3 : length - 1 ]]
461461 else :
462462 labels = [d .get ("label" ) for d in self .columns [1 : length - 1 ]]
463- self .chart = {"data" : {"labels" : labels , "datasets" : []}, "type" : "line" }
463+
464+ datasets = []
465+ for curve in self .data :
466+ data = {
467+ "name" : curve .get ("entity_name" , curve ["entity" ]),
468+ "values" : [curve .get (scrub (label ), 0 ) for label in labels ],
469+ }
470+ if self .filters .curves == "non-zeros" and not sum (data ["values" ]):
471+ continue
472+ elif self .filters .curves == "total" and "indent" in curve :
473+ if curve ["indent" ] == 0 :
474+ datasets .append (data )
475+ elif self .filters .curves == "total" :
476+ if datasets :
477+ a = [
478+ data ["values" ][idx ] + datasets [0 ]["values" ][idx ] for idx in range (len (data ["values" ]))
479+ ]
480+ datasets [0 ]["values" ] = a
481+ else :
482+ datasets .append (data )
483+ datasets [0 ]["name" ] = _ ("Total" )
484+ else :
485+ datasets .append (data )
486+
487+ self .chart = {"data" : {"labels" : labels , "datasets" : datasets }, "type" : "line" }
464488
465489 if self .filters ["value_quantity" ] == "Value" :
466490 self .chart ["fieldtype" ] = "Currency"
You can’t perform that action at this time.
0 commit comments