【问题标题】:JasperReports Charts : Accessing Series expression 's Value in Customize() methodJasperReports 图表:在 Customize() 方法中访问 Series 表达式的值
【发布时间】:2013-07-07 17:22:28
【问题描述】:

我正在使用 JasperReports Server 5.0 专业版

对于其中一份报告,我正在使用图表定制器来定制条形的颜色。评估时间为报告

iReport 中,我将 Series 表达式定义为

 $F{form} + "(" + $V{month} + ")"  

Java 文件的自定义方法中,我想访问上述表达式的值,即

9 月 1 日、10 月 2 日、1 月 3 日、2 月 4 日

我尝试了以下代码来获取系列值,但没有成功。

  public JRCategorySeries[] categoryList = null ; 
  JRFillCategoryDataset  categoryDS  = (JRFillCategoryDataset)jasperChart.getDataset();
  categoryList = categoryDS.getSeries();

  SubCategoryAxis domainAxis = new SubCategoryAxis("");
  domainAxis.setCategoryMargin(0.05);

  for (int i = 0 ; i <categoryList.length -1 ; i++ ) {

    JRCategorySeries jrcategoryseries = categoryList[i];

    domainAxis.addSubCategory(jrcategoryseries.getSeriesExpression().getText());
  }

我需要帮助以自定义方法访问系列数据点。我会很感激你的cmets。

【问题讨论】:

    标签: java jasper-reports jfreechart


    【解决方案1】:

    您可以从传递给自定义类的 JFreeChart 参数中获取数据集。 也可以通过 JRChart 参数访问您在 jrxml 中为图表设置的属性

    请试试这个

    public void customize(JFreeChart chart, JRChart jasperChart) {
    
        // To access the dataset of the chart
         CategoryPlot plot = (CategoryPlot) chart.getPlot();
         CategoryDataset catData = plot.getDataset();
    
    
      // to access the key property of chart <br/>
         String key = jasperChart.getKey();
    }
    

    问候 钱德拉

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-25
      • 2011-02-06
      • 2013-06-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多