Merge pull request #38218 from gajjug004/fix/report-view-chart-crash-on-group-by-removal

fix: report view crash when removing group by after toggling chart
This commit is contained in:
Ejaaz Khan 2026-03-25 01:52:00 +05:30 committed by GitHub
commit a8c429ecbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -502,6 +502,11 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
// show chart if saved via report or user settings
if (!this.chart) {
if (this.chart_args) {
if (!this.chart_axes_valid(this.chart_args)) {
this.reset_chart_state();
return;
}
this.build_chart_args(
this.chart_args.x_axis,
this.chart_args.y_axes,
@ -643,12 +648,30 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
refresh_charts() {
if (!this.chart || !this.chart_args) return;
if (!this.chart_axes_valid(this.chart_args)) {
this.reset_chart_state();
return;
}
this.$charts_wrapper.removeClass("hidden");
const { x_axis, y_axes, chart_type } = this.chart_args;
this.build_chart_args(x_axis, y_axes, chart_type);
this.chart.update(this.chart_args);
}
chart_axes_valid(chart_args) {
const { x_axis, y_axes } = chart_args;
return this.columns_map[x_axis] && y_axes.every((y_axis) => this.columns_map[y_axis]);
}
reset_chart_state() {
this.chart = null;
this.chart_args = null;
this.$charts_wrapper.addClass("hidden");
this.save_view_user_settings({ chart_args: null });
}
get_editing_object(colIndex, rowIndex, value, parent) {
const control = this.render_editing_input(colIndex, value, parent);
if (!control) return false;