我需要在JavaScript情况下使用PHP变量的帮助。
我想在莫里斯图表中使用PHP变量,例如,
var area = new Morris.Area({
element: 'revenue-chart',
resize: true,
data: [
{y: '6D', fab: 20004, qc: 0},
{y: '5D', fab: 2778, qc: 0},
{y: '4D', fab: 4912, qc: 0},
{y: '3D', fab: 3767, qc: 0},
{y: '2D', fab: 6810, qc: 0},
{y: '1D', fab: <?php echo $sumWeightYesterday; ?>, qc: 0},
{y: 'NOW', fab: 4820, qc: 0}
],
parseTime: false,
xkey: 'y',
ykeys: ['fab', 'qc'],
labels: ['FAB', 'QC'],
lineColors: ['#a0d0e0', '#3c8dbc'],
hideHover: 'auto'
});
我想使用
$sumWeightYesterday
,但它在数据上显示0
。请帮我,
谢谢
最佳答案
你可以尝试一下。
var sumWeightYesterday = <?php echo $sumWeightYesterday; ?>
var area = new Morris.Area({
element: 'revenue-chart',
resize: true,
data: [
{y: '6D', fab: 20004, qc: 0},
{y: '5D', fab: 2778, qc: 0},
{y: '4D', fab: 4912, qc: 0},
{y: '3D', fab: 3767, qc: 0},
{y: '2D', fab: 6810, qc: 0},
{y: '1D', fab: sumWeightYesterday, qc: 0},
{y: 'NOW', fab: 4820, qc: 0}
],
parseTime: false,
xkey: 'y',
ykeys: ['fab', 'qc'],
labels: ['FAB', 'QC'],
lineColors: ['#a0d0e0', '#3c8dbc'],
hideHover: 'auto'
});