myDBR allows you to generate different kinds of charts based on your data. For complete documentation on charts see the Charts section. In this example we'll generate a sample pie-chart.
As with the previous examples, we'll generate a stored report to generate the report and the data needed for the chart. In case of a pie-chart, we need a caregory and value column. We'll create a sample Pie-chart of total sales of the film categories. The procedure to be created looks like this:
create procedure sp_DBR_FilmByCategoryChart() begin select category, total_sales from mydb.sales_by_film_category; end
After we assign the procedure to myDBR and run it, we'll get the data needed for the chart. First parameter is the chart type ('pie') and the second parameter is an optional chart name. You can also specify the chart size or use any of the options available.
To generate a chart, a dbr.chart -command is added in front of the result set.
create procedure sp_DBR_FilmByCategoryChart() begin select 'dbr.chart', 'Pie', 'Sample Pie chart'; select category, total_sales from mydb.sales_by_film_category; end
When we re-run the report, we'll get the data drawn as a chart.