CTools Tips and Tricks

by Zachary Zeus
March 6, 2017

The CTools are a set of community-driven tools which are installed as a stack on top of the Pentaho BA server. They extend the Pentaho platform capabilities by providing a framework for more flexible development. This blog covers few tips and trick for developing CCC (Community Charting Components) and using the CGG (Community Graphics Generator).

Debugging

  • To debug a CDE dashboard add “debug=true&debuglevel=15” to the generateContent url i.e. http://<<server_name>>:8080/pentaho/api/repos/<<cde_dashboard_path>>.wcdf/generatedContent?debug=true&debuglevel=15
  • In browser debug (developer tools) console, pvc.<<chart type>> OPTIONS is the chart definition and should be able to be expanded to show the definition details
  • In browser debug (developer tools) console, pvc.<<chart type>> RENDER gives you details of the dataset being used, example data and is where debug steps are logged to.
  • As per above diagram, if crosstab mode is turned off, the chart expects the series to be in column 1 of the data, then category column/s, then value columns. Date is seen as a special category column. Category columns should be strings unless it’s a date.
  • There is a static Javascript class called Dashboards which is an alias for the dashboard objects real name which in some versions is “dash” and “dashboard” in others
  • Enter Dashboards.getComponentByName(‘render_<<chart_name>>’) into debug console to display the DOM object for the chart.
  • Dashboards.getComponentByName(‘render__<<chart_name>>’).chart returns the class definition for the chart and it’s internal objects.
  • Dashboards.getComponentByName(‘render__<<chart_name>>’).chartDefinition returns the chart definition DOM object.
  • You can use Dashboards.getParameterValue(‘<<parameter_name>>’) to get a parameter value in both custom javascript and debug console
  • For additional debugging messages, use console.log to log messages to pentaho.log. Enable the debug level for the category pt.webdetails.cgg in WEB-INF/classes/log4j.xml:
  • To activate the debug level in CCC, supply the following parameters in the url:

paramdebugLevel=16&paramdebug=true

  • The maximum value for debugLevel is at 16. That will even draw the bounding boxes in the chart. The debugging level needs to be adjusted to the required level.

Development workflow

  • Create chart data source (add parameters as necessary)
  • Add chart to CDE dashboard
    • Choose the chart type that best matches the requirements – the type chart defines the behaviour and the options for customisation
  • Set chart data source
  • If the chart requires parameters to be passed to it the following needs to be defined:
    • For each input parameter add a component from the Generic list (if it’s a text field use “Simple Parameter”)
    • For each input parameter define an input component which will have the parameter name and the listener name specified
    • In the chart properties select all the relevant listeners in the list of listeners
    • If the data source requires parameters to be passed to it then parameters need to be defined in the chart properties (mapping of the data source input parameters to the listeners)
  • If there is a need to modify/extend the definition of some chart properties, the functions to achieve that can be defined in the Extension points part of the Advanced properties tab.
  • Each extension point name comprises of the [component name] + “_” + [function name].
  • The functions defined in the extensions points need to return acceptable values both in format and in range
  • Since the chart will need to be converted to CGG so that it can be used in a report, if there are extension points that are referring to Dashboards component, there needs to be an additional part defined so that it works in CGG. For example:
  • To convert the dashboard chart to CGG, open the components tab and press Shift+G and tick the box in front of the chart that you would like to create the CGG for and get the URL
  • To pass parameters in the URL they need to be prefixed with paramp, for example:

http://<servername>:8080/pentaho/plugin/cgg/api/services/draw?script=<script location>&outputType=png&paramp_Param1=345636&paramp_Param2=987989&paramp_Param3=A3B5B6&paramp_Param4=C3D4D5

Background colour

  • To set the background colour on a CCC Line chart in Extension points add the following:

References

 

Portrait of Maxx Silver
Zachary Zeus

Zachary Zeus is the Co-CEO & Founder of BizCubed. He provides the business with more than 20 years' engineering experience and a solid background in providing large financial services with data capability. He maintains a passion for providing engineering solutions to real world problems, lending his considerable experience to enabling people to make better data driven decisions.

More blog posts