写给读者的话^_^:

  众所周知,基于Highcharts插件生成的svg图片组(注意这里鄙人指的组是若干图有序组合,并非一张图片,具有业务意义)导出为PDF文档是有难度滴。鄙人也曾“异想天开”用前端技术拍个快照然后转换为pdf文件导出,后来因为能力有限未能完美实现。因此,参照互联网已有的经验和做法,创造出一套较为有操作性的方案,详情见下文。

  

---------------------------------------------------说正事儿分割线----------------------------------------------------

假设需求如下:

  1. 如图所示的复杂图表报告
  2. 对其进行PDF导出(demo中所有数据为伪造,并无任何价值)
  3. 此图仅作为demo展示,不涉及商业数据,所有数据均为构造假数据

    那么问题来了,肿么导出哩,先看下导出后的效果,卖个关子,如下图:

  4. 当然,不可否认的是图像质量会打折。但是效果终究实现了。接下来我们去看看前端怎么写,然后提交到后台又如何处理返回一个文档输出流。

    1. 前端html自定义元素属性,如下:

      1. <div class="timeFenBuPic" id="timeFenBuPic">
      2. <div class="timeFenBuOne" id="timeFenBuOne" softOrHard="hard" position="center" getSvg="true" h4="VR眼镜使用饱和度">
      3. </div>
      4. </div>

      例如:其中position咱们可以定义给它三个值属性:left,center,right代表了在文档中,每一组svg图的相对位置,其余几个属性自己结合后台程序使用即可。

  5. 前端js脚本获取并且组织svg图像元素并提交给服务端(这里我们用的服务端时Java写的struts2作为控制器层的服务端接口),js写法如下:
    1. function PDFExecute(){
    2. //循环拿到各个绘图区域id
    3. $("#svgPDF").empty();
    4. $.each($("[getSvg='true']"),function(index,ele){
    5. //根据每个绘图区域的id获取svg,position,softOrHard等属性
    6. var svg = $(this).highcharts();
    7. if(typeof(svg)=='undefined'||svg==null){
    8. svg = 'noData';
    9. }else{
    10. svg = svg.getSVG();
    11. }
    12. $("#svgPDF").append("<input id='SVG"+$(this).attr("id")+"' name='svg' type='hidden' value='' />");
    13. $("#SVG"+$(this).attr("id")).val(
    14. $(this).attr("id")+
    15. "___"+$(this).attr("position")+
    16. "___"+encodeURI($(this).attr("h4")+getSvgUnit($(this).parents('li').children('ul').children('li .curr').text()))+
    17. "___"+$(this).attr("softOrHard")+
    18. "___"+svg);
    19. });
    20. $("#svgPDF").append("<input name='logoT' type='hidden' value='"+encodeURI($(".logoT").text())+"' />");
    21. //处理文本锚点异常错误
    22. // $('[text-anchor="undefined"]').attr('text-anchor','');
    23. $("#svgPDF").submit();
    24.  
    25. }
  6. 服务端处理
  7. 服务端处理采用itext作为pdf生成第三方工具包,然后返回一个输出流到前端

    1. pdf导出接口

      1. /**
      2. * PDF导出入口方法
      3. * 参数要求:
      4. * 1.一个页面的title(encode后的)
      5. * 2.所有highcharts的svg
      6. * 3.页面所有查询参数(用于表格类型的数据查询,因为表格类型前端无法传给后台)
      7. * 4.svg详述:
      8. * svg为一个数组
      9. * svg的每个数组元素为字符串,且包含多个信息,以三个连续英文半角的下划线___做split操作,得到数组,具体内容如下:
      10. * 页面每个hicharts图的绘制id___此图在水平方向的相对位置(left还是right)___encode后的每两个图组成的title标题
      11. * (例如xx投放趋势)___此图为软广还是硬广(soft还是hard)___svg字符串用来转换图片输出流
      12. * 因此 svg.split("___")结果为:
      13. * ["charts图id","left/right","xx趋势图","soft/hard","<svg.../>"]
      14. * 5.使用时修改ByteArrayOutputStream方法下参数及布局规则
      15. */
      16. public String svgPDF(){
      17. try {
      18. request.setCharacterEncoding("utf-8");
      19. response.setCharacterEncoding("utf-8");
      20. Map<String,Object> map = new HashMap<String,Object>();
      21. String logoT = request.getParameter("logoT");
      22. if(StringUtils.isNotEmpty(logoT)){
      23. logoT = URLDecoder.decode(logoT,"utf-8");
      24. }
      25.  
      26. downloadFileName= URLEncoder.encode(logoT,"utf-8")+".pdf";
      27. String[] svg = request.getParameterValues("svg");
      28. map.put("svg", svg);
      29. map.put("logoT", logoT);
      30.  
      31. //实例化文档绘制工具类
      32. ComprehensivePdfUtil cpu = new ComprehensivePdfUtil();
      33.  
      34. ByteArrayOutputStream buff = cpu.getPDFStream(request,response,map);
      35. inputStream = new ByteArrayInputStream(buff.toByteArray());
      36. buff.close();
      37. return "success";
      38. } catch (IOException e) {
      39. e.printStackTrace();
      40. return null;
      41. }
      42. }

      此接口响应来自客户端的http请求并返回输出流

    2. PDF文档绘制工具类
      1. package com.demo.utils;
      2.  
      3. import java.io.ByteArrayOutputStream;
      4. import java.io.IOException;
      5. import java.io.StringReader;
      6. import java.io.UnsupportedEncodingException;
      7. import java.net.MalformedURLException;
      8. import java.net.URLDecoder;
      9. import java.util.ArrayList;
      10. import java.util.List;
      11. import java.util.Map;
      12.  
      13. import javax.servlet.http.HttpServletRequest;
      14. import javax.servlet.http.HttpServletResponse;
      15.  
      16. import org.apache.batik.transcoder.TranscoderException;
      17. import org.apache.batik.transcoder.TranscoderInput;
      18. import org.apache.batik.transcoder.TranscoderOutput;
      19. import org.apache.batik.transcoder.image.PNGTranscoder;
      20.  
      21. import com.itextpdf.text.BadElementException;
      22. import com.itextpdf.text.BaseColor;
      23. import com.itextpdf.text.Document;
      24. import com.itextpdf.text.DocumentException;
      25. import com.itextpdf.text.Element;
      26. import com.itextpdf.text.Font;
      27. import com.itextpdf.text.Image;
      28. import com.itextpdf.text.Paragraph;
      29. import com.itextpdf.text.Phrase;
      30. import com.itextpdf.text.Rectangle;
      31. import com.itextpdf.text.pdf.BaseFont;
      32. import com.itextpdf.text.pdf.PdfPCell;
      33. import com.itextpdf.text.pdf.PdfPRow;
      34. import com.itextpdf.text.pdf.PdfPTable;
      35. import com.itextpdf.text.pdf.PdfWriter;
      36.  
      37. /**
      38. * @Description XXX分析页面PDF导出工具方法
      39. */
      40. public class ComprehensivePdfUtil {
      41. /**
      42. * 获得PDF字节输出流及pdf布局业务逻辑
      43. * @param request
      44. * @param response
      45. * @param resultMap 包含参数:svg(绘图svg参数及hicharts图布局参数) logoT(页面总标题)
      46. * @param list 页面包含植入栏目排行表格图,该list存储绘制表格所用的数据
      47. * @param tableTh 页面包含植入栏目排行表格图,该字符串作为表格表头
      48. * @param tableTd 页面包含植入栏目排行表格图,该字符串作为表格内容填充时,实体类反射值所用的方法名(必须与实体方法严格一致)
      49. * @return
      50. */
      51. public ByteArrayOutputStream getPDFStream(HttpServletRequest request,
      52. HttpServletResponse response,
      53. Map<String,Object> resultMap){
      54. try {
      55. //图片变量定义
      56. String noData = "/style/images/noData.png";//无数据左右图
      57. String noDataCenter = "/style/images/noDataCenter.png";//无数据中间图
      58. String waterMark = "/style/images/PDFSHUIYIN.png";//PDF导出文件水印图片
      59. String [] svgName = (String[]) resultMap.get("svg");//导出PDF页面所有svg图像
      60. Document document = new Document();
      61.  
      62. ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      63. PdfWriter pdfWriter = PdfWriter.getInstance(document, buffer);
      64.  
      65. //设置页面大小
      66. int pageHeight = 2000;
      67. Rectangle rect = new Rectangle(0,0,1200,pageHeight);
      68. rect.setBackgroundColor(new BaseColor(248,248,248));//页面背景色
      69. document.setPageSize(rect);//页面参数
      70.  
      71. //页边空白
      72. document.setMargins(20, 20, 30, 20);
      73. document.open();
      74.  
      75. //设置页头信息
      76. if(null!=resultMap.get("logoT")){
      77. BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
      78. Font FontChinese = new Font(bfChinese,20, Font.BOLD);
      79. Paragraph paragraph = new Paragraph((String)resultMap.get("logoT"),FontChinese);
      80. paragraph.setAlignment(Element.ALIGN_CENTER);
      81. document.add(paragraph);
      82. }
      83.  
      84. PdfPTable table = null;
      85. String path = request.getContextPath();
      86. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
      87.  
      88. //开始循环写入svg图像到pdf文档对象
      89. for(String str:svgName){
      90. //////////////////////////////////////////////////////////////////////////////////////////////////////////
      91. //positionAndSvg数组中元素说明:
      92. //positionAndSvg[0]表示svg图像所在页面的div的id
      93. //positionAndSvg[1]表示svg图像在水平方向的相对位置:
      94. // 1.left(水平方向两张图,居左且占比50%)
      95. // 2.right(水平方向两张图,居右且占比50%)
      96. // 3.center(水平方向一张图,居中且占比100%)
      97. //positionAndSvg[2]表示svg图像模块的标题如:xxx走势图
      98. //positionAndSvg[3]表示soft/hard即软广图或者硬广图,当无数据时为无数据提示效果图提供判断依据
      99. //positionAndSvg[4]表示svg图像元素,形如<svg...../>
      100. //////////////////////////////////////////////////////////////////////////////////////////////////////////
      101. String[] positionAndSvg = str.split("___");
      102.  
      103. Image image1 = null;
      104. boolean havaData = true;
      105.  
      106. if("noData".equals(positionAndSvg[4])){//无数据时
      107. image1 = Image.getInstance(basePath+noData);
      108. havaData = false;
      109. }else{//有数据
      110. image1 = Image.getInstance(highcharts(request,response,positionAndSvg[4]).toByteArray());
      111. havaData = true;
      112. }
      113.  
      114. if("left".equals(positionAndSvg[1])){
      115. String title1 = URLDecoder.decode(positionAndSvg[2],"utf-8");
      116. setTitleByCharts(document,30,title1,"",0,87,55,Element.ALIGN_LEFT,headfont);
      117. if(!"cooperateProporOne".equals(positionAndSvg[0])){
      118. setTitleByCharts(document,0,"左图","右图",248,248,248,Element.ALIGN_CENTER,blackTextFont);
      119. }else{
      120. setTitleByCharts(document,0,"","",248,248,248,Element.ALIGN_CENTER,blackTextFont);
      121. }
      122. table = new PdfPTable(2);
      123.  
      124. float[] wid ={0.50f,0.50f}; //列宽度的比例
      125. table.setWidths(wid);
      126. table = PdfPTableImage(table,image1,80f);
      127. }else if("right".equals(positionAndSvg[1])){
      128. table = PdfPTableImage(table,image1,80f);
      129. table.setSpacingBefore(10);
      130. table=setTableHeightWeight(table,360f,1000);
      131. document.add(table);
      132. table = null;
      133. }else if("center".equals(positionAndSvg[1])){//总览全局
      134. String title1 = URLDecoder.decode(positionAndSvg[2],"utf-8");
      135. setTitleByCharts(document,30,title1,"",0,87,55,Element.ALIGN_LEFT,headfont);
      136. setTitleByCharts(document,0,"","",248,248,248,Element.ALIGN_CENTER,blackTextFont);
      137. table = new PdfPTable(1);
      138. float[] wid ={1.00f}; //列宽度的比例
      139. table.setWidths(wid);
      140. if(havaData){
      141. table = PdfPTableImageTable(table,image1,1000f,600f);
      142. }else{
      143. table = PdfPTableImageTable(table,Image.getInstance(basePath+noDataCenter),1000f,600f);
      144. }
      145. table=setTableHeightWeight(table,400f,1000);
      146. document.add(table);
      147. table=null;
      148. }
      149. }
      150.  
      151. //添加水印Start---------------------------------------------------------------------------------------------
      152. PdfFileExportUtil pdfFileExportUtil = new PdfFileExportUtil();
      153. pdfWriter.setPageEvent(pdfFileExportUtil.new PictureWaterMarkPdfPageEvent(basePath+waterMark));
      154. // pdfWriter.setPageEvent(pdfFileExportUtil.new TextWaterMarkPdfPageEvent("xxx科技"));
      155. //添加水印End-----------------------------------------------------------------------------------------------
      156. document.close();
      157. return buffer;
      158. } catch (BadElementException e) {
      159. e.printStackTrace();
      160. return null;
      161. } catch (MalformedURLException e) {
      162. e.printStackTrace();
      163. return null;
      164. } catch (DocumentException e) {
      165. e.printStackTrace();
      166. return null;
      167. } catch (IOException e) {
      168. e.printStackTrace();
      169. return null;
      170. } catch (Exception e) {
      171. e.printStackTrace();
      172. return null;
      173. }
      174. }
      175.  
      176. /**
      177. * 设置图片类型Cell属性
      178. * @param table
      179. * @param image1
      180. * @param imgPercent
      181. * @return
      182. * @throws Exception
      183. */
      184. private PdfPTable PdfPTableImage(PdfPTable table,Image image1,float imgPercent){
      185. table = useTable(table,Element.ALIGN_CENTER);
      186. PdfPCell cellzr = createCellImage(image1,imgPercent);
      187. cellzr.setBorder(0);
      188. cellzr.setBackgroundColor(new BaseColor(248,248,248));
      189. table.addCell(cellzr);
      190. return table;
      191. }
      192. /**
      193. * 设置图片类型Table的Cell属性
      194. * @param table
      195. * @param image1
      196. * @param imgPercentWidth
      197. * @param imgPercentHeight
      198. * @return
      199. * @throws Exception
      200. */
      201. private PdfPTable PdfPTableImageTable(PdfPTable table,Image image1,float imgPercentWidth,float imgPercentHeight){
      202. table = useTable(table,Element.ALIGN_CENTER);
      203. PdfPCell cellzr = createCellImageTable(image1,imgPercentWidth,imgPercentHeight);
      204. cellzr.setBorder(0);
      205. cellzr.setBackgroundColor(new BaseColor(248,248,248));
      206. table.addCell(cellzr);
      207. return table;
      208. }
      209.  
      210. /**
      211. * 设置表头
      212. * @param document
      213. * @param SpacingBefore
      214. * @param title1
      215. * @param title2
      216. * @param r1
      217. * @param r2
      218. * @param r3
      219. * @param ele
      220. * @param font
      221. * @throws Exception
      222. */
      223. private void setTitleByCharts(Document document,int SpacingBefore,String title1,String title2,int r1,int r2,int r3,int ele,Font font){
      224. try {
      225. float[] titlewidthsLeft = {0.50f,0.50f};
      226. PdfPTable zrfbtitleTable = createTable(titlewidthsLeft);
      227. PdfPCell cellzr = createCellLeft(title1,font,ele);
      228. cellzr.setBorder(0);
      229. cellzr.setBackgroundColor(new BaseColor(r1,r2,r3));
      230. zrfbtitleTable.addCell(cellzr);
      231.  
      232. PdfPCell cellzr1 = createCellLeft(title2,font,ele);
      233. cellzr1.setBorder(0);
      234. cellzr1.setBackgroundColor(new BaseColor(r1,r2,r3));
      235. zrfbtitleTable.addCell(cellzr1);
      236. zrfbtitleTable.setSpacingBefore(SpacingBefore);
      237. zrfbtitleTable=setTableHeightWeight(zrfbtitleTable,30f,1000);
      238.  
      239. document.add(zrfbtitleTable);
      240. } catch (DocumentException e) {
      241. e.printStackTrace();
      242. }
      243. }
      244.  
      245. /**
      246. * 导出Pdf所用字体静态变量
      247. */
      248. private static Font headfont ;// title字体
      249. private static Font blackTextFont ;// 黑色字体
      250. private static Font colorfont;
      251. int maxWidth = 500;
      252. static{
      253. BaseFont bfChinese;
      254. try {
      255. bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
      256. headfont = new Font(bfChinese, 15, Font.BOLD);// 设置字体大小
      257. headfont.setColor(BaseColor.WHITE);
      258. blackTextFont = new Font(bfChinese, 11, Font.BOLD);// 设置字体大小
      259. blackTextFont.setColor(BaseColor.BLACK);
      260. colorfont = new Font(bfChinese, 11, Font.NORMAL);// 设置字体大小
      261. colorfont.setColor(BaseColor.RED);
      262. } catch (Exception e) {
      263. e.printStackTrace();
      264. }
      265. }
      266.  
      267. /**
      268. * 创建指定内容背景色的Table元素Cell
      269. * @param value
      270. * @param font
      271. * @param c1
      272. * @param c2
      273. * @param c3
      274. * @return
      275. */
      276. public PdfPCell createCell(String value,Font font,int c1,int c2, int c3){
      277. PdfPCell cell = new PdfPCell();
      278. cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
      279. cell.setHorizontalAlignment(Element.ALIGN_CENTER);
      280. cell.setPhrase(new Phrase(value,font));
      281. cell.setBackgroundColor(new BaseColor(c1,c2,c3));
      282. cell.setFixedHeight(33.33f);
      283. cell.setBorder(0);
      284. return cell;
      285. }
      286. /**
      287. * 创建指定位置的Table元素Cell
      288. * @param value
      289. * @param font
      290. * @param ele
      291. * @return
      292. */
      293. public PdfPCell createCellLeft(String value,Font font,int ele){
      294. PdfPCell cell = new PdfPCell();
      295. cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
      296. cell.setHorizontalAlignment(ele);
      297. cell.setPaddingLeft(10);
      298. cell.setPhrase(new Phrase(value,font));
      299. return cell;
      300. }
      301. /**
      302. * 创建内容为Image的Table元素Cell
      303. * @param image
      304. * @param imgPercent
      305. * @return
      306. */
      307. public PdfPCell createCellImage(Image image,float imgPercent){
      308. image.scalePercent(imgPercent);
      309. PdfPCell cell = new PdfPCell(image,false);
      310. cell.setUseAscender(true);
      311. cell.setUseDescender(true);
      312. cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
      313. cell.setHorizontalAlignment(Element.ALIGN_CENTER);
      314. cell.setPaddingLeft(10);
      315. return cell;
      316. }
      317. /**
      318. * 创建table元素cell
      319. * @param image
      320. * @param imgPercentWidth
      321. * @param imgPercentHeight
      322. * @return
      323. */
      324. public PdfPCell createCellImageTable(Image image,float imgPercentWidth,float imgPercentHeight){
      325. image.scaleAbsoluteWidth(imgPercentWidth);
      326. if(imgPercentHeight==410f){
      327. image.scaleAbsoluteHeight(imgPercentHeight);
      328. }
      329.  
      330. PdfPCell cell = new PdfPCell(image,false);
      331. cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
      332. cell.setHorizontalAlignment(Element.ALIGN_CENTER);
      333. return cell;
      334. }
      335.  
      336. /**
      337. * 创建Table
      338. * @param widths 列宽比例
      339. * @return
      340. */
      341. public PdfPTable createTable(float[] widths){
      342. for(int i=0;i<widths.length;i++){
      343. widths[i] = widths[i]*maxWidth;
      344. }
      345. PdfPTable table = new PdfPTable(widths);
      346. try{
      347. table.setTotalWidth(maxWidth);
      348. table.setLockedWidth(true);
      349. table.setHorizontalAlignment(Element.ALIGN_CENTER);
      350. table.getDefaultCell().setBorder(1);
      351. }catch(Exception e){
      352. e.printStackTrace();
      353. }
      354. return table;
      355. }
      356. /**
      357. * 设置table参数
      358. * @param table
      359. * @param position
      360. * @return
      361. */
      362. public PdfPTable useTable(PdfPTable table,int position){
      363. try{
      364. table.setTotalWidth(maxWidth);
      365. table.setLockedWidth(true);
      366. table.setHorizontalAlignment(position);
      367. table.getDefaultCell().setBorder(0);
      368. }catch(Exception e){
      369. e.printStackTrace();
      370. }
      371. return table;
      372. }
      373.  
      374. /**
      375. * 设置PdfTable行高
      376. * @param table
      377. * @param maxHeight
      378. * @param maxWidth
      379. * @return
      380. */
      381. public PdfPTable setTableHeightWeight(PdfPTable table,float maxHeight,float maxWidth){
      382. table.setTotalWidth(maxWidth);
      383. List<PdfPRow> list=new ArrayList<PdfPRow>();
      384. list=table.getRows();
      385. for(PdfPRow pr:list){
      386. pr.setMaxHeights(maxHeight);
      387. }
      388. return table;
      389. }
      390.  
      391. /**
      392. * 根据SVG字符串得到一个输出流
      393. * @param request
      394. * @param response
      395. * @param svg
      396. * @return
      397. * @throws Exception
      398. */
      399. public ByteArrayOutputStream highcharts(HttpServletRequest request,HttpServletResponse response,String svg){
      400. try {
      401. request.setCharacterEncoding("utf-8");// 注意编码
      402. //转码防止乱码
      403. byte[] arrayStr = svg.getBytes("utf-8");
      404. svg = new String(arrayStr, "UTF-8");
      405.  
      406. ByteArrayOutputStream stream = new ByteArrayOutputStream();
      407.  
      408. try {
      409. stream=this.transcode(stream, svg);
      410. } catch (Exception e) {
      411. e.printStackTrace();
      412. }
      413. return stream;
      414. } catch (UnsupportedEncodingException e) {
      415. e.printStackTrace();
      416. return null;
      417. }
      418. }
      419.  
      420. /**
      421. * 对svg进行转码
      422. * @param stream
      423. * @param svg
      424. * @return
      425. * @throws Exception
      426. */
      427. public synchronized ByteArrayOutputStream transcode(ByteArrayOutputStream stream, String svg){
      428. try {
      429. TranscoderInput input = new TranscoderInput(new StringReader(svg));
      430.  
      431. TranscoderOutput transOutput = new TranscoderOutput(stream);
      432.  
      433. PNGTranscoder transcoder = new PNGTranscoder();
      434.  
      435. transcoder.transcode(input, transOutput);
      436. return stream;
      437. } catch (TranscoderException e) {
      438. e.printStackTrace();
      439. return null;
      440. }
      441. }
      442.  
      443. }

      PDF文档绘制工具类

      此工具类可以根据前端传来的svg信息,前文中提到的自定义position等属性,布局完成所要输出的PDF文档,因时间有限,不再一一赘述,有想研究的可以下载demo,我已做了一个demo供各位交流学习,下载地址:http://yun.baidu.com/share/link?shareid=2976350494&uk=657798452

Highcharts图表导出为pdf的JavaWeb实践的更多相关文章

  1. 把页面上的图表导出为pdf文件,分享一种请求下载文件的方法

    最近客户提出一个需求,就是把页面上的图表导出为pdf文件. 找了很多资料.终于有了点头绪.最主要是参考了HighCharts的做法.http://www.hcharts.cn/ 实现原理:把页面图表的 ...

  2. 在asp.net中如何自己编写highcharts图表导出到自己的服务器上来

    1.准备工作:网上下载highcharts导出的关键dll.      1).Svg.dll:因为highcharts的格式其实就是一个xml,采用svg的方式画图:      2).itextsha ...

  3. 基于ITextSharp插件在ASP.NET MVC中将图表导出为PDF

    样本: 在这个示例中,我们使用的是微软给我们提供的数据库,也就是家喻户晓的Northwind数据库.要下载Microsoft的免费样本Northwind数据库,您需要访问以下URL.下载Northwi ...

  4. highCharts图表入门简介

    一.Highcharts简介 Highcharts:功能强大.开源.美观.图表丰富.兼容绝大多数浏览器的纯js图表库 Highcharts是一款纯javascript编写的图表库,能够很简单便捷的在W ...

  5. highcharts自定义导出文件格式(csv) highcharts的一些使用心得

    highcharts是国外的一个图表插件,包括各种数据图形展示,柱形图,线性图等等,是手机端和pc端最好的图表插件之一,相比于百度的echarts更加轻便和易懂.链接http://www.hchart ...

  6. highCharts图表应用-实现多种图表的显示

    在数据统计和分析业务中,有时需要在一个图表中将柱状图.饼状图.曲线图的都体现出来,即可以从柱状图中看出具体数据.又能从曲线图中看出变化趋势,还能从饼状图中看出各部分数据比重.highCharts可以轻 ...

  7. Saiku图表导出时中文显示问题的解决方法

    Saiku图表导出时png,jpg,pdf三种格式的中文显示都有问题,目前找到一种不太完善的解决方法(中文可以显示但不清晰),需要修改Saiku项目下的ExporterResource.java文件, ...

  8. HighCharts 图表高度动态调整

    HighCharts 图表高度动态调整 前言 在使用HighCharts控件过程中,发现图表可以自适应div的高度,无法根据图表x.y轴的数量动态调整div高度,否则图标挤在一起,看起来非常不美观,也 ...

  9. highCharts图表应用-模拟心电图

    通过前两章的学习,相信大家对highcharts已经有了初步的了解.这一章将通过一个例子来模拟Highcharts如何实现经常变化的数据显示. 比如说股票的涨停.实时篮球比分以及A选手和B选手的支持率 ...

随机推荐

  1. 《web全栈工程师的自我修养》阅读笔记

    在买之前以为这本书是教你怎么去做一个web全栈工程师,以及介绍需要掌握的哪些技术的书,然而看的过程中才发现,是一本方法论的书.读起来的感觉有点像红衣教主的<我的互联网方法论>,以一些自己的 ...

  2. LightOJ 1205 Palindromic Numbers

    数位DP.... Palindromic Numbers Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %l ...

  3. Hadoop Hive sql 语法详细解释

    Hive 是基于Hadoop 构建的一套数据仓库分析系统.它提供了丰富的SQL查询方式来分析存储在Hadoop 分布式文件系统中的数据,能够将结构 化的数据文件映射为一张数据库表,并提供完整的SQL查 ...

  4. bzoj 2437 [Noi2011]兔子和鸡蛋 [二分图匹配]

    叙述性说明 这些日子.兔子和蛋像一个新的棋盘游戏. 这场比赛是在 n 行 m 在船上进行列. 前,棋盘上有一 个格子是空的,其他的格子中都放置了一枚棋子,棋子或者是黑色,或者是白色. 每一局游戏总是兔 ...

  5. linux中fork()函数具体解释(原创!!实例解说)

     一.fork入门知识 一个进程,包含代码.数据和分配给进程的资源.fork()函数通过系统调用创建一个与原来进程差点儿全然同样的进程,也就是两个进程能够做全然同样的事,但假设初始參数或者传入的变量不 ...

  6. (大数据工程师学习路径)第二步 Vim编辑器----Vim文档编辑

    一.vim重复命令 1.重复执行上次命令 在普通模式下.(小数点)表示重复上一次的命令操作 拷贝测试文件到本地目录 $ cp /etc/protocols . 打开文件进行编辑 $ vim proto ...

  7. deepinmind(转)

    http://it.deepinmind.com/ 花名有孚,支付宝工程师 有希望加入支付宝的同学,可以把简历发到我的个人邮箱spidercoco@gmail.com

  8. 使用Enterprise Architecture绘制10种UML画画

    UML绘制10种课程要求UML画画,选Enterprise Architecture作为一个绘图工具,每一个草图必须是网上找教程,我觉得很麻烦,还有一些数字并没有找到详细的教程.在我自己找一个绘图方法 ...

  9. 至Android虚拟机发送短信和拨打电话

    Android的emulator是已经包括了gsm 模块,能够模拟电话与短信进行调试(就不用花太多冤枉钱) 首先,肯定是打开虚拟机: emulator -avd XXXXXX -scale 0.8&a ...

  10. Open the Lock

    Problem Description Now an emergent task for you is to open a password lock. The password is consist ...