• Highcharts 二种导出方式


    HightCharts 导出资源放在 http://export.highcharts.com/ 这个服务器上面,如果想控制导出的内容还是比较麻烦的。

    有的时候希望把多张图片打包成一个PDF,或者说在PDF追加点文字。

    2种方法介绍
    1.webconfig 追加 httpHandlers。每次提交前走HighchartsExport.axd这里过一把。源代码下载

        <system.web>
            <httpHandlers>
                <add verb="POST" path="HighchartsExport.axd" type="Tek4.Highcharts.Exporting.HttpHandler, Tek4.Highcharts.Exporting"/>
            </httpHandlers>
            <compilation debug="true"/>
      </system.web>



    2.在js里面post请求


     
        <script>
            function download() {
                var chart = $('#container').highcharts()
                svg = chart.getSVG();
    
                $.ajax({
                    async: true,
                    url: 'HighchartsExport.axd',
                    type: 'post',
                    data: { "svg": svg },
                    success: function (data) {
                        d = data;
                    }
                });
    
    
            }
        </script>
    
    
    
    
    internal static void ProcessExportRequest(HttpContext context)
    {
      if (context != null &&
        context.Request != null &&
        context.Response != null &&
        context.Request.HttpMethod == "POST")
      {
        HttpRequest request = context.Request;
    
        // Get HTTP POST form variables, ensuring they are not null.
        string filename = request.Form["filename"];
        string type = request.Form["type"];
        int width = 0;
        //这里可以得到svg 图片
        string svg = request.Form["svg"];
    
        if (filename != null &&
          type != null &&
          Int32.TryParse(request.Form["width"], out width) &&
          svg != null)
        {
          // Create a new chart export object using form variables.
          Exporter export = new Exporter(filename, type, width, svg);
    
          // Write the exported chart to the HTTP Response object.
          export.WriteToHttpResponse(context.Response);
    
          // Short-circuit this ASP.NET request and end. Short-circuiting
          // prevents other modules from adding/interfering with the output.
          HttpContext.Current.ApplicationInstance.CompleteRequest();
          context.Response.End();
        }
      }   
    }
  • 相关阅读:
    16.ajax_case08
    16.ajax_case07
    16.ajax_case06
    16.ajax_case05
    9.2 sun.py
    9.1 mongo_python.py
    pandas-如何得到某一个值所在的行
    [已解决]ValueError: row index was 65536, not allowed by .xls format
    [已解决]python FileNotFoundError: [WinError 3] for getsize(filepath)
    Tomcat6连接数设置:permsize
  • 原文地址:https://www.cnblogs.com/kfsmqoo/p/5455972.html
Copyright © 2020-2023  润新知