我有一个网站模板,它使用外部 JAVSCRIPT 文件将数据绘制到图表上。我想要做的是将演示内容交换为 php 变量。
原始图形数据
var data = [{
label: "Facebook",
data: [[1, 2], [2, 37], [3, 12], [4, 72], [5, 24], [6, 113], [7, 27]]
},
{
label: "Google+",
data: [[1, 3], [2, 45], [3, 16], [4, 48], [5, 12], [6, 125], [7, 26]]
}];
我的尝试
var data = [{
label: "Facebook",
data: [[<?php echo '$daysago7'; ?>, 2], [<?php echo '$daysago6'; ?>, 37], [<?php echo '$daysago5'; ?>, 12], [<?php echo '$daysago4'; ?>, 72], [<?php echo '$daysago3'; ?>, 24], [<?php echo '$daysago2'; ?>, 113], [<?php echo '$daysago1'; ?>, 27]]
},
{
label: "Google+",
data: [[<?php echo '$daysago7'; ?>, 3], [<?php echo '$daysago6'; ?>, 45], [<?php echo '$daysago5'; ?>, 16], [<?php echo '$daysago4'; ?>, 48], [<?php echo '$daysago3'; ?>, 12], [<?php echo '$daysago2'; ?>, 125], [<?php echo '$daysago1'; ?>, 26]]
}]
当我包含我的版本时,我根本没有得到任何图表。