Revision d5145a56
Von Bernd Bleßmann vor mehr als 2 Jahren hinzugefügt
| js/kivi.CustomerVendorTurnover.js | ||
|---|---|---|
|
$('#turnovers').load(url);
|
||
|
};
|
||
|
|
||
|
ns.show_turnover_chart = function(period) {
|
||
|
ns.show_turnover_chart = function(period, year_for_month) {
|
||
|
const html = '<div class="chart-container" style="position: relative;">'
|
||
|
+ '<canvas id="chart"></canvas>'
|
||
|
+ '</div>';
|
||
| ... | ... | |
|
let mode = "month";
|
||
|
if (period === 'y') {
|
||
|
mode = "year";
|
||
|
year_for_month = undefined;
|
||
|
} else if (period === 'm') {
|
||
|
mode = "month";
|
||
|
}
|
||
| ... | ... | |
|
const data = { action: 'CustomerVendorTurnover/turnover.json',
|
||
|
id: $('#cv_id').val(),
|
||
|
db: $('#db').val(),
|
||
|
mode: mode
|
||
|
mode: mode,
|
||
|
year: year_for_month
|
||
|
};
|
||
|
$.getJSON('controller.pl', data, function( returned_data ) {
|
||
|
ns.draw_chart(returned_data);
|
||
| ... | ... | |
|
|
||
|
ns.chart = function(data) {
|
||
|
const ctx = 'chart';
|
||
|
const myChart = new Chart(ctx, {
|
||
|
const chart = new Chart(ctx, {
|
||
|
type: 'bar',
|
||
|
data: {
|
||
|
datasets: [{
|
||
| ... | ... | |
|
parsing: {
|
||
|
xAxisKey: 'date_part',
|
||
|
yAxisKey: 'netamount'
|
||
|
},
|
||
|
onClick: (e) => {
|
||
|
const canvasPosition = Chart.helpers.getRelativePosition(e, chart);
|
||
|
|
||
|
// Substitute the appropriate scale IDs
|
||
|
const dataX = chart.scales.x.getValueForPixel(canvasPosition.x);
|
||
|
const dataY = chart.scales.y.getValueForPixel(canvasPosition.y);
|
||
|
|
||
|
if ((data[dataX].date_part || "").match(/^\d{1,4}$/)) {
|
||
|
ns.show_turnover_chart('m', data[dataX].date_part);
|
||
|
} else {
|
||
|
ns.show_turnover_chart('y');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
Auch abrufbar als: Unified diff
Umsatzstatistik-Chart: per Klick auf Monate des entsprechenden Jahres