0% found this document useful (0 votes)
48 views2 pages

Google Charts

The document contains code for creating a line chart using Google Charts. It loads the Corechart package, defines a data table with year, sales, and expenses data, sets the chart options, and draws the line chart to a DOM element with id "curve_chart". It also includes code to convert data from a .NET DataTable to the JSON format required by Google Charts.

Uploaded by

adrian_cft
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views2 pages

Google Charts

The document contains code for creating a line chart using Google Charts. It loads the Corechart package, defines a data table with year, sales, and expenses data, sets the chart options, and draws the line chart to a DOM element with id "curve_chart". It also includes code to convert data from a .NET DataTable to the JSON format required by Google Charts.

Uploaded by

adrian_cft
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<%--------------Google Charts-----------------%>

<script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"></script>
<%--<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {
var data = google.visualization.arrayToDataTable([ <%= JSONArray %> ]);

var options = {
title: 'Company Performance',
curveType: 'function',
legend: { position: 'bottom' }
};

var chart = new


google.visualization.LineChart(document.getElementById('curve_chart'));

chart.draw(data, options);
}
</script>--%>

'Grafico google
phEstadisticasGrid.Controls.Add(New LiteralControl("<div
id=""curve_chart"" style=""width: 900px; height: 500px""></div>"))
JSONArray = GetJson(dtDatos)

Public Function GetJson(ByVal dt As DataTable) As String


Dim serializer As New JavaScriptSerializer
Dim rows As New List(Of Dictionary(Of String, Object))()
Dim row As Dictionary(Of String, Object) = Nothing
For Each dr As DataRow In dt.Rows
row = New Dictionary(Of String, Object)()
For Each dc As DataColumn In dt.Columns
If dc.ColumnName.Trim() = "TAGNAME" Then
row.Add(dc.ColumnName.Trim(), dr(dc))
End If
Next
rows.Add(row)
Next
Return serializer.Serialize(rows)
End Function

------------------------------------oRiGiNaL-------------------------------------

<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1400, 0]
]);

var options = {
title: 'Company Performance',
curveType: 'function',
legend: { position: 'bottom' }
};

var chart = new


google.visualization.LineChart(document.getElementById('curve_chart'));

chart.draw(data, options);
}
</script

You might also like