Sfoglia il codice sorgente

fix: let charts handle aggregation (#18293) (#18295)

Currently we are doing aggregation of remaining slices manually BUT this
breaks basic principle of DRY:

- dashboard chart decides how many groups to consider
- frappe charts has different maxSlices config

This results in mess like frappe computing "Other" and Frappe charts
computing "rest" separately.

Fix: Just pass all data to charts and let it figure out the "Rest".
(cherry picked from commit d597acb5e2)

Co-authored-by: Ankush Menat <ankush@frappe.io>
version-14
mergify[bot] 2 anni fa
committed by GitHub
parent
commit
e0974c53ab
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: 4AEE18F83AFDEB23
2 ha cambiato i file con 2 aggiunte e 8 eliminazioni
  1. +0
    -7
      frappe/desk/doctype/dashboard_chart/dashboard_chart.py
  2. +2
    -1
      frappe/public/js/frappe/widgets/chart_widget.js

+ 0
- 7
frappe/desk/doctype/dashboard_chart/dashboard_chart.py Vedi File

@@ -293,13 +293,6 @@ def get_group_by_chart_config(chart, filters):
)

if data:
if chart.number_of_groups and chart.number_of_groups < len(data):
other_count = 0
for i in range(chart.number_of_groups - 1, len(data)):
other_count += data[i]["count"]
data = data[0 : chart.number_of_groups - 1]
data.append({"name": "Other", "count": other_count})

chart_config = {
"labels": [item["name"] if item["name"] else "Not Specified" for item in data],
"datasets": [{"name": chart.name, "values": [item["count"] for item in data]}],


+ 2
- 1
frappe/public/js/frappe/widgets/chart_widget.js Vedi File

@@ -571,12 +571,13 @@ export default class ChartWidget extends Widget {
Heatmap: "heatmap",
};

let max_slices = ["Pie", "Donut"].includes(this.chart_doc.type) ? 6 : 9;
let chart_args = {
data: this.data,
type: chart_type_map[this.chart_doc.type],
colors: colors,
height: this.height,
maxSlices: ["Pie", "Donut"].includes(this.chart_doc.type) ? 6 : 9,
maxSlices: this.chart_doc.number_of_groups || max_slices,
axisOptions: {
xIsSeries: this.chart_doc.timeseries,
shortenYAxisNumbers: 1,


Caricamento…
Annulla
Salva