Bar chart

In the earlier section, we saw some of the power that charting can have with reports, by adding both the graphical representation of data and the interactivity for users to see the details of that data in a separate report. We also saw how to pass data through to the target report by using the expression. In this report, the hyperlink will take us to an internal bookmark, which means it will jump us to a location inside the same report containing the details for our report. We will also look at aggregating values inside the chart so that we can provide a simple query that just retrieves the necessary details and lets BIRT handle the tricky stuff for us.

  1. Create a new report called EmployeeSalesPerformanceReport.rptDesign.
  2. Use the dsClassicCars data source in the library.
  3. Create a new dataset called employeeSales, using the following query:
    select
    CLASSICMODELS.EMPLOYEES.EMPLOYEENUMBER,
    CLASSICMODELS.EMPLOYEES.LASTNAME || ', ' || CLASSICMODELS.EMPLOYEES.FIRSTNAME name,
    CLASSICMODELS.ORDERDETAILS.PRICEEACH,
    CLASSICMODELS.ORDERS.ORDERDATE,
    CLASSICMODELS.PRODUCTS.PRODUCTNAME
    from
    CLASSICMODELS.EMPLOYEES,
    CLASSICMODELS.CUSTOMERS,
    CLASSICMODELS.ORDERS,
    CLASSICMODELS.ORDERDETAILS,
    CLASSICMODELS.PRODUCTS
    where
    CLASSICMODELS.ORDERS.ORDERNUMBER = CLASSICMODELS.ORDERDETAILS.ORDERNUMBER
    and CLASSICMODELS.EMPLOYEES.EMPLOYEENUMBER = CLASSICMODELS.CUSTOMERS.SALESREPEMPLOYEENUMBER
    and CLASSICMODELS.ORDERS.CUSTOMERNUMBER = CLASSICMODELS.CUSTOMERS.CUSTOMERNUMBER
    and CLASSICMODELS.PRODUCTS.PRODUCTCODE = CLASSICMODELS.ORDERDETAILS.PRODUCTCODE
    and CLASSICMODELS.ORDERS.ORDERDATE between ? and ?
    
  4. Map the dataset parameters to report parameters startDate and endDate.
    Bar chart
  5. Drag a table element over from the palette.
    Bar chart
  6. Set Number of columns to 3 and Number of details to 1, and map the dataset element to the employeeSales dataset.
    Bar chart
  7. In the header row, insert a new row.
    Bar chart
  8. In the top most header, merge all the cells into one large cell.
    Bar chart
  9. Insert a chart element into the large cell.
    Bar chart
  10. Select Bar chart as the type.
  11. Select the stacked Bar Chart as the subtype.
  12. Set the Output Format to PNG.
    Bar chart
  13. Go to the Select Data tab.
    Bar chart
  14. For the series value, drag in the PRICEEACH column.
    Bar chart
  15. For the Category (x) Series, use the following expression:
    (row["ORDERDATE"].getYear() + 1900).toString() + '-' + (row["ORDERDATE"].getMonth() + 1).toString()
    

This may not make much sense now, but we will explain it further in the next chapter.

  1. For the Optional Y Series Grouping, drag in the NAME column.
    Bar chart
  2. In the Inherit Data From Container drop-down list, select Inherit Columns only. This will set up the chart to ignore any grouping at the table level and let the chart engine do its down grouping.
    Bar chart
  3. Next to the Category (x) Series expression editor button, there is a button to edit group and sorting. Click that button.
    Bar chart
  4. Select Ascending from the Data Sorting drop down.
  5. In the Grouping checkbox, check the Enable option.
    Bar chart
  6. Keep the other values at their defaults and click OK.
  7. Click Finish and save the report.
  8. Select the table, and create a group on EMPLOYEENUMBER.
    Bar chart
  9. Create a grouping on OrderDate.
  10. For the detail row, drag over the PRODUCTNAME into the second column and PRICEEACH into the third column.
    Bar chart
  11. From the Palette, drag over an Aggregation element into the groupFooter for the OrderDate grouping.
    Bar chart
  12. Create the aggregation on the PRICEEACH field for the salesDateGroup.
    Bar chart
  13. Add in any formatting that might spruce up the look of our report.
    Bar chart
  14. Select the OrderDate groupings header row. Select the Bookmark tab under the property editor. Use the following expression for the bookmark:
    row["EMPLOYEENUMBER"] + row["ORDERDATE"]
    
    Bar chart
  15. Double-click on the chart to enter the Chart Editor.
  16. Select the Format Chart tab.
    Bar chart
  17. In the Edit Chart window, select the Value (Y) Series section and click the Interactivity button.
    Bar chart
  18. In the Event drop-down list select Mouse Click, whereas in the Action listbox select Hyperlink.
    Bar chart
  19. Click the Add button.
  20. Enter ChartHyperlink for the Name.
    Bar chart
  21. Click the Edit base URL... button.
  22. In the hyperlink dialog box, select Internal Bookmark as the type.
    Bar chart
  23. Select the following from the drop down:
    row["EMPLOYEENUMBER"] + row["ORDERDATE"]
    
  24. Click OK to save the report. Now run it.
Bar chart

Now, when we click on any of the different colored sections of the bar chart, it will bring us to the details section within our own report.

Bar chart
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset