Create a Pie chart using the SQL macro
Scenario
As an example, let's create a Pie chart to display "Book Print Operational Costs".
Background
Our scenario uses a data source profile, BookWarehouse, to query a database table, PRINTOPERATION. The table contains current minimum, maximum, and, average operational costs associated with the printing and go-to-market costs for books.
For this scenario, we focus on charting the current average market costs for each type of print operation.
SQL > mysql> select po_book_id, printoperation, avgcost from printoperation;
+------------+-----------------------+----------+
| po_book_id | printoperation | avgcost |
+------------+-----------------------+----------+
| 2 | Developmental Editing | 18000.00 |
| 3 | Copyediting | 7000.00 |
| 4 | Cover Design | 3500.00 |
| 5 | Formatting | 2500.00 |
| 6 | Illustrations | 4000.00 |
| 7 | ISBN Registration | 250.00 |
| 8 | Marketing & PR | 5000.00 |
+------------+-----------------------+----------+
For more information about data source profiles, click the appropriate version:
Our query against the PRINTOPERATION table looks like:
SELECT printoperation as "Service"
,format(avgcost,0) AS "Cost"
FROM printoperation;Steps
The following steps demonstrate how to use Markup to insert Confluence's native Chart macro and our SQL macro on a Confluence page:
Create a Confluence pageCreate a Confluence page to add the macros needed to produce the chart.
| ||||||||||||||
Configure the Chart macroEdit the Print Operations page and do the following:
| Chart macro parameters:
| |||||||||||||
Configure the SQL Query macroThis step uses the SQL macro to retrieve the data to be displayed in the bar chart. To configure the SQL macro, do the following:
| SQL macro parameters:
Moving the SQL macro inside the Chart macro: | |||||||||||||
Save and test the pageNow, go back to the Print Operations page and click Save. You should now see a page that appears as shown on the right. | Book Print Operational Costs: | |||||||||||||