zoukankan      html  css  js  c++  java
  • MS 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;
    
            }
  • 相关阅读:
    C++引用之引用的使用
    C++引用之声明方法
    C++const与指针
    C++默认参数值函数
    LeanCloud 调研报告
    [译] 为何流处理中局部状态是必要的
    Z-Stack
    Think twice before starting the adventure
    Multi-pattern string match using Aho-Corasick
    C pointer again …
  • 原文地址:https://www.cnblogs.com/FH-cnblogs/p/3494178.html
Copyright © 2011-2022 走看看