如何解决在ChartJS函数中使用php变量时,表达式预期错误
我试图在ChartJS Javascript文件中输入我的Controller变量,以便在ChartJS中动态创建图表
预期表达为“
Controller.php
// Pie Chart Example
var ctx = document.getElementById("myPieChart");
var myPieChart = new Chart(ctx,{
type: 'doughnut',data: {
labels: <?php echo json_encode($labels); ?>,// Error Line
datasets: [{
data: <?php echo json_encode($data); ?>,// Error Line
backgroundColor: ['#4e73df','#1cc88a','#36b9cc'],hoverBackgroundColor: ['#2e59d9','#17a673','#2c9faf'],hoverBorderColor: "rgba(234,236,244,1)",}],},
chart-pie-demo.js:
str_1 = "Hello World"
def insert_str(org_str,insert_str,pos):
str_2 = list(org_str)
str_2.insert(pos,insert_str)
new_string = "".join(str_2)
return new_string
a = '@'
position = 3
new_string = insert_str(org_str=str_1,insert_str=a,pos=position)
print(new_string)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。