MS Chart 인쇄

9435 단어 chart
 protected void btnPrint_Click(object sender, EventArgs e)

        {

           hidPrint.Value = "1";



                    // 

                    PrintDocument printdoc = new PrintDocument();

                    // 

                    printdoc.PrintPage += new PrintPageEventHandler(printdoc_PrintPage);

                    PaperSize ps = new PaperSize("print_ps", 2100, 2700);

                    printdoc.DefaultPageSettings.PaperSize = ps;

                    printdoc.DefaultPageSettings.Landscape = false;



                    // 

                    printdoc.Print();

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "A", "showMessage(' ',true);", true);

                }

 
  <asp:Chart ID="Chart1" runat="server" Width="630px" Height="450px" Style="text-align: left"

                    Palette="Excel" ImageLocation="~/TempImages/ChartPic_#SEQ(400,3)">

                    <Series>

                        <asp:Series ChartType="Pie" Name="Series1" ChartArea="ChartArea1" Legend="Legend1">

                        </asp:Series>

                    </Series>

                    <ChartAreas>

                        <asp:ChartArea Name="ChartArea1">

                        </asp:ChartArea>

                    </ChartAreas>

                    <Legends>

                        <asp:Legend Name="Legend1">

                        </asp:Legend>

                    </Legends>

                </asp:Chart>
protected void SetChartData()

        {

            Bms_SecurityHiddenTypeCollection collection = new Bms_SecurityHiddenTypeBLL().GetSecurityHiddenTypeRate(Conditions);



            // 

            Chart1.DataSource = collection;



            // 

            Chart1.Series["Series1"].Label = "#PERCENT{P2}";



            // 

            Chart1.Series["Series1"].LegendText = "#VALX";

            //// X 

            //Chart1.Series[0].PostBackValue = "#VALX";

            Chart1.Series["Series1"].Points.DataBindXY(collection, "TypeName", collection, "Rate");

            // 

            Chart1.DataBind();



            Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;

            Chart1.ChartAreas["ChartArea1"].Area3DStyle.Inclination = 45;

            Chart1.ChartAreas["ChartArea1"].Area3DStyle.Rotation = 45;

            Chart1.Series["Series1"]["PieLabelStyle"] = "Outside";

        }
 void printdoc_PrintPage(object sender, PrintPageEventArgs e)

        {

            // 

            string path = Server.MapPath(string.Format("../TempImageFiles/chart_{0}.png", DateTime.Now.ToString("yyyyMMddhhmmssfff")));

            Chart1.SaveImage(path, ChartImageFormat.Png);

            Bitmap b = new Bitmap(path);

            e.Graphics.DrawImage(b, e.MarginBounds.Left, e.MarginBounds.Top);

            e.PageSettings.Landscape = true;



        }

좋은 웹페이지 즐겨찾기