首先,我对C#和Json很新.
我想在C#GUI中绘制mysql表数据的图形.我制作了一个PHP文件来从mysql数据库表中选择数据并使用json数组回显所选内容echo json_encode(array("result"=>$result))
这是我的PHP:
$row[0],'p_pairs'=>$row[1],'temp1'=>$row[2] ,'temp2'=>$row[3],'temp3'=>$row[4],'temp4'=>$row[5],'temp5'=>$row[6],'avg_current'=>$row[7],'avg_voltage'=>$row[8],'kw'=>$row[9],'kwh'=>$row[10])); } echo json_encode(array($result)); mysqli_close($con); ?>
使用链接,我可以清楚地看到日期时间间隙之间的json数组.我想要的是用线图中的date_time绘制温度值(temp1,temp2,..),p对值等的图形.阅读历史数据.
我访问PHP页面时得到的是:
[[{"id":"1","p_pairs":"0000-00-00 00:00:00","temp1":"2","temp2":"100","temp3":"100","temp4":"100","temp5":"100","avg_current":"100","avg_voltage":"300","kw":"300","kwh":"300"},{"id":"2","p_pairs":"0000-00-00 00:00:00","temp1":"45","temp2":"105","temp3":"230","temp4":"100","temp5":"2500","avg_current":"570","avg_voltage":"100","kw":"250","kwh":"1000"},{"id":"3","p_pairs":"2016-01-07 21:10:00","temp1":"45","temp2":"105","temp3":"230","temp4":"100","temp5":"2500","avg_current":"570","avg_voltage":"100","kw":"250","kwh":"1000"},{"id":"4","p_pairs":"2016-01-07 21:10:00","temp1":"45","temp2":"105","temp3":"230","temp4":"100","temp5":"2500","avg_current":"570","avg_voltage":"100","kw":"250","kwh":"1000"}]]
注意:某些日期时间在此处设置为默认值.我只想展示这个数组.正确的一个将是完美的绘制图形.
我可以使用来自C#的Web请求将这些数组放在一个字符串中.使用波纹管代码:
System.Net.WebClient wc = new System.Net.WebClient(); byte[] raw = wc.DownloadData("url to php"); string webData = System.Text.Encoding.UTF8.GetString(raw);
这将是一个很大的帮助如果有人可以帮我在线图中绘制这个作为date_time Vs temp1,temp2或p_pairs,就像在C#GUI中那样...
这对我来说将是一个很大的帮助.提前感谢你.