Skip to content

Instantly share code, notes, and snippets.

@nainav
Created July 26, 2017 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nainav/60c608f8f7c02fac629a5b4336e0e4e5 to your computer and use it in GitHub Desktop.
Save nainav/60c608f8f7c02fac629a5b4336e0e4e5 to your computer and use it in GitHub Desktop.
<?php
echo '
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
';
$file="https://gist.githubusercontent.com/nainav/40d12828d30ea323f07994730c304d87/raw/f103603366cf4dfbe02e639fed15ba15b43b48c1/ravi.csv";
$csv= file_get_contents($file);
$array = array_map("str_getcsv", explode("\n", $csv));
$json = json_encode($array);
print($json);
$cont = json_decode($json, true);
print $cont[0][0];
$cont = array_slice($cont,0,1);
foreach($cont as $arr){
$basic = $basic . '['.$arr[0].','.$arr[1].']';
}
print $basic;
echo "
<script>
Highcharts.chart('container', {
chart: {
type: 'spline',
inverted: true
},
title: {
text: 'Atmosphere Temperature by Altitude'
},
subtitle: {
text: 'According to the Standard Atmosphere Model'
},
xAxis: {
reversed: false,
title: {
enabled: true,
text: 'Altitude'
},
labels: {
formatter: function () {
return this.value + 'km';
}
},
maxPadding: 0.05,
showLastLabel: true
},
yAxis: {
title: {
text: 'Temperature'
},
labels: {
formatter: function () {
return this.value + '°';
}
},
lineWidth: 2
},
legend: {
enabled: false
},
tooltip: {
headerFormat: '<b>{series.name}</b><br/>',
pointFormat: '{point.x} km: {point.y}°C'
},
plotOptions: {
spline: {
marker: {
enable: false
}
}
},
series: [{
name: 'Temperature',
data: [[0, 15], [10, -50], [20, -56.5], [30, -46.5], [40, -22.1],
"?>
<?php echo $basic ;
echo " ] }]
});
</script>"
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment