如何在构建柱形图、折线图和饼图时引入 php 变量?
<?php $numero = 9; ?>
<script type="text/javascript">
var mes_I = "<?p h p echo $numero; ?>";
var chart;
$(function container_V () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container_V'
},
title: {
text: 'Média de Utilização de Animais'
},
xAxis: {
categories: ["mes_III", "mes_II", "mes_I"]
},
tooltip: {
formatter: function() {
var s;
if (this.point.name) { // the pie chart
s = ''+
this.point.name +': '+ this.y +'%';
} else {
s = ''+
this.x +': '+ this.y;
}
return s;
}
},
labels: {
items: [{
html: 'Utilização',
style: {
left: '40px',
top: '8px',
color: 'black'
}
}]
},
series: [{
type: 'column',
name: 'Mouse',
color: 'white',
data: [mes_I]
}, {
type: 'spline',
name: 'Average',
data: [3, 2.67, 3],
marker: {
lineWidth: 3,
lineColor: Highcharts.getOptions().colors[3],
fillColor: 'black'
}
}, {
type: 'pie',
name: 'Total consumption',
data: [{
name: 'LABCET',
y: 10,
color: '#006400'
}, {
name: 'LPEP',
y: 19,
color: '#00BFFF'
}],
center: [70, 75],
size: 100,
showInLegend: false,
dataLabels: {
enabled: false
}
}]
});
});
});
</script>
变量 mes_I ok,包含值 '9'。但是,当我输入给定的系列时,它不会出现。