如何在循环中创建谷歌图表
how to create google charts in a loop
嗨,我在谷歌图表工作,一切都很好。图表加载完美,但现在我在一个情况下,我需要在一个循环加载图表,我无法延迟绑定图表。这里是c# mvc代码
<table>
<tr>
<td>
<% Html.RenderPartial("ChartsDetailPDF", ViewData); %> //this chart code is working fine
</td>
</tr>
<% var allChildCategories = ViewData["allChildCategories"] as List<Category>;
if (allChildCategories != null)
{
foreach (var item in allChildCategories)
{
var categoryId = item.Id;
// from here i need categoryId and from this id i can get jsondata from server calling ajax function
%>
<tr>
<td>
<script>
$(document).ready(function () {
google.load('visualization', '1.1', { 'packages': ['corechart'], 'callback': drawChartLateBinding("<%=categoryId %>", "<%=userId %>", "<% =startDate %>", "<% =endDate %>") });
});
function drawChartLateBinding(categoryId ,userId,startDate,endDate) {
$('#chartControlRepeater' + categoryId).load( function () {
drawBarChartAjaxfunction(categoryId, userId, startDate, endDate);
});
</script>
<div id="chartDiv_<%=categoryId %>" data-categoryId="<%=categoryId%>" data-userId="<%=userId %>" data-startdate="<% =startDate %>" data-enddate="<% =endDate %>" style="width: 100%; height: 450px;">
</div>
</td>
</tr>
<%}
} %>
</table>
问题不清楚(或者我没有理解),但这是图表初始化和绘制的基本步骤:
var chart_data_categoryId = new google.visualization.DataTable(data);
var chart_categoryId = new google.visualization.ColumnChart(document.getElementById(chart_div_categoryId));
chart_categoryId.draw(chart_data_categoryId, options);
相关文章:
- 使用外部数据创建仪表板(谷歌电子表格)-JavaScript
- 谷歌地图动态创建的标记点击事件使用相同的标记
- 创建带有侧边栏的谷歌地图
- 谷歌标记集群未创建
- 如何创建一个谷歌地图地理坐标数组
- 如何在谷歌开发者控制台上为firefox扩展创建oAuth项目
- 创建一个不断变化的谷歌涂鸦风格的标题
- 谷歌索引iframe动态创建了什么
- 如何创建谷歌地图下拉列表
- 谷歌浏览器模式正则表达式在使用setCustomValidity动态创建表单时不起作用
- 如何为动态网页创建谷歌放大器
- 从数据库中的城市创建谷歌地图标记
- 谷歌地图API多段线创建失败;未捕获类型错误:数字不是函数;
- 如何创建谷歌图像引擎效果
- 自定义创建的谷歌地图嵌入
- 创建谷歌图表;转换为图像服务器端
- 谷歌工作表中用于获取条目和创建日历事件的脚本示例
- 谷歌可视化树图-如何创建自定义文本
- 谷歌地图,使用place_id创建地图
- 谷歌脚本创建了两个电子表格,而不是一个