简体   繁体   English

如何在BIRT报告中绘制图形或自定义设计图表?

[英]How to draw graphics or custom designed charts in BIRT reports?

I am trying to generate a report based on some data from a XML file. 我试图根据XML文件中的一些数据生成报告。 Basically, the first page of the report contains some static text, a logo, some dynamic text and data and two charts. 基本上,报告的第一页包含一些静态文本,一个徽标,一些动态文本和数据以及两个图表。 and the next pages should contain some text and a chart next to it. 并且下一页应包含一些文本和旁边的图表。 I have a very big issue here. 我这里有一个很大的问题。 The charts that BIRT provides are not suitable for my report so I thought maybe I can produce some charts(with an external app) based on the data from my xml file, saving the charts into files and eventually, dynamically load those files into my report. BIRT提供的图表不适合我的报告,所以我想也许我可以根据我的xml文件中的数据生成一些图表(使用外部应用程序),将图表保存到文件中,最后将这些文件动态加载到我的报告中。 This is very easy for the charts on the first page. 这对于第一页上的图表非常容易。 However, the next pages need to have their own charts and I couldn't find a proper way to include the corresponsing images into the next pages. 但是,接下来的页面需要有自己的图表,我找不到合适的方法将相应的图像包含在下一页中。 So here are my questions: 所以这是我的问题:

  1. Is this possible to somehow creat custom desinged charts? 这有可能以某种方式创建自定义设计图表吗? if yes how to do this? 如果是的话怎么做? and how can I add charts to the 2,3,...pages of my report? 如何将图表添加到报告的2,3,...页面?
  2. I have all the data needed in my xml file, is this possible to draw graphics on the fly with some javascript while the report is being created? 我有我的xml文件中所需的所有数据,这是否可以在创建报告时使用一些javascript动态绘制图形? I mean by using the data I just draw my own custom designed chart?(this is a very simple chart and no fancy stuff) 我的意思是通过使用数据我只是绘制我自己的自定义设计图表?(这是一个非常简单的图表,没有花哨的东西)
  3. If I go for the solution of creating my charts externally and add them to the report dynamically, how can I add these images dynamically to the 2,3,..pages of my report.(each page has its own chart!) would using multiple master pages help me? 如果我在外部创建我的图表的解决方案并动态地将它们添加到报表中,我如何动态地将这些图像添加到我的报表的2,3,...页面。(每个页面都有自己的图表!)将使用多个母版页对我有帮助吗?

You can create custom designed charts using D3.js or Flash and add page breaks where you need them in the BIRT Designer 4.x. 您可以使用D3.js或Flash创建自定义设计的图表,并在BIRT Designer 4.x中的所需位置添加分页符。 There are online tutorials for using Flash within a BIRT report. 有一个在BIRT报告中使用Flash的在线教程。

If you create your own charts outside of BIRT, then you could import them as images using the image gadget and a URI to your images. 如果您在BIRT之外创建自己的图表,则可以使用图像小工具和图像的URI将它们作为图像导入。

If you want to use D3.js, 如果你想使用D3.js,

  • Add head.js(" http://d3js.org/d3.v3.js "); 添加head.js(“ http://d3js.org/d3.v3.js ”); to the ClientScript > clientInitialize script of the report design 到报表设计的ClientScript> clientInitialize脚本
  • Add script to your dataset that creates: 将脚本添加到您创建的数据集中:
    • an array such as myArray = new java.util.ArrayList(); 一个数组,如myArray = new java.util.ArrayList(); at beforeOpen 在之前打开
    • a script to fill that array using the onFetch event of the dataset, for example myArray.add("['"+row["date"]+"','"+row["sales"]+"']"); 使用数据集的onFetch事件填充该数组的脚本,例如myArray.add(“['”+ row [“date”] +“','”+ row [“sales”] +“']”) ;
    • a script to copy the array to a global variable such as reportContext.setPersistentGlobalVariable("myArray",myArray); 将数组复制到全局变量的脚本,例如reportContext.setPersistentGlobalVariable(“myArray”,myArray);
  • Add a text item to the report layout where you: 将文本项添加到报表布局中:
    • Grab the global variable, for example: var data = reportContext.getPersistentGlobalVariable("myArray"); 抓取全局变量,例如:var data = reportContext.getPersistentGlobalVariable(“myArray”);
    • use d3.js JavaScript to build the SVG visualization that you want, using the data from the global variable. 使用d3.js JavaScript使用全局变量中的数据构建所需的SVG可视化。

If you move to the commercial BIRT Designer Professional, there are included Flash objects and you also get the highcharts library of HTML5 charts that you can edit with JavaScript using the highcharts.org API. 如果您转移到商业BIRT Designer Professional,则包含Flash对象,您还可以获得HTML5图表的高级图表库,您可以使用highcharts.org API使用JavaScript编辑这些图表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM