谷歌饼图在yii中不起作用
在我的Yii网络应用程序中,谷歌图表不起作用。我通过renderpartial方法获取所有值。但是,不显示饼图 我的密码是谷歌饼图在yii中不起作用,yii,charts,Yii,Charts,在我的Yii网络应用程序中,谷歌图表不起作用。我通过renderpartial方法获取所有值。但是,不显示饼图 我的密码是 <div class="content"> <div id="graph" style="width:300px;height:300px "> </div> </div> <script type="text/javascript" src="https://www.google.com/jsapi">
<div class="content">
<div id="graph" style="width:300px;height:300px ">
</div>
</div>
<script type="text/javascript" src="https://www.google.com/jsapi">
// Load the Visualization API and the piechart package.
google.load("visualization", "1", { packages: ["corechart"] });
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(createPIE);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function createPIE() {
var options = {
title: 'Fees Allocation',
colors: ['#888', 'orange','red'],
is3D: true
};
// Create our data table.
var data = google.visualization.arrayToDataTable([
['Total Amount', <?php echo $amount;?>],
['Collected', <?php echo $collected;?>],
['Due', <?php echo $due;?>]]);
var chart = new google.visualization.PieChart(document.getElementById('graph'));
chart.draw(data, options);
}
</script>
//加载可视化API和piechart包。
load(“可视化”、“1”、{packages:[“corechart”]});
//将回调设置为在加载Google Visualization API时运行。
setOnLoadCallback(createPIE);
//创建并填充数据表的回调,
//实例化饼图,传入数据并
//画它。
函数createPIE(){
变量选项={
标题:“费用分配”,
颜色:['#888'、'橙色'、'红色'],
is3D:对
};
//创建我们的数据表。
var data=google.visualization.arrayToDataTable([
[‘总额’,],
[‘收集’,],
[‘到期’,]);
var chart=newgoogle.visualization.PieChart(document.getElementById('graph');
图表绘制(数据、选项);
}
请帮助我。您的代码中几乎没有错误,请尝试下面的代码
<?php
$amount = 20;
$collected = 50;
$due = 30;
?>
<div class="content">
<div id="graph" style="width:300px;height:300px">
</div>
</div>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.charts.load("current", { packages: ["corechart"] });
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(createPIE);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function createPIE() {
var options = {
title: 'Fees Allocation',
colors: ['#888', 'orange','red'],
is3D: true
};
// Create our data table.
var data = google.visualization.arrayToDataTable([
['status', 'Amount'],
['Total Amount', <?php echo $amount;?>],
['Collected', <?php echo $collected;?>],
['Due', <?php echo $due;?>]]);
var chart = new google.visualization.PieChart(document.getElementById('graph'));
chart.draw(data, options);
}
</script>
//加载可视化API和piechart包。
load(“当前”{packages:[“corechart”]});
//将回调设置为在加载Google Visualization API时运行。
google.charts.setOnLoadCallback(createPIE);
//创建并填充数据表的回调,
//实例化饼图,传入数据并
//画它。
函数createPIE(){
变量选项={
标题:“费用分配”,
颜色:['#888'、'橙色'、'红色'],
is3D:对
};
//创建我们的数据表。
var data=google.visualization.arrayToDataTable([
[‘状态’、‘金额’],
[‘总额’,],
[‘收集’,],
[‘到期’,]);
var chart=newgoogle.visualization.PieChart(document.getElementById('graph');
图表绘制(数据、选项);
}
签出此小提琴:您的代码中几乎没有错误,请尝试下面的代码
<?php
$amount = 20;
$collected = 50;
$due = 30;
?>
<div class="content">
<div id="graph" style="width:300px;height:300px">
</div>
</div>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.charts.load("current", { packages: ["corechart"] });
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(createPIE);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function createPIE() {
var options = {
title: 'Fees Allocation',
colors: ['#888', 'orange','red'],
is3D: true
};
// Create our data table.
var data = google.visualization.arrayToDataTable([
['status', 'Amount'],
['Total Amount', <?php echo $amount;?>],
['Collected', <?php echo $collected;?>],
['Due', <?php echo $due;?>]]);
var chart = new google.visualization.PieChart(document.getElementById('graph'));
chart.draw(data, options);
}
</script>
//加载可视化API和piechart包。
load(“当前”{packages:[“corechart”]});
//将回调设置为在加载Google Visualization API时运行。
google.charts.setOnLoadCallback(createPIE);
//创建并填充数据表的回调,
//实例化饼图,传入数据并
//画它。
函数createPIE(){
变量选项={
标题:“费用分配”,
颜色:['#888'、'橙色'、'红色'],
is3D:对
};
//创建我们的数据表。
var data=google.visualization.arrayToDataTable([
[‘状态’、‘金额’],
[‘总额’,],
[‘收集’,],
[‘到期’,]);
var chart=newgoogle.visualization.PieChart(document.getElementById('graph');
图表绘制(数据、选项);
}
签出此小提琴: