图表缩放DotNet.HighCharts和WebForms

时间:2016-09-02 21:09:32

标签: c# asp.net highcharts zoom zooming

嗨,我正在做一个图表,需要放大并观察不同的距离并在上下班

不是放置缩放参数

从数据库中获取数据,但这是我完成项目所需的最后一部分

asp.net

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Grafica.aspx.cs" Inherits="GraficaPrueba.Grafica" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
   <head runat="server"> 
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
      <script type="text/javascript" src="http://code.highcharts.com/highcharts.js"></script>
      <script type="text/javascript" src="http://code.highcharts.com/modules/exporting.js"></script>

     <title></title>
  </head>
  <body>
     <form id="form1" runat="server">
        <div>
           <asp:Literal id="chrtMyChart" runat="server"></asp:Literal>
        </div>
     </form>
  </body>
</html>

以及从中获取的数据 -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------------------.................... .................................................. .................................................. .......................

namespace GraficaPrueba
{
    public partial class Grafica : System.Web.UI.Page
    {
        SqlConnection cn;
        SqlCommand cmd;
        SqlDataReader dr;
        protected void Page_Load(object sender, EventArgs e)
        {
            Grafica_Chart();
        }

        public byte[] selectAlarmas(int idPAciente)
        {
            try
            {
                cn = new SqlConnection("Data Source=JAVIERCASASUC;Initial Catalog=FUCS;Persist Security Info=True;User ID=pasante1;Password=sebastian1");
                cn.Open();
                Console.Write("conectado bien");
            }
            catch (Exception e)
            {
                Console.Write("no se conecto" + e);
            }
            byte[] Datos = null;
            List<int> numeros = new List<int>();
            try
            {
                cmd = new SqlCommand("Select ECG1 From dbo.Alarm where PatientiID=" + idPAciente + ";", cn);
                dr = cmd.ExecuteReader();
            }
            catch (Exception e)
            {
                Console.Write("No se puede Consultar bien " + e.ToString());
            }
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        Datos = (byte[])dr.GetValue(0);
                        for (int i = 0; i < Datos.Length; i++)
                        {
                            numeros.Add(Datos[i]);
                        }
                    }
                }
            }
            return Datos;
        }

        protected void Grafica_Chart()
        {
            byte[] Datos = null;
            List<int> graficoY = new List<int>();
            Datos = selectAlarmas(104);
            Object[] chartValues = new Object[Datos.Length];
            for (int i = 0; i < Datos.Length; i++)
            {
                chartValues[i] = Datos[i];
            }


            // Declare the HighCharts object    
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart").InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
            //DotNet.Highcharts.Highcharts chart2 = new DotNet.Highcharts.Highcharts("chart").InitChart(new Chart { DefaultSeriesType = })    
                .SetSeries(new[]
                        {
                        new Series
                        {
                            Name = "ECG1",
                            Data = new Data(chartValues)   // Here we put the dbase data into the chart    

                        },
                    });


            chrtMyChart.Text = chart.ToHtmlString(); // Let's visualize the chart into the webform.

        }



    }
}

0 个答案:

没有答案