public function buildQuickForm() {
//p3 = Three dimensional pie chart.
//bvg = Vertical bar chart
- $this->addElement('select', 'chart_type', ts('Chart Style'), array('bvg' => ts('Bar'),
+ $this->addElement('select', 'chart_type', ts('Chart Style'), array(
+ 'bvg' => ts('Bar'),
'p3' => ts('Pie'),
- ),
- array('onchange' => "getChart();")
+ )
);
$defaultValues['chart_type'] = $this->_chartType;
$this->setDefaults($defaultValues);
}
}
- $this->addElement('select', 'select_year', ts('Select Year (for monthly breakdown)'),
- $years, array('onchange' => "getChart();")
- );
+ $this->addElement('select', 'select_year', ts('Select Year (for monthly breakdown)'), $years);
$this->setDefaults(array(
'select_year' => ($this->_year) ? $this->_year : $currentYear,
));
year = currentYear;
}
chartUrl = CRM.url("civicrm/ajax/chart", {
- 'snippet' : 4,
- 'year' : year,
- 'type' : charttype
+ 'snippet': 4,
+ 'year': year,
+ 'type': charttype
+ });
+ $("#chartData").load(chartUrl, function() {
+ $("select", "#chartData").change(getChart);
});
- $(chartData).load(chartUrl);
}
function buildTabularView() {
var tableUrl = CRM.url("civicrm/contribute/ajax/tableview", {showtable: 1, snippet: 4});
- $(tableData).load(tableUrl);
+ $("#tableData").load(tableUrl);
}
- getChart();
$('#chart_view').click(function() {
if ($('#chart_view').hasClass('ui-state-default')) {
$('#chart_view').removeClass('ui-state-default').addClass('ui-state-active ui-tabs-selected');
$('#chartData').children().html('');
}
});
+
+ // Initialize chart or table based on url hash
+ if (window.location.hash === '#table_layout') {
+ $('#table_view').click();
+ }
+ else {
+ getChart();
+ }
});