mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-04 22:38:49 +00:00
* Add bad .js code - Call function which has not been defined - Should throw JS lint error * update eslint - Move to newer version of eslint - Change default rules * Fixes for tables.js * Fixes for table_filters.js * Fixes for stock.js * Fix for sales_order.js and search.js * Fix return_order.js * Fixes for purchase_order.js * More updates - part.js - plugin.js - pricing.js * Updates - order.js * Even morerer updates - label.js - modals.js - model_renderers.js - news.js - notification.js * More, MORE! - build.js - company.js - charts.js - filters.js - forms.js - helpers.js * Final? - api.js - attachment.js - barcode.js - bom.js * Fix 'useless-escape' * Disable no-useless-escape rule
77 lines
1.4 KiB
JavaScript
77 lines
1.4 KiB
JavaScript
{% load i18n %}
|
|
{% load inventree_extras %}
|
|
|
|
/* globals
|
|
Chart,
|
|
*/
|
|
|
|
/* exported
|
|
loadBarChart,
|
|
loadDoughnutChart,
|
|
loadLineChart,
|
|
randomColor,
|
|
*/
|
|
|
|
|
|
/* Generate a random color */
|
|
function randomColor() {
|
|
return '#' + (Math.random().toString(16) + '0000000').slice(2, 8);
|
|
}
|
|
|
|
|
|
/*
|
|
* Load a simple bar chart
|
|
*/
|
|
function loadBarChart(context, data) {
|
|
return new Chart(context, {
|
|
type: 'bar',
|
|
data: data,
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
plugins: {
|
|
legend: {
|
|
position: 'bottom'
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
/*
|
|
* Load a simple doughnut chart
|
|
*/
|
|
function loadDoughnutChart(context, data) {
|
|
return new Chart(context, {
|
|
type: 'doughnut',
|
|
data: data,
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
plugins: {
|
|
legend: {
|
|
position: 'right',
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
/*
|
|
* Load a simple line chart
|
|
*/
|
|
function loadLineChart(context, data) {
|
|
return new Chart(context, {
|
|
type: 'line',
|
|
data: data,
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
plugins: {
|
|
legend: {position: 'bottom'},
|
|
}
|
|
}
|
|
});
|
|
}
|