Exporting charts with CGG

Pentaho CTools

Version
10.2.x
Audience
anonymous
Part Number
MK-95PDIA006-12
In this walk-through tutorial, you will export the bar chart with the Community Graphics Generator (CGG) using the demoDashboard CDE dashboard created in the Create a dashboard using RequireJS tutorial. To use CGG, open an existing CDE dashboard for editing, and select which charts in the dashboard you want to render as CGG charts.
  1. Open the demoDashboard in CDE.
    1. Log on to Pentaho User Console and navigate to the Browse Files perspective.
    2. In the Folders pane, click to expand the Public folder, and then click to highlight the demoDashboard folder.

      demoDashboard example in the Browse Files perspective
    3. In the Files pane, click on demoDashboard and then, in the File Actions pane, click Edit.
      You are now in the Opened perspective with CDE in editing mode. The Editing:demoDashboard tab is now active in CDE.
  2. In the Components perspective, press Shift G . In the Choose what charts to render as CGG popup, click to select the chartComponent check box.
    This popup lists all the components available to CGG, such as the Community Charting Components (CCC) chart components. When you save the dashboard, CGG generates a JavaScript file for each chart selected in the popup and saves it in your solutions directory.
    chartComponent option in the Choose what charts to render as CGG popup
  3. Click the Url button to generate a URL link to CGG which will export the target chart image. Copy the export link by selecting the full URL text and pressing CtrlC on your keyboard. When finished, click Close.

    Url option in the Choose what charts to render as CGG popup
  4. Before we can use the export URL, we need to save the dashboard so the CGG scripts are generated and saved in the proper repository. To save the dashboard, on the CDE menu bar, click Save.
  5. View the generated CGG JavaScript files. In Pentaho User Console, navigate to your demoDashboard folder. Note the following files:
    • The demoDashboard_chartComponent.js contains the chart definitions.
    • The chartComponent.js contains the same content as the above file. This file is saved for backwards compatibility with previous server versions.

    dempDashboard_chartComponent.js selection
  6. Open a browser window and paste the export URL (from Step 3) into the browser's navigation bar. Press Enter. The chart image displays in the browser window.

    Displayed chart image
By default, CGG exports images in the Portable Network Graphics format (PNG). If you want CGG to export the image in the Scalable Vector Graphics format (SVG), then change the outputType in the URL query string to svg as shown below.
http://localhost:8080/pentaho/plugin/cgg/api/services/draw?script=/public/demoDashboard/demoDashboard_chartComponent.js&outputType=svg