using System;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI.DataVisualization.Charting;
using System.Data.SqlClient;


/// <summary>
///DrawChart 的摘要说明
/// </summary>
public partial class DrawChart
{

      /// <summary>
    /// 故障率 lvzhen
    /// </summary>
    /// <param name="dt"></param>
    /// <param name="chart1"></param>
    public static void ChartFaultPercent(DataTable dt, Chart chart1)
    {
        if (dt.Rows.Count == 0)
            return;
        foreach (DataRow row in dt.Rows)
        {
            string seriesName = row["工位号"].ToString();
            chart1.Series.Add(seriesName);
            chart1.Series[seriesName].ChartType = SeriesChartType.Column;
            chart1.Series[seriesName].BorderWidth = 2;
            chart1.Series[seriesName].ToolTip = "工位号：" + row["工位号"].ToString() + "\n运行时间: " + row["运行时间"].ToString() + "\n故障时间: " + row["故障时间"].ToString() + "\n故障率：#VALY";
            for (int colIndex = 3; colIndex < dt.Columns.Count; colIndex++)
            {
                // For each column (column 1 and onward) add the value as a point
                string columnName = dt.Columns[colIndex].ColumnName;
                string YVal = row[columnName].ToString();
                chart1.Series[seriesName].Points.AddXY(columnName, YVal);
            }
            //for (int i = 0; i < 10; i++)
            //{
            //    chart1.Series[seriesName].Points.AddXY(dt.Rows[i]["报警编号"], dt.Rows[i]["报警数量"]);
            //}
            //chart1.DataBind();
        }
    }

    /// <summary>
    /// 故障率 lvzhen
    /// </summary>
    /// <param name="dt"></param>
    /// <param name="chart1"></param>
    public static void ChartFaultPercentTrue(DataTable dt, Chart chart1)
    {
        if (dt.Rows.Count == 0)
            return;
        foreach (DataRow row in dt.Rows)
        {
            string seriesName = row["工位号"].ToString();
            chart1.Series.Add(seriesName);
            chart1.Series[seriesName].ChartType = SeriesChartType.Column;
            chart1.Series[seriesName].BorderWidth = 2;
            chart1.Series[seriesName].ToolTip = "工位号：" + row["工位号"].ToString()+" \n故障率：#VALY";
            for (int colIndex = 3; colIndex < dt.Columns.Count; colIndex++)
            {
                // For each column (column 1 and onward) add the value as a point
                string columnName = dt.Columns[colIndex].ColumnName;
                string YVal = row[columnName].ToString();
                chart1.Series[seriesName].Points.AddXY(columnName, YVal);
            }
            //for (int i = 0; i < 10; i++)
            //{
            //    chart1.Series[seriesName].Points.AddXY(dt.Rows[i]["报警编号"], dt.Rows[i]["报警数量"]);
            //}
            //chart1.DataBind();
        }
    }
    /// <summary>
    /// 开机率 lvzhen
    /// </summary>
    /// <param name="dt"></param>
    /// <param name="chart1"></param>
    public static void ChartKaijiProportion(DataTable dt, Chart chart1)
    {
        chart1.Series[0].Points.DataBind(dt.DefaultView, "操作日期", "开机率", "Tooltip=ToolTip");
    }
   
}