{* Display monthly and yearly contributions using Google charts (Bar and Pie) *}
{if $hasContributions}
<div id="chartData">
-<table class="chart">
- <tr class="crm-contribution-form-block-open_flash_chart">
- <td>
+<table >
+ <tr class="crm-contribution-form-block-chart">
+ <td width="50%">
{if $hasByMonthChart}
{* display monthly chart *}
- <div id="open_flash_chart_by_month"></div>
+ <div id="chart_by_month"></div>
{else}
{ts}There were no contributions during the selected year.{/ts}
{/if}
</td>
- <td>
+ <td width="50%">
{* display yearly chart *}
- <div id="open_flash_chart_by_year"></div>
+ <div id="chart_by_year"></div>
</td>
</tr>
</table>
{literal}
<script type="text/javascript">
- var allData = {/literal}{$chartData}{literal};
-
CRM.$(function($) {
- $.each(allData, function(chartID, chartValues) {
- createChart(chartID, chartValues.divName, chartValues.size.xSize, chartValues.size.ySize, 'loadData');
- });
- });
+ var allData = {/literal}{$chartData}{literal};
- function loadData( chartID ) {
- return allData[chartID].object;
- }
+ $.each( allData, function( chartID, chartValues ) {
+ var divName = "chart_" + chartID;
+ createChart( chartID, divName, 300, 300, allData[chartID].object );
+ });
- function byMonthOnClick( barIndex ) {
- var url = allData.by_month.on_click_urls['url_' + barIndex];
- if ( url ) window.location.href = url;
- }
+ function byMonthOnClick( barIndex ) {
+ var url = allData.by_month.on_click_urls['url_' + barIndex];
+ if ( url ) window.location.href = url;
+ }
- function byYearOnClick( barIndex ) {
- var url = allData.by_year.on_click_urls['url_' + barIndex];
- if ( url ) window.location.href = url;
- }
+ function byYearOnClick( barIndex ) {
+ var url = allData.by_year.on_click_urls['url_' + barIndex];
+ if ( url ) window.location.href = url;
+ }
- </script>
+ });
+</script>
{/literal}
{/if}
}
// 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');