Use the sample Code for displaying the line chart:
HTML Code:
<asp:label id="Label8" runat="server" text="Line Chart" xmlns:asp="#unknown"></asp:label>
<br />
<div id="chart_div8">
<asp:literal id="lt8" runat="server" xmlns:asp="#unknown"></asp:literal>
</div>
C# Code:
public void Line_Chart1()
{
StringBuilder str4 = new StringBuilder();
string sql = "select itemid,round(avg(rating)) as rating from tmp_feedback group by itemid";
DataSet ds = new DataSet();
OracleDataAdapter adp = new OracleDataAdapter(sql, conn);
adp.Fill(ds, "tmp_feedback");
DataTable dt = new DataTable();
dt = ds.Tables[0];
try
{
adp.Fill(dt);
str4.Append(@"<script type=text/javascript> google.load( *visualization*, *1*, {packages:[*corechart*]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'ITEMID');
data.addColumn('number', 'RATING');
data.addRows(" + dt.Rows.Count + ");");
Int32 i;
for (i = 0; i <= dt.Rows.Count - 1; i++)
{
str4.Append("data.setValue( " + i + "," + 0 + "," + "'" + dt.Rows[i]["ITEMID"].ToString() + "');");
str4.Append("data.setValue(" + i + "," + 1 + "," + dt.Rows[i]["RATING"].ToString() + ") ;");
}
str4.Append(" var chart = new google.visualization.LineChart(document.getElementById('chart_div8'));");
str4.Append(" chart.draw(data, {width: 300, height: 300, title: 'Performance Rating',");
str4.Append("vAxis: {title: 'Rating', titleTextStyle: {color: 'green'}}");
str4.Append("}); }");
str4.Append("</script>");
lt8.Text = str4.ToString().TrimEnd(',').Replace('*', '"');
conn.Close();
}
catch
{
}
finally
{
conn.Close();
}
}