Use Highcharts js charts in ASP. NET

Source: Internet
Author: User

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 ))
{

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.