Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

SQL Chart equips you with another medium of reporting by using charts. You are given the flexibility of defining your own SQL query to determine the charts that you would like to generate, ranging from a number of graph types.

Info
titleLearning More

Download the tutorial app on SQL Charts from Joget Workflow Marketplace to learn more.

Image Modified

Figure 1: SQL Chart Properties

NameDescription
Custom ID 

Item link slug. Optional field.

Info
titleUnique field

Value defined here must be unique to the rest of the Userview Menus as the first matching name will be called upon.

Label Menu label. Mandatory field.
Chart Type
  • Area Chart
  • Bar Chart
  • Bubble Chart
  • Candlestick Chart
  • Donut Chart
  • Line Chart
  • Open High Low Close Chart (OHLC Chart)
  • Pie Chart
  • XY Chart
Chart TitleChart Title  to be displayed part of the generated graph.

Image Added

Figure 2: SQL Chart Properties - Chart Options

NameDescription
X-axis Label 
X-axis Label 
X-axis display as
  • Category
 
  • Number
  • Date
Y-axis Label 
Y-axis Label 
Y-axis Prefix
 
Y-axis Prefix
Show Legend?
 
If checked, legend will be shown in the generated graph.
Show Value Label in Chart?
If checked, value label will be shown in the generated graph.
Width 

Width in character.

Code Block
titleExample
100%
Height  

Height

 
 
Colors 

in character.

Code Block
titleExample
300px
Colors

Series color. Optional field.

Comma separated values (CSV) of color codes.

Example:

Code Block
titleExample
 #3333FF,#66FF00,#FF9933,#990000

Image Added

Code Block
titleExample
red,orange,yellow,green,blue,indigo

Image Added

Info
titleWhat are the default colors?

http://stackoverflow.com/questions/18332440/what-are-the-jqplot-default-series-colors

Figure 3: SQL Chart Properties - SQLSQL

NameDescription
SQL Query 
 

SQL Query to produce the dataset required for the graph type.

Info

The first column in the dataset will be assumed for X-axis/label.

Example 1:

Code Block
titleExample
SELECT c_status as 'status', COUNT(c_status) as 'count' FROM app_fd_tix_tickets WHERE c_status IS NOT NULL GROUP BY c_status

Image Added

Example 2:

Code Block
titleSQL
select c.c_claimant, sum( cast( replace(c.c_total,'$', '') as decimal(10,2)) ) as 'total', avg( cast( replace(c.c_total,'$', '') as decimal(10,2)) ) as 'avg' from app_fd_hr_expense_claim c group by c.c_claimant

Image Added

Image Added

Figure 4: SQL Chart Properties - UI

NameDescription
Custom Header Custom Header in HTML.
Custom Footer Custom Footer in HTML.

Figure 5: SQL Chart Properties - Advanced

NameDescription
Datasource
  • Default Datasource
  • Custom Datasource
If the default datasource is selected, the custom JDBC settings below will be ignored.
Userview Key Name

When defined, additional condition will be appended using the value defined here as the parameter and the userview key value as the value.

Info
titleExample

SQL: SELECT category, count(category) FROM table1

Userview Key Name: type

Userview Key Value: val

Resultant SQL:  SELECT category, count(category) FROM table1 WHERE type = 'val'

Userview Key Name

When userview key value is defined, you may define #userviewKey# in your SQL query to have it replaced with the userview key value.

Info
titleExample

SQL: SELECT category, count(category) FROM table1 WHERE type = '#userviewKey#'

Userview Key Value: val

Resultant SQL:  SELECT category, count(category) FROM table1 WHERE type = 'val'

Interactive Chart

The following code can be modified and put in "Custom Footer" for interactive Chart.

Code Block
<script>
$(document).ready(function(){
    $('#jq_plot_chart').bind('jqplotDataClick',
        function (event, seriesIndex, pointIndex, data) {   
            console.log(event);
            console.log(seriesIndex);
            console.log(pointIndex);
            console.log(data);
            
            //for chart which used legend and x-axis, 
            var xaxis = $(".jqplot-xaxis-tick:eq("+pointIndex+")");
            var series = $(".jqplot-table-legend-label:eq("+seriesIndex+")");
            
            console.log("x-axis :" + xaxis.text());
            console.log("series :" + series.text());
        }
    );
 
    //for double click event. Please note the arguments are different.
    $('#jq_plot_chart').bind('jqplotDblClick',
        function (event, coordinate, points, data) {   
            console.log(event);
            console.log(coordinate);
            console.log(points);
            console.log(data);

            if (data) {
                var xaxis = $(".jqplot-xaxis-tick:eq("+data.pointIndex+")");
                var series = $(".jqplot-table-legend-label:eq("+data.seriesIndex+")");

                console.log("values :" + data.data);
                console.log("x-axis :" + xaxis.text());
                console.log("series :" + series.text());
            }
        }
    );
});
</script>
Note

 This code does not work with OHLC and candlestick chart.