From f648602ad5ab86223a3276fe6a2f8f4f4011f09e Mon Sep 17 00:00:00 2001 From: Rich Lott / Artful Robot Date: Thu, 10 Oct 2019 09:39:29 +0200 Subject: [PATCH] Fix missing/broken contribution charts --- CRM/Contribute/Form/ContributionCharts.php | 2 +- .../Contribute/Form/ContributionCharts.tpl | 45 +++++++++---------- templates/CRM/common/chart.tpl | 3 +- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/CRM/Contribute/Form/ContributionCharts.php b/CRM/Contribute/Form/ContributionCharts.php index 70c58ce2cb..158db37c79 100644 --- a/CRM/Contribute/Form/ContributionCharts.php +++ b/CRM/Contribute/Form/ContributionCharts.php @@ -173,7 +173,7 @@ class CRM_Contribute_Form_ContributionCharts extends CRM_Core_Form { $monthlyChart = TRUE; } - $values['divName'] = "open_flash_chart_{$chartKey}"; + $values['divName'] = "chart_{$chartKey}"; $funName = ($chartType == 'bvg') ? 'barChart' : 'pieChart'; // build the chart objects. diff --git a/templates/CRM/Contribute/Form/ContributionCharts.tpl b/templates/CRM/Contribute/Form/ContributionCharts.tpl index 3e6c01a0f9..0faf575cd3 100644 --- a/templates/CRM/Contribute/Form/ContributionCharts.tpl +++ b/templates/CRM/Contribute/Form/ContributionCharts.tpl @@ -26,19 +26,19 @@ {* Display monthly and yearly contributions using Google charts (Bar and Pie) *} {if $hasContributions}
- - -
+ + + -
{if $hasByMonthChart} {* display monthly chart *} -
+
{else} {ts}There were no contributions during the selected year.{/ts} {/if}
+ {* display yearly chart *} -
+
@@ -60,28 +60,25 @@ {literal} + }); + {/literal} {/if} diff --git a/templates/CRM/common/chart.tpl b/templates/CRM/common/chart.tpl index 5425871f12..1400408f4a 100644 --- a/templates/CRM/common/chart.tpl +++ b/templates/CRM/common/chart.tpl @@ -44,7 +44,8 @@ function createChart( chartID, divName, xSize, ySize, data ) { } // Figure out suitable size based on container size. - var w = Math.min(div.clientWidth - 32, 800); + // In some cases the containing element has no size. We should insist on a minimum size. + var w = Math.max(Math.min(div.clientWidth - 32, 800), 316); var h = Math.min(400, parseInt(w / 2)); var chartNode = document.createElement('div'); -- 2.25.1