所以我试图在我的asp.net网站上使用这个javascript https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart
我在代码隐藏中有一个数组,其中包含我的数据,我将其转换为这样的多维数据表。
<in codebehind vb>
Public Property datat As DataTable
For outerIndex As Integer = 0 To 2
Dim newRow As DataRow = table.NewRow()
For innerIndex As Integer = 0 To 2
newRow(innerIndex) = Array(outerIndex, innerIndex)
Next
table.Rows.Add(newRow)
Next
datat = table
<in asp>
function drawChart() {
var data = <%=datat%>
我总是得到一个未定义的错误数据表。
我的新作品
<in asp>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawcharts);
function drawcharts() {
var data = google.visualization.arrayToDataTable([
['X', 'MW'],
[<%=mwtimepublic%>, <%=mwarraypublic%>]
]);
var options = {
title: 'MW Trend'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
});
</script>
公共函数 Dtable() As DataTable 将 startdate 作为 String 将 enddate 作为 String
If FirstRun = False Then
datat.Clear()
End If
If FirstRun = True Then
FirstRun = False
enddate = Date.Today
startdate = DateAdd(DateInterval.Day, -20, Date.Today)
Else
enddate = TextBox2.Text
startdate = TextBox1.Text
End If
'<confidential code></confidentialcode>
Dim mwaray(pdata.Count)
Dim mwtime(pdata.Count)
Dim table As New DataTable
table.Columns.Add("X")
table.Columns.Add("MW")
Dim i As Integer
Dim x As Integer
For i = 1 To pdata.Count
mwaray(i) = pdata(i).Value
If mwaray(i) > upperlimit Then
upperlimit = mwaray(i) + 50
End If
Next
For i = 1 To pdata.Count
mwtime(i) = "'" & pdata(i).TimeStamp.LocalDate.Month.ToString() & "/" & pdata(i).TimeStamp.LocalDate.Day.ToString() & "/" & pdata(i).TimeStamp.LocalDate.Year.ToString() & " " & pdata(i).TimeStamp.LocalDate.TimeOfDay.Hours.ToString() & ":" & pdata(i).TimeStamp.LocalDate.TimeOfDay.Minutes.ToString() & ":" & pdata(i).TimeStamp.LocalDate.TimeOfDay.Seconds.ToString() & "'"
Next
For i = 1 To pdata.Count
mwarraypublic.Add(mwaray(i))
Next
For i = 1 To pdata.Count
mwtimepublic.Add(mwtime(i))
Next
End Function
我仍然没有绘制图表