Please help on subject mail.
Plesae find the below code.
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TagIndexdemo.aspx.cs" Inherits="TagIndexdemo" %>
- <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <img src="logo_73492.gif" style="height: 63px; width: 267px; margin-top: 0px" />
- </head>
- <body>
- <form id="form1" runat="server">
- <asp:ScriptManager ID="ScriptManager1" runat="server">
- </asp:ScriptManager>
- <div>
- <table>
- <tr>
- <td>
- <asp:DropDownList ID="ddltagindex" runat="server" Width="119px" >
- <asp:ListItem>-------Select ----</asp:ListItem>
- <asp:ListItem>TagIndex1</asp:ListItem>
- <asp:ListItem>TagIndex2</asp:ListItem>
- <asp:ListItem>TagIndex3</asp:ListItem>
- <asp:ListItem>TagIndex4</asp:ListItem>
- <asp:ListItem>TagIndex5</asp:ListItem>
- <asp:ListItem>TagIndex6</asp:ListItem>
- </asp:DropDownList>
- </td>
- <td>
- <asp:Label ID="lblFromdate" runat="server" Text="FromDate"></asp:Label>
- </td>
- <td>
- <asp:TextBox ID="txtfromdate" runat="server"></asp:TextBox>
- <asp:CalendarExtender ID="FromYearTxt_CalendarExtender" runat="server" Enabled="True"
- TargetControlID="txtfromdate" Format="yyyy-MM-dd hh:mm:ss"></asp:CalendarExtender>
- </td>
- <td>
- <asp:Label ID="lbltodate" runat="server" Text="ToDate"></asp:Label>
- </td>
- <td>
- <asp:TextBox ID="txttodate" runat="server"></asp:TextBox>
- <asp:CalendarExtender ID="CalendarExtender1" runat="server" Enabled="True"
- TargetControlID="txttodate" Format="yyyy-MM-dd hh:mm:ss"></asp:CalendarExtender>
- </td>
- </tr>
- </table>
- <br />
- <br />
- <br />
- <table>
- <tr>
- <td>
- <asp:Button ID="Btnsubmit" runat="server" Text="Submit" Font-Bold="True" Font-Names="Times New Roman" OnClick="Btnsubmit_Click" />
- </td>
- </tr>
- </table>
- <canvas id="Chart" width="1000" height="700"></canvas>
- </div>
- </form>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.js"></script>
- <script type="text/javascript">
- $(function () {
- var ctx = document.getElementById("Chart").getContext('2d');
- $.ajax({
- url: "TagIndexdemo.aspx/getChartData",
- type: "POST",
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function (response) {
- var chartLabel = eval(response.d[0]);
- var chartData = eval(response.d[1]);
- var chartData1 = eval(response.d[2]);
- var chartData2 = eval(response.d[3]);
- var chartData3 = eval(response.d[4]);
- var chartData4 = eval(response.d[5]);
- var barData = {
- labels: chartLabel,
- datasets: [
- {
- fillColor: "rgba(255, 0, 0, 0.0)",
- strokeColor: "red",
- pointColor: "red",
- pointStrokeColor: "#fff",
- pointHighlightFill: "#fff",
- pointHighlightStroke: "rgba(220,220,220,1)",
- data: chartData
- },
- {
- label: 'PowerFactor',
- fillColor: "rgba(225,225,225,0.2)",
- strokeColor: "Crimson",
- pointColor: "blue",
- pointStrokeColor: "HotPink",
- pointHighlightFill: "",
- pointHighlightStroke: "rgba(220,220,220,1)",
- data: chartData1
- }, {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Data.SqlClient;
- using System.Text;
- using System.Configuration;
- using System.IO;
- using System.Web.Services;
- public partial class TagIndexdemo : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- [WebMethod]
- public static List<string> getChartData()
- {
- var returnData = new List<string>();
- var Con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["demoConnectionString2"].ConnectionString);
- Con.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.CommandText = "ProCreateTagIndex1 ";
-
-
- cmd.Connection = Con;
- SqlDataAdapter adapter = new SqlDataAdapter(cmd);
- DataSet ds = new DataSet();
- try
- {
- adapter.Fill(ds);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- Con.Close();
- Con.Dispose();
- }
- var chartLabel = new StringBuilder();
- var chartData = new StringBuilder();
- var chartData1 = new StringBuilder();
- var chartData2 = new StringBuilder();
- var chartData3 = new StringBuilder();
- var chartData4 = new StringBuilder();
- chartLabel.Append("[");
- chartData.Append("[");
- chartData1.Append("[");
- chartData2.Append("[");
- chartData3.Append("[");
- chartData4.Append("[");
- foreach (DataRow row in ds.Tables[0].Rows)
- {
- chartLabel.Append(string.Format("'{0}',", row["DateAndTime"].ToString()));
- chartData.Append(string.Format("'{0}',", row["TagIndex1"].ToString()));
- chartData1.Append(string.Format("'{0}',", row["TagIndex2"].ToString()));
- chartData2.Append(string.Format("'{0}',", row["TagIndex3"].ToString()));
- chartData3.Append(string.Format(" '{0}',", row["TagIndex4"].ToString()));
- chartData4.Append(string.Format("' {0}',", row["TagIndex5"].ToString()));
- }
- chartData.Length--;
- chartData.Append("]");
- chartData1.Length--;
- chartData1.Append("]");
- chartData2.Length--;
- chartData2.Append("]");
- chartData3.Length--;
- chartData3.Append("]");
- chartData4.Length--;
- chartData4.Append("]");
- chartLabel.Length--;
- chartLabel.Append("]");
- returnData.Add(chartLabel.ToString());
- returnData.Add(chartData.ToString());
- returnData.Add(chartData1.ToString());
- returnData.Add(chartData2.ToString());
- returnData.Add(chartData3.ToString());
- returnData.Add(chartData4.ToString());
- return returnData;
- }
- protected void Btnsubmit_Click(object sender, EventArgs e)
- {
- txtfromdate.Text = "";
- txttodate.Text = "";
- }
- }