hightchart导出图片

通常在使用highchart导出图片pdf等文件时,我们一般直接引入exporting.js即可

执行导出操作则会直接请求highchart服务器,执行生成图片等操作,然后下载到客户端;

但这一切的操作可执行的前提,必须用户使用的pc客户端连接到外网上,否则无法执行下载操作。

我们必须通过自定义的模式,来实现转换、生成图片pdf等操作。

 查询hightchart官网,highchart官网提供了三三种服务端模式,java,php 以及phantomjs(+node),针对我们asp.net程序,如果使用上述三种,还必须依赖其他的http服务器或者即使使用IIS配置也相对麻烦,幸好有一种第三方的.net平台的一种实现:

github地址为:https://github.com/imclem/Highcharts-export-module-asp.net

这里主要记录下使用过程中遇到的一个小问题:

我对hightchart theme进行了设置:

//Highcharts.theme = {
        //    colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
        //    chart: {
        //        backgroundColor: {
        //            linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 },
        //            stops: [
        //                [0, 'rgb(255, 255, 255)'],
        //                [1, 'rgb(240, 240, 255)']
        //            ]
        //        },
        //        borderWidth: 2,
        //        plotBackgroundColor: 'rgba(255, 255, 255, .9)',
        //        plotShadow: true,
        //        plotBorderWidth: 1
        //    },
        //    title: {
        //        style: {
        //            color: '#000',
        //            font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
        //        }
        //    },
        //    subtitle: {
        //        style: {
        //            color: '#666666',
        //            font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
        //        }
        //    },
        //    xAxis: {
        //        gridLineWidth: 1,
        //        lineColor: '#000',
        //        tickColor: '#000',
        //        labels: {
        //            style: {
        //                color: '#000',
        //                font: '11px Trebuchet MS, Verdana, sans-serif'
        //            }
        //        },
        //        title: {
        //            style: {
        //                color: '#333',
        //                fontWeight: 'bold',
        //                fontSize: '12px',
        //                fontFamily: 'Trebuchet MS, Verdana, sans-serif'
        //            }
        //        }
        //    },
        //    yAxis: {
        //        minorTickInterval: 'auto',
        //        lineColor: '#000',
        //        lineWidth: 1,
        //        tickWidth: 1,
        //        tickColor: '#000',
        //        labels: {
        //            style: {
        //                color: '#000',
        //                font: '11px Trebuchet MS, Verdana, sans-serif'
        //            },
        //            formatter: function () {
        //                if (/^\d+$/.test(this.value)) {
        //                    return this.value;
        //                } else {
        //                    return "";
        //                }
        //            }
        //        },
        //        min: 0,
        //        title: {
        //            style: {
        //                color: '#333',
        //                fontWeight: 'bold',
        //                fontSize: '12px',
        //                fontFamily: 'Trebuchet MS, Verdana, sans-serif'
        //            }
        //        }
        //    },
        //    legend: {
        //        itemStyle: {
        //            font: '9pt Trebuchet MS, Verdana, sans-serif',
        //            color: 'black'

        //        },
        //        itemHoverStyle: {
        //            color: '#039'
        //        },
        //        itemHiddenStyle: {
        //            color: 'gray'
        //        }
        //    },
        //    labels: {
        //        style: {
        //            color: '#99b'
        //        }
        //    },

        //    navigation: {
        //        buttonOptions: {
        //            theme: {
        //                stroke: '#CCCCCC'
        //            }
        //        }
        //    }
        //};

         Apply the theme
        //var highchartsOptions = Highcharts.setOptions(Highcharts.theme);

  

如果对highchart theme设置比较多,那么会导致提交的xml文件过大,造成内存溢出的问题。

 

转载于:https://www.cnblogs.com/Johnzhang/p/4497238.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
A:要使用Java Highcharts实现统计图生成,需要先进行以下步骤: 1. 安装 Java Highcharts 首先,需要从Java Highcharts官网(https://www.highcharts.com/products/highcharts/)下载Java Highcharts的库文件。 2. 引入 Java Highcharts 将下载的Java Highcharts库文件导入到你的Java项目中,并在需要用到的Java文件中引入。 3. 准备数据 准备用于生成图表的数据。 4. 创建图表 使用Java Highcharts提供的API创建处理数据后的图表。 以下是一个简单的Java Highcharts代码示例,用于生成柱状图: ```java import java.util.ArrayList; import java.util.List; import com.highcharts.export.bean.ExportType; import com.highcharts.export.bean.ExportValue; import com.highcharts.export.util.ChartUtils; public class GenerateChart { public static void main(String[] args) { // 数据 List<ExportValue> dataList = new ArrayList<ExportValue>(); dataList.add(new ExportValue("A", 10)); dataList.add(new ExportValue("B", 20)); dataList.add(new ExportValue("C", 30)); dataList.add(new ExportValue("D", 40)); dataList.add(new ExportValue("E", 50)); // 设置图表类型和标题 ChartUtils chart = new ChartUtils(); chart.setChartType(ExportType.COLUMN.toString().toLowerCase()); chart.setTitle("柱状图"); // 设置图表数据 chart.setData(dataList); // 保存图表 try { chart.exportChart("D:\\chart.png"); } catch (Exception e) { e.printStackTrace(); } } } ``` 以上是一种使用Java Highcharts实现统计图生成的方式,当然还有其他的一些方式,可以根据个人需要选择使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值