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;
    
            }
  • 相关阅读:
    目标检测网络CenterNet详解(四)
    样本不均衡问题
    目标检测网络Faster RCNN详解(一)
    SpringCloud学习总结(八)——服务调用Feign
    OpenFeign(2020-10-13)
    Feign真正正确的使用方法
    微服务实战SpringCloud之Feign简介及使用
    spring cloud gateway网关和负载均衡框架ribbon实战
    Studio 3T 破解
    JVM 垃圾回收?全面详细安排!
  • 原文地址:https://www.cnblogs.com/FH-cnblogs/p/3494178.html
Copyright © 2011-2022 走看看