TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sumeet Bagade
NA
18
5.5k
Google combo chart percentage line error shows down
Oct 6 2014 2:12 AM
public partial class student_master : System.Web.UI.Page
{
mydb db = new mydb();
string st = "";
//SqlCommand cm;
SqlDataReader dr;
double x = 0;
double fmax_marks, smax_marks;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGvdata();
BindChart();
}
}
private void BindGvdata()
{
gvdata.DataSource = GetChartData();
gvdata.DataBind();
}
private void BindChart()
{
DataTable dschartdata = new DataTable();
StringBuilder strScript = new StringBuilder();
try
{
dschartdata = GetChartData();
strScript.Append(@"<script type='text/javascript'>
google.load('visualization', '1', {packages: ['corechart']});</script>
<script type='text/javascript'>
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['sub_name', 'FA1', 'FA2', 'SA1', 'FA3','FA4','SA2','%'],");
foreach (DataRow row in dschartdata.Rows)
{
strScript.Append("['" + row["sub_name"] + "'," + row["FA1"] + "," +
row["FA2"] + "," + row["SA1"] + "," + row["FA3"] + "," + row["FA4"] + "," + row["SA2"] + "," + row["%"] + ",],");
}
strScript.Remove(strScript.Length - 1, 1);
strScript.Append("]);");
strScript.Append("var options = { title : '', vAxis: {title: 'MARKS',}, hAxis: {title: 'SUBJECTS'}, seriesType: 'bars', series: {6: {type: 'area'}} };");
strScript.Append(" var chart = new google.visualization.ComboChart(document.getElementById('char_div')); chart.draw(data, options); } google.setOnLoadCallback(drawVisualization);");
strScript.Append(" </script>");
ltScripts.Text = strScript.ToString();
}
catch
{ }
finally
{
dschartdata.Dispose();
strScript.Clear();
}
}
private DataTable GetChartData()
{
DataSet dsData = new DataSet();
try
{
SqlConnection dd = new SqlConnection(WebConfigurationManager.AppSettings["con"]);
st = @"SELECT MAX(exam_details.max_marks) AS max_marks
FROM exam_master INNER JOIN exam_details ON exam_master.e_id = exam_details.e_id
WHERE (exam_master.c_id = 1) AND (exam_master.e_name LIKE 'FA%')";
dr = db.readall(st);
if (dr.Read() == true)
{
fmax_marks = Convert.ToDouble(dr[0].ToString());
}
st = @"SELECT MAX(exam_details.max_marks) AS max_marks
FROM exam_master INNER JOIN exam_details ON exam_master.e_id = exam_details.e_id
WHERE (exam_master.c_id = 1) AND (exam_master.e_name LIKE 'SA%')";
dr = db.readall(st);
if (dr.Read() == true)
{
smax_marks = Convert.ToDouble(dr[0].ToString());
}
st = @" SELECT results.sb_id, student_master.s_name, results.FA1 / " + fmax_marks + " *100 AS FA1, results.FA1 / " + fmax_marks + "* 100 AS FA2, results.SA1 / " + smax_marks + " * 100 AS SA1, results.FA1 / " + fmax_marks + "*100 AS FA3, results.FA1 / " + fmax_marks + " * 100 AS FA4, results.SA2 / " + smax_marks + " * 100 AS SA2, results.st_no, subject_master.sub_name,0 as '%'";
st += " FROM results INNER JOIN student_master ON results.st_no = student_master.st_no INNER JOIN subject_master ON results.sb_id = subject_master.sb_id WHERE (results.st_no = 1) AND (results.c_id = 1)";
dd.Open();
db.fids(st, gvdata);
SqlDataAdapter sqlda = new SqlDataAdapter(st, dd);
sqlda.Fill(dsData);
dd.Close();
}
catch
{
throw;
}
return dsData.Tables[0];
}
protected void gvdata_RowDataBound(object sender, GridViewRowEventArgs e)
{
//if (e.Row.RowType == DataControlRowType.DataRow)
//{
foreach(GridViewRow row in gvdata.Rows)
{
// Label label2 = (Label)row.FindControl("label");
Label label3 = (Label)row.FindControl("Label3");
Label label4 = (Label)row.FindControl("Label4");
Label label5 = (Label)row.FindControl("Label5");
Label label6 = (Label)row.FindControl("Label6");
Label label7 = (Label)row.FindControl("Label7");
Label label8 = (Label)row.FindControl("Label8");
Label label1 = (Label)row.FindControl("Label1");
// st = @" SELECT id ,sum(FA1+FA2+SA1+FA3+FA4+SA2 ) as total, sum(FA1+FA2+SA1+FA3+FA4+SA2 )/6 as avg from results group by id";
x = (Convert.ToDouble(db.chk_ch_0(label3.Text)) + Convert.ToDouble(db.chk_ch_0(label4.Text)) + Convert.ToDouble(db.chk_ch_0(label5.Text)) + Convert.ToDouble(db.chk_ch_0(label6.Text)) + Convert.ToDouble(db.chk_ch_0(label7.Text)) + Convert.ToDouble(db.chk_ch_0(label8.Text))) / 6;
// st = (db.chk_ch_0(label3.Text) + db.chk_ch_0(label4.Text) + db.chk_ch_0(label5.Text) + db.chk_ch_0(label6.Text) + db.chk_ch_0(label7.Text) + db.chk_ch_0(label8.Text));
label1.Text = x.ToString();
}
// }
}
}
Thise is my code ........Please help me soon regarding thise
Reply
Answers (
1
)
Getting the value of Query String
How To classify Read and Unread news in Feed Reader?