public void PieGraph(Excel.Chart chart, Excel.Worksheet targetSheet, Excel.Range dataRange)
    {
        //chart.ChartType = Excel.XlChartType.xl3DPie;
        chart.SetSourceData(dataRange, Excel.XlRowCol.xlColumns);

        string strModel = Convert.ToString(drpModel.SelectedItem.Text);
        string strReportType = "";
        if (rdoCost.Checked)
        {
            strReportType = "Cost";
        }
        else
        {
            strReportType = "Defect";
        }

        string strHMR = "";
        if (rdoHMRAll.Checked)
        {
            strHMR = "All";
        }
        else if (rdoLessThan250.Checked)
        {
            strHMR = "0 to 250 Hours";
        }
        else
        {
            strHMR = "251 to 2500 Hours";
        }
        string strYear = "";
        if (rdoYear.SelectedIndex == 0)
        {
            strYear = "I Year";
        }
        else if (rdoYear.SelectedIndex == 1)
        {
            strYear = "II Year";
        }
        else
        {
            strYear = "Total";
        }

        chart.HasTitle = true;
        //chart.ChartTitle.Font.Bold = true;
        chart.ChartTitle.Font.Size = 15;
        chart.ChartTitle.Text = "Model: " + strModel;
        chart.ChartTitle.Text += "\n " + strReportType + " / Tractor ";
        chart.ChartTitle.Text += "| HMR:" + strHMR;
        chart.ChartTitle.Text += "\n " + strYear;
        chart.ChartTitle.Font.Name = "Times New Roman";
        chart.PlotArea.Fill.ForeColor.SchemeColor = 2;
        chart.PlotArea.Border.ColorIndex = Excel.Constants.xlNone;

        chart.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowValue, null, null, false, false, false, true, false, false, ",");
        chart.HasLegend = true;

        Excel.Series oSeriesBar = null;
        oSeriesBar = (Excel.Series)chart.SeriesCollection(1);
        oSeriesBar.Border.ColorIndex = Excel.Constants.xlNone;
        oSeriesBar.HasLeaderLines = true;

        DataTable dsData =GetTable();
        int colcount = dsData.Columns.Count;
        int rowcount = dsData.Rows.Count;

        int flag = 1;
        int colorflag = 1;
        int colorindex = 8;
        float deg = 0.0F;
        foreach (DataRow dr in dsData.Rows)
        {

            Excel.Point oPoint = null;

            oPoint = (Excel.Point)oSeriesBar.Points(flag);
            oPoint.DataLabel.Font.Name = "Palatino Linotype";
            oPoint.DataLabel.Font.Size = 12;

            if (colorflag == 1)
            {
                colorindex = 8;
                deg = 0.3F;
            }
            else if (colorflag == 2)
            {
                colorindex = 50;
                deg = 0.3F;
            }
            else if (colorflag == 3)
            {
                colorindex = 4;
                deg = 0.3F;
            }
            else if (colorflag == 4)
            {
                colorindex = 6;
                deg = 0.3F;
            }
            else if (colorflag == 5)
            {
                colorindex = 22;
                deg = 0.3F;
            }
            else if (colorflag == 6)
            {
                colorindex = 24;
                deg = 0.3F;
            }
            else if (colorflag == 7)
            {
                colorindex = 39;  //26
                deg = 0.3F;
            }
            else if (colorflag == 7)
            {
                colorindex = 26;
                deg = 0.3F;
            }
            else if (colorflag == 7)
            {
                colorindex = 26;
                deg = 0.3F;
            }
            else if (colorflag == 7)
            {
                colorindex = 26;
                deg = 0.3F;
            }

            oPoint.DataLabel.Font.Bold = true;
            oPoint.Fill.ForeColor.SchemeColor = colorindex;
            oPoint.Fill.OneColorGradient(MsoGradientStyle.msoGradientHorizontal, 1, deg);

            colorflag++;
            if (colorflag > 7)
            {
                colorflag = 1;
            }
            flag = flag + 1;
        }
        /**************************************************************************************************/
    }
Example #2
0
    public void ColumnGraph(Excel.Chart chart, Excel.Worksheet targetSheet, Excel.Range dataRange)
    {
        chart.SetSourceData(dataRange, Excel.XlRowCol.xlColumns);
        string strChartType = Convert.ToString(chart.ChartType);

        string strModel = "";
        string strItem = "";
        if (chkSelectAll.Checked)
        {
            strModel = "All";
        }
        else
        {
            int modelflag = 0;
            foreach (ListItem modellist in chkModelCodeList.Items)
            {
                if (modellist.Selected)
                {
                    if (modelflag > 0)
                    {
                        strModel += " , ";
                    }
                    strModel += modellist.Text;
                    modelflag++;
                }
            }
        }

        if (ChkAllitemlist.Checked)
        {
            strItem = "All";
        }
        else
        {
            int itemflag = 0;
            foreach (ListItem itemlist in Chkitemlist.Items)
            {
                if (itemlist.Selected)
                {
                    if (itemflag > 0)
                    {
                        strItem += " , ";
                    }
                    strItem += itemlist.Text;
                    itemflag++;
                }
            }
        }

        chart.HasTitle = true;
        chart.ChartTitle.Font.Bold = true;
        chart.ChartTitle.Font.Size = 15;
        chart.ChartTitle.Text = "Model: " + strModel;
        chart.ChartTitle.Text += "\n Item:" + strItem;
        chart.ChartTitle.Font.Name = "Times New Roman";
        chart.PlotArea.Fill.ForeColor.SchemeColor = 2;

        //chart.Walls.Fill.ForeColor.SchemeColor = 20;
        //chart.Walls.Fill.OneColorGradient(MsoGradientStyle.msoGradientHorizontal, 1, 0.3F);

        Excel.Axes xlAxisCategory;
        Excel.Axes xlAxisValue;
        object orient = 40;
        try
        {
            xlAxisCategory = (Excel.Axes)chart.Axes(Type.Missing, Excel.XlAxisGroup.xlPrimary);
            //xlAxisCategory = (Excel.Axes)chart.Axes(null, Excel.XlAxisGroup.xlPrimary);
            //xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).HasTitle = true;
            //xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = "Financial Year";
            xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).TickLabels.Orientation = (Excel.XlTickLabelOrientation)orient;
            xlAxisValue = (Excel.Axes)chart.Axes(Type.Missing, Excel.XlAxisGroup.xlPrimary);
            xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).HasTitle = true;
            xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = "Failure/1000 Tractors";

        }
        catch { }

        chart.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowValue, null, null, false, false, false, true, false, false, ",");
        chart.HasLegend = false;

        Excel.Series oSeriesBar = null;
        oSeriesBar = (Excel.Series)chart.SeriesCollection(1);
        if (strChartType != "xlLine")
        {
            oSeriesBar.Border.ColorIndex = Excel.Constants.xlNone;
        }

        DataTable dsData = GetTable();
        int colcount = dsData.Columns.Count;
        int rowcount = dsData.Rows.Count;

        int flag = 1;
        int colorflag = 1;
        int colorindex = 8;
        //float deg = 0.0F;
        //foreach (DataRow dr in dsData.Rows)
        //{

        //    Excel.Point oPoint = null;

        //    oPoint = (Excel.Point)oSeriesBar.Points(flag);
        //    oPoint.DataLabel.Font.Name = "Palatino Linotype";
        //    oPoint.DataLabel.Font.Size = 12;

        //    if (colorflag == 1)
        //    {
        //        colorindex = 8;
        //        deg = 0.3F;
        //    }
        //    else if (colorflag == 2)
        //    {
        //        colorindex = 50;
        //        deg = 0.3F;
        //    }
        //    else if (colorflag == 3)
        //    {
        //        colorindex = 4;
        //        deg = 0.3F;
        //    }
        //    else if (colorflag == 4)
        //    {
        //        colorindex = 6;
        //        deg = 0.3F;
        //    }
        //    else if (colorflag == 5)
        //    {
        //        colorindex = 22;
        //        deg = 0.3F;
        //    }
        //    else if (colorflag == 6)
        //    {
        //        colorindex = 24;
        //        deg = 0.3F;
        //    }
        //    else if (colorflag == 7)
        //    {
        //        colorindex = 39;  //26
        //        deg = 0.3F;
        //    }
        //    else if (colorflag == 7)
        //    {
        //        colorindex = 26;
        //        deg = 0.3F;
        //    }
        //    else if (colorflag == 7)
        //    {
        //        colorindex = 26;
        //        deg = 0.3F;
        //    }
        //    else if (colorflag == 7)
        //    {
        //        colorindex = 26;
        //        deg = 0.3F;
        //    }

        //    oPoint.DataLabel.Font.Bold = true;
        //    oPoint.Fill.ForeColor.SchemeColor = colorindex;
        //    oPoint.Fill.OneColorGradient(MsoGradientStyle.msoGradientHorizontal, 1, deg);

        //    colorflag++;
        //    if (colorflag > 7)
        //    {
        //        colorflag = 1;
        //    }
            flag = flag + 1;
           // }
        /**************************************************************************************************/
    }
    public void ColumnGraph(Excel.Chart chart, Excel.Worksheet targetSheet, Excel.Range dataRange)
    {
        chart.SetSourceData(dataRange, Excel.XlRowCol.xlColumns);
        string strChartType = Convert.ToString(chart.ChartType);

        string strModel = Convert.ToString(drpModel.SelectedItem.Text);
        string strReportType = "";
        if (rdoCost.Checked)
        {
            strReportType = "Cost";
        }
        else
        {
            strReportType = "Defect";
        }

        string strHMR = "";
        if (rdoHMRAll.Checked)
        {
            strHMR = "All";
        }
        else if (rdoLessThan250.Checked)
        {
            strHMR = "0 to 250 Hours";
        }
        else
        {
            strHMR = "251 to 2500 Hours";
        }
        string strYear = "";
        if (rdoYear.SelectedIndex == 0)
        {
            strYear = "I Year";
        }
        else if (rdoYear.SelectedIndex == 1)
        {
            strYear = "II Year";
        }
        else
        {
            strYear = "Total";
        }

        chart.HasTitle = true;
        //chart.ChartTitle.Font.Bold = true;
        chart.ChartTitle.Font.Size = 15;
        chart.ChartTitle.Text = "Model: " + strModel;
        chart.ChartTitle.Text += "\n " + strReportType + " / Tractor ";
        chart.ChartTitle.Text += "| HMR:"+ strHMR;
        chart.ChartTitle.Text += "\n " + strYear ;
        chart.ChartTitle.Font.Name = "Times New Roman";
        chart.PlotArea.Fill.ForeColor.SchemeColor = 2;

        //chart.Walls.Fill.ForeColor.SchemeColor = 20;
        //chart.Walls.Fill.OneColorGradient(MsoGradientStyle.msoGradientHorizontal, 1, 0.3F);

        Excel.Axes xlAxisCategory;
        Excel.Axes xlAxisValue;
        object orient = 40;
        try
        {
            xlAxisCategory = (Excel.Axes)chart.Axes(Type.Missing, Excel.XlAxisGroup.xlPrimary);
            //xlAxisCategory = (Excel.Axes)chart.Axes(null, Excel.XlAxisGroup.xlPrimary);
            //xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).HasTitle = true;
            //xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = "Financial Year";
            xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).TickLabels.Orientation = (Excel.XlTickLabelOrientation)orient;
            xlAxisValue = (Excel.Axes)chart.Axes(Type.Missing, Excel.XlAxisGroup.xlPrimary);
            xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).HasTitle = true;
            xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = "Rs.";

        }
        catch { }

        chart.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowValue, null, null, false, false, false, true, false, false, ",");
        chart.HasLegend = false;

        Excel.Series oSeriesBar = null;
        oSeriesBar = (Excel.Series)chart.SeriesCollection(1);
        if (strChartType != "xlLine")
        {
            oSeriesBar.Border.ColorIndex = Excel.Constants.xlNone;
        }

        DataTable dsData = GetTable();
        int colcount = dsData.Columns.Count;
        int rowcount = dsData.Rows.Count;

        int flag = 1;
        int colorflag = 1;
        int colorindex = 8;
        float deg = 0.0F;
        foreach (DataRow dr in dsData.Rows)
        {

            Excel.Point oPoint = null;

            oPoint = (Excel.Point)oSeriesBar.Points(flag);
            oPoint.DataLabel.Font.Name = "Palatino Linotype";
            oPoint.DataLabel.Font.Size = 12;

            if (colorflag == 1)
            {
                colorindex = 8;
                deg = 0.3F;
            }
            else if (colorflag == 2)
            {
                colorindex = 50;
                deg = 0.3F;
            }
            else if (colorflag == 3)
            {
                colorindex = 4;
                deg = 0.3F;
            }
            else if (colorflag == 4)
            {
                colorindex = 6;
                deg = 0.3F;
            }
            else if (colorflag == 5)
            {
                colorindex = 22;
                deg = 0.3F;
            }
            else if (colorflag == 6)
            {
                colorindex = 24;
                deg = 0.3F;
            }
            else if (colorflag == 7)
            {
                colorindex = 39;  //26
                deg = 0.3F;
            }
            else if (colorflag == 7)
            {
                colorindex = 26;
                deg = 0.3F;
            }
            else if (colorflag == 7)
            {
                colorindex = 26;
                deg = 0.3F;
            }
            else if (colorflag == 7)
            {
                colorindex = 26;
                deg = 0.3F;
            }

            oPoint.DataLabel.Font.Bold = true;
            oPoint.Fill.ForeColor.SchemeColor = colorindex;
            oPoint.Fill.OneColorGradient(MsoGradientStyle.msoGradientHorizontal, 1, deg);

            colorflag++;
            if (colorflag > 7)
            {
                colorflag = 1;
            }
            flag = flag + 1;
        }
        /**************************************************************************************************/
    }
Example #4
0
    public void ColumnGraph(Excel.Chart chart, Excel.Worksheet targetSheet, Excel.Range dataRange)
    {
        chart.SetSourceData(dataRange, Excel.XlRowCol.xlRows);
        string strChartType = Convert.ToString(chart.ChartType);

        string strModel = "";
        string strItem = "";
        if (chkSelectAll.Checked)
        {
            strModel = "All";
        }
        else
        {
            int modelflag = 0;
            foreach (ListItem modellist in chkModelCodeList.Items)
            {
                if (modellist.Selected)
                {
                    if (modelflag > 0)
                    {
                        strModel += " , ";
                    }
                    strModel += modellist.Text;
                    modelflag++;
                }
            }
        }

        if (ChkAllitemlist.Checked)
        {
            strItem = "All";
        }
        else
        {
            int itemflag = 0;
            foreach (ListItem itemlist in Chkitemlist.Items)
            {
                if (itemlist.Selected)
                {
                    if (itemflag > 0)
                    {
                        strItem += " , ";
                    }
                    strItem += itemlist.Text;
                    itemflag++;
                }
            }
        }
        chart.HasDataTable = true;
        chart.HasTitle = true;
        chart.HasLegend = true;
        chart.ChartTitle.Font.Bold = true;
        chart.ChartTitle.Font.Size = 15;
        chart.ChartTitle.Text = "Model: " + strModel;
        //chart.ChartTitle.Text += "\n Item:" + strItem;   Changed on 20 Feb 2010

        chart.ChartTitle.Text += "\n Group:" + drpItemGroup.SelectedItem.Text;
        chart.ChartTitle.Font.Name = "Times New Roman";
        chart.PlotArea.Fill.ForeColor.SchemeColor = 2;

        //chart.Walls.Fill.ForeColor.SchemeColor = 20;
        //chart.Walls.Fill.OneColorGradient(MsoGradientStyle.msoGradientHorizontal, 1, 0.3F);

        Excel.Axes xlAxisCategory;
        Excel.Axes xlAxisValue;
        object orient = 40;
        try
        {
            xlAxisCategory = (Excel.Axes)chart.Axes(Type.Missing, Excel.XlAxisGroup.xlPrimary);
            xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).TickLabels.Orientation = (Excel.XlTickLabelOrientation)orient;
            xlAxisValue = (Excel.Axes)chart.Axes(Type.Missing, Excel.XlAxisGroup.xlPrimary);
            xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).HasTitle = true;
            xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = "Cumulative Failure/1000 Tractors";

        }
        catch { }

        chart.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowValue, null, null, false, false, false, false, false, false, ",");
        chart.HasLegend = false;

        DataTable dsData = GetTable();
        int colcount = dsData.Columns.Count;
        int rowcount = dsData.Rows.Count;

        /**************************************************************************************************/
    }