I discovered an array's mean, mode, median, and standard deviation. Now I'd like to plot them in a graph. I want to create an array line chart and highlight the mean, mode, median, and standard deviation. I tried something below, but only the x and y axes appeared, with no digits; I'm new to php. I need assistance converting my array to a line chart. Is there anyone who can assist me? Thank you very much.

My code is:

```<?php
echo "Welcome to my project".'<br>'.'<br>';
\$arr=array(1100,3150,4430,4430,5170,7450,7450,7450,8230);
for(\$i=0; \$i<=8; \$i++)
{
if (\$arr[\$i]<100) {
\$arr[\$i]=\$arr[\$i];
}
else
{
\$arr[\$i]=\$arr[\$i]/1000;
\$arr[\$i]=(string)\$arr[\$i];
}
}

function calculate(\$arr, \$output){

switch(\$output){
case 'mean':
\$count = count(\$arr)+1;
\$sum = array_sum(\$arr);
\$total = \$sum / \$count;
break;
case 'median':
rsort(\$arr);
\$middle = (count(\$arr) / 2)+1;
\$total = \$arr[\$middle-1];
break;
case 'mode':
\$v = array_count_values(\$arr);
arsort(\$v);
foreach(\$v as \$k => \$v){\$total = \$k; break;}

break;

}
return \$total;
}

function sd_square(\$x, \$total) { return pow(\$x - \$total,2); }
function sd(\$arr) {
return sqrt(array_sum(array_map("sd_square", \$arr, array_fill(0,count(\$arr), (array_sum(\$arr) / count(\$arr)) ) ) ) / (count(\$arr)-1) );
}

echo '  '.'<br>';
echo "Values: ";
echo json_encode(\$arr).'<br>';
echo 'Mean: '.calculate(\$arr, 'mean').'<br>';
echo 'Median: '.calculate(\$arr, 'median').'<br>';
echo 'Mode: '.calculate(\$arr, 'mode').'<br>';
echo "Standart Derivation: ".sd(\$arr);
?>

<!DOCTYPE HTML>
<html>
<script>

var chart = new CanvasJS.Chart("chartContainer", {
title: {
text: "Analysis"
},
axisY: {
title: "Variables"
},
data: [{
type: "line",
arr: <?php echo json_encode(\$arr, JSON_NUMERIC_CHECK); ?>
}]
});
chart.render();

}
</script>
<body>
<div id="chartContainer" style="height: 250px; width: 50%;"></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
</body>
</html> ```
Aug 16, 2022 in HTML 674 views

## How do I create an HTML button that acts like a link?

How can I make a button in ...READ MORE

## How can I set the default value for an HTML <select> element?

I believed that by setting the "value" ...READ MORE

+1 vote

## How can i create simple register form using html and css?

Html5 contains lots of elements using which ...READ MORE

## Inputting a default image in case the src attribute of an html <img> is not valid?

Is there any way to render a ...READ MORE

## Can i learn back-end web development without having any knowledge on front end web development?

Hi Unfortunately no, you have to know the ...READ MORE

## Anyone can help me out to understand the semantic of (document.getElementBYId("demo").innerHTML="Hello") ?

Hello guys, Can Someone helps me to find ...READ MORE

+1 vote