Document 3
Document 3
<script>
var xArray = <?php echo json_encode($inventory);?>;
var yArray = <?php echo json_encode($request); ?>;
var data = [
{x:xArray, y:yArray, mode:"markers"},
{x:[1, <?php $inventory2=mysqli_query($link, "select sum(quantity) as quantity
from sup_req WHERE status=5");
$inv2=mysqli_fetch_assoc($inventory2);
echo $inv2["quantity"]; ?>], y:[1, <?php
$request2=mysqli_query($link, "select * from sup_req WHERE status=2");
$req1=mysqli_num_rows($request2);
echo $req1;
?>], mode:"line"},
];
var layout = {
xaxis: {range: [-1, <?php $inventory2=mysqli_query($link, "select sum(quantity)
as quantity from sup_req WHERE status=5");
$inv2=mysqli_fetch_assoc($inventory2);
echo $inv2["quantity"]; ?>], title: "Inventory"},
yaxis: {range: [-1, <?php
$request2=mysqli_query($link, "select * from sup_req WHERE status=2");
$req1=mysqli_num_rows($request2);
echo $req1;
?>], title: "Supplies Request"},
title: "Supplies Request Vs. Inventory"
};
</style>
</div>
<script>var resultLineChart = {
"series": ["Supply Request", "Number of inventory", "Trend curve of the average
number of request", "Trendline of the number of inventory"],
"labels":
<?php echo json_encode($data); ?>
,
"data": [
<?php echo json_encode($request); ?>,
<?php echo json_encode($inventory); ?>,
]
};
const getRegression = (data, degre) => {
degre = degre || 2;
let dataRegression = [];
data.forEach((element, index) => dataRegression.push([index + 1, element]));
var lineChartData = {
labels: resultLineChart.labels,
datasets: [{
// Nombre moyen de reports par correction
label: resultLineChart.series[0],
backgroundColor: "rgba(255, 108, 110, 0.1)",
borderColor: "rgba(255, 108, 110, 1)",
pointBackgroundColor: "rgba(255, 108, 110, 0.5)",
pointBorderColor: "#fff",
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: "rgba(255, 108, 110, 0.5)",
pointBorderWidth: 1,
yAxisID: 'y-axis-1',
data: resultLineChart.data[0]
}, {
label: resultLineChart.series[1],
backgroundColor: "rgba(50, 155, 255, 0.2)",
borderColor: "rgba(50, 155, 255, 1)",
pointBackgroundColor: "rgba(50, 155, 255, 0.5)",
pointBorderColor: "#fff",
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: "rgba(50, 155, 255, 0.5)",
pointBorderWidth: 1,
yAxisID: 'y-axis-2',
data: resultLineChart.data[1]
}, {
// Régression linéaire nb moyen de reports
label: resultLineChart.series[2],
fill: false,