+ chartJS: add function to filter a chart.
This commit is contained in:
@@ -23,3 +23,50 @@ function previewCharts()
|
||||
postAndLoadPage(previewUrl, form, '#chartPanel');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选一个图表。
|
||||
* Filter a chart.
|
||||
*
|
||||
* @param string chartID
|
||||
* @access public
|
||||
* @return bool|void
|
||||
*/
|
||||
loadChart = function(chartID)
|
||||
{
|
||||
if(!chartID.includes('_')) return false;
|
||||
|
||||
const keys = chartID.split('_');
|
||||
const form = new FormData();
|
||||
form.append('groupID', keys[0]);
|
||||
form.append('chartID', keys[1]);
|
||||
|
||||
$('#filter_' + chartID + ' .filter').each(function(index)
|
||||
{
|
||||
const $filter = $(this);
|
||||
if ($filter.hasClass('filter-input'))
|
||||
{
|
||||
form.append('filterValues[' + index + ']', $filter.find('input').val());
|
||||
}
|
||||
else if($filter.hasClass('filter-select'))
|
||||
{
|
||||
const value = $filter.find('.pick-value').val();
|
||||
form.append('filterValues[' + index + ']', typeof value == 'array' ? value.filter(Boolean) : value);
|
||||
}
|
||||
else if($filter.hasClass('filter-date') || $filter.hasClass('filter-datetime'))
|
||||
{
|
||||
const $pickValue = $filter.find('.pick-value');
|
||||
if($pickValue.length == 1)
|
||||
{
|
||||
form.append('filterValues[' + index + ']', $pickValue.val());
|
||||
}
|
||||
else if($pickValue.length == 2)
|
||||
{
|
||||
form.append('filterValues[' + index + '][begin]', $pickValue.eq(0).val());
|
||||
form.append('filterValues[' + index + '][end]', $pickValue.eq(1).val());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
postAndLoadPage(previewUrl, form, '#chart_' + chartID);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user