'How can you create review apps in Azure Devops
Im very new to review apps but have been asked to create review apps in Azure devops? Any guides to how to do this ? The source code is in Github and they were using Herouku previously but now want to use Azure
Solution 1:[1]
You didn't pass the data in the Chart Object correctly. You can transform the object in php or js.
Example in js below.
const ctx = document.getElementById("myChart").getContext("2d");
const xValues = [
{ date: "2021-12-10" },
{ date: "2021-12-11" },
{ date: "2021-12-12" },
{ date: "2021-12-13" },
{ date: "2021-12-14" },
{ date: "2021-12-15" },
{ date: "2021-12-16" },
{ date: "2021-12-17" },
{ date: "2021-12-18" },
{ date: "2021-12-19" },
{ date: "2021-12-20" },
];
const yValues = [
{ attendance: "65" },
{ attendance: "58" },
{ attendance: "56" },
{ attendance: "78" },
{ attendance: "51" },
{ attendance: "54" },
{ attendance: "69" },
{ attendance: "35" },
{ attendance: "68" },
{ attendance: "43" },
{ attendance: "52" },
];
const x = xValues.map(item => item.date);
const y = yValues.map(item => item.attendance);
new Chart(ctx, {
type: "line",
data: {
labels: x,
datasets: [
{
label: "Dataset 1",
backgroundColor: "rgba(0,0,255,1.0)",
borderColor: "rgba(0,0,255,0.1)",
data: y,
},
],
},
options: {
responsive: true,
plugins: {
legend: {
position: "top",
},
title: {
display: true,
text: "Chart.js Line Chart",
},
},
},
});
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<canvas id="myChart" width="400" height="400"></canvas>
EDIT Full php example
<?php
$con = new mysqli($servername, $username, $password, $db);
$myquery1 = "select date from Table_attendance";
$result1 = mysqli_query($con, $myquery1);
$rowsDate = mysqli_fetch_all($result1, MYSQLI_ASSOC);
$xValues = array_map(function ($item) {
return $item['date'];
}, $rowsDate);
$myquery2 = "select attendance from Table_attendance";
$result2 = mysqli_query($con, $myquery2);
$rowsAtd = mysqli_fetch_all($result2, MYSQLI_ASSOC);
$yValues = array_map(function ($item) {
return $item['attendance'];
}, $rowsAtd);
?>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<canvas id="myChart" width="400" height="400"></canvas>
<script>
const x = <?php echo json_encode($xValues) ?>;
const y = <?php echo json_encode($yValues) ?>;
new Chart(ctx, {
type: "line",
data: {
labels: x,
datasets: [{
label: "Dataset 1",
backgroundColor: "rgba(0,0,255,1.0)",
borderColor: "rgba(0,0,255,0.1)",
data: y,
}, ],
},
options: {
responsive: true,
plugins: {
legend: {
position: "top",
},
title: {
display: true,
text: "Chart.js Line Chart",
},
},
},
});
</script>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
