@using System.Data; @using System.Collections.Generic; @using System.Data.SqlClient; @{ Layout = null; string connectionString="Server=192.168.1.125,1433\\sqlexpress; Database=HEK; Uid=sa; Pwd=lubelincek12121"; DataTable dt = new DataTable(); String rows = ""; using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter("SELECT TOP 500 Datum, Sava, P1, P2, P3 FROM vws ORDER BY DATUM DESC", conn)) { adapter.Fill(dt); List<string> rowsList = new List<string>(); // rowsList.Add("['Datum', 'Sava', 'RPWS1']"); foreach (DataRow row in dt.Rows) { //Converts your object into a DateTime (so that it's properties can be accessed properly DateTime yourDate = Convert.ToDateTime(row["Datum"]); rowsList.Add("[new Date(" + yourDate.Year + ", " + (yourDate.Month - 1) + ", " + yourDate.Day + ", " + yourDate.Hour + ", " + yourDate.Minute + ", " + yourDate.Second + "), " + row["Sava"] + ", " + row["P1"] + "," + row["P2"] + "," + row["P3"] + "]"); } rows = String.Join(", ", rowsList); }; }; } @if (Roles.IsUserInRole("admin")||(Roles.IsUserInRole("hek"))){ <span style="color: rgba(0,0,0,.33)"><b></b>.</span> } else{ Response.Redirect("~/members/AdminError"); } <html> <head> <title>Test Graph</title> <script type='text/javascript' src="http://www.google.com/jsapi"></script> <script type="text/javascript" src="/java/asgallant.LineChartAsAnnotatedTimeline[0.4b].js"></script> <script type="text/javascript"> function drawChart() { var data1 = new google.visualization.DataTable() data1.addColumn('datetime', 'Datum'); data1.addColumn('number', 'Sava'); data1.addColumn('number', 'P1'); data1.addColumn('number', 'P2'); data1.addColumn('number', 'P3'); data1.addRows([@Html.Raw(rows)]); var chart = new asgallant.LineChartAsAnnotatedTimeline(document.getElementById('chart_div')); chart.draw(data1, { title: 'Absolutni nivo vode', height: 350, width:850, vAxis: { minValue: 162, maxValue: 164 } }); } google.load('visualization', '1', { 'packages': ['controls'] }); google.setOnLoadCallback(drawChart); </script> </head> <body> <div id="chart_div"></div> </body> </html>
I've copied the whole folder with all java files and everything.Any idead would be appreciated , m
{ //Converts your object into a DateTime (so that it's properties can be accessed properly DateTime yourDate = Convert.ToDateTime(row["Datum"]);
if (Convert.ToString(row["MPT11"]) == "-777") {row["MPT11"]= DBNull.Value;}
if (Convert.ToString(row["MPT12"]) == "-777") {row["MPT12"]= DBNull.Value;}
if (Convert.ToString(row["MPT2"]) == "-777") {row["MPT2"]= DBNull.Value;}
if (Convert.ToString(row["MPT31"]) == "-777") {row["MPT31"]= DBNull.Value;}
if (Convert.ToString(row["MPT32"]) == "-777") {row["MPT32"]= DBNull.Value;}
rowsList.Add("[new Date(" + yourDate.Year + ", " + (yourDate.Month - 1) + ", " + yourDate.Day + ", " + yourDate.Hour + ", " + yourDate.Minute + ", " + yourDate.Second + "), "
+ row["MPT11"] + ", "
+ row["MPT12"] + ", "
+ row["MPT2"] + ", "
+ row["MPT31"] + ", "
+ row["MPT32"] + "]");
Any ideas? could that also be because of regional settings (bTW , this is on local machine, not server).
thanks, m
String lastCol = Convert.ToString(row["MPT32"]);
if (Convert.ToString(row["MPT11"]) == "-777") {row["MPT11"] = DBNull.Value;}
if (Convert.ToString(row["MPT12"]) == "-777") {row["MPT12"] = DBNull.Value;}
if (Convert.ToString(row["MPT2"]) == "-777") {row["MPT2"] = DBNull.Value;}
if (Convert.ToString(row["MPT31"]) == "-777") {row["MPT31"] = DBNull.Value;}
if (lastCol == "-777") {lastCol = "null";}
rowsList.Add("[new Date(" + yourDate.Year + ", " + (yourDate.Month - 1) + ", " + yourDate.Day + ", " + yourDate.Hour + ", " + yourDate.Minute + ", " + yourDate.Second + "), "
+ row["MPT11"] + ", "
+ row["MPT12"] + ", "
+ row["MPT2"] + ", "
+ row["MPT31"] + ", "
+ lastCol + "]");
And it's finally working.
Still having troubles to hack it on server thought...Decimal points vs. Comma.Thanks for the help!
Well, with the help of asp.net forums, i manage to solve part of this.
But i guess when Javascript changes the input from 'string' as C# to number, it changes the dots (.) to commas (,).