Engaged in ASP. NET development may be exposed to some chart controls, such as OWC and ZendGraph. These controls have a feature that we can operate like. objects in. NET control some of their attributes, which may cause permission issues during local development and upload to the server, resulting in failure to run properly. This week tells us about a JavaScript chart control. Don't underestimate this JavaScript chart control. It can generate various common charts.
Encoding
For ease of demonstration, Zhou Gong used the single-page mode when creating an ASP. NET page. The code for the whole page is as follows:
<% @ Page Language = "C #" %>
<% @ Import Namespace = "System. Text" %>
<% @ Import Namespace = "System. IO" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Mce: script runat = "server"> <! --
Public string result = string. Empty;
Protected void Page_Load (object sender, EventArgs e)
{
String graphType = ddlGraphType. SelectedValue;
GraphType = graphType. ToLower ();
Switch (graphType)
{
Case "line": result = OutputLine (); break;
Case "spline": result = OutputSpline (); break;
Case "area": result = OutputArea (); break;
Case "areaspline": result = OutputAreaSpline (); break;
Case "column": result = OutputColumn (); break;
Case "bar": result = OutputBar (); break;
Case "pie": result = OutputPie (); break;
Case "scatter": result = OutputScatter (); break;
}
}
Private string OutputLine ()
{
String result = string. Empty;
Using (StreamReader reader = new StreamReader (Server. MapPath ("~ /Js/template/line. js "), Encoding. UTF8 ))
{
StringBuilder buffer = new StringBuilder (reader. ReadToEnd ());
Buffer. Replace ("{# title #}"," Zhou Gong's demo ");
Result = buffer. ToString ();
}
Return result;
}
Private string OutputSpline ()
{
String result = string. Empty;
Using (StreamReader reader = new StreamReader (Server. MapPath ("~ /Js/template/spline. js "), Encoding. UTF8 ))
{
StringBuilder buffer = new StringBuilder (reader. ReadToEnd ());
Buffer. Replace ("{# title #}"," Zhou Gong's demo ");
Result = buffer. ToString ();
}
Return result;
}
Private string OutputArea ()
{
String result = string. Empty;
Using (StreamReader reader = new StreamReader (Server. MapPath ("~ /Js/template/area. js "), Encoding. UTF8 ))
{
StringBuilder buffer = new StringBuilder (reader. ReadToEnd ());
Buffer. Replace ("{# title #}"," Zhou Gong's demo ");
Result = buffer. ToString ();
}
Return result;
}
Private string OutputAreaSpline ()
{
String result = string. Empty;
Using (StreamReader reader = new StreamReader (Server. MapPath ("~ /Js/template/areaspline. js "), Encoding. UTF8 ))
{
StringBuilder buffer = new StringBuilder (reader. ReadToEnd ());
Buffer. Replace ("{# title #}"," Zhou Gong's demo ");
Result = buffer. ToString ();
}
Return result;
}
Private string OutputColumn ()
{
String result = string. Empty;
Using (StreamReader reader = new StreamReader (Server. MapPath ("~ /Js/template/column. js "), Encoding. UTF8 ))
{
StringBuilder buffer = new StringBuilder (reader. ReadToEnd ());
Buffer. Replace ("{# title #}"," Zhou Gong's demo ");
Result = buffer. ToString ();
}
Return result;
}
Private string OutputBar ()
{
String result = string. Empty;
Using (StreamReader reader = new StreamReader (Server. MapPath ("~ /Js/template/bar. js "), Encoding. UTF8 ))
{