Search code examples
chartscomboboxpentahoonchange

pentaho first steps: link combobox to chart


I'm completely new to SO, Pentaho, and have a (very) limited knowledge on js and jquery.

I need a simple requirement: whenever my combobox changes (2 values: budget or estimate), I need to reload my chart.

What I've tried so far:

In Components panel, I've added a

-Simple Parameter

--Name: param_budget_or_estimate

--Property value: budget

-Select component

--Name: BudgetEstimate_Select

--Parameter: budget_or_estimate

--Datasource: budgetestimate_query

-CCC Pie Chart

--Name: piechart_linecosts

--Listeners: added param_budget_or_estimate

--Parameters: arg param_budget_or_estimate, value param_budget_or_estimate

--Datasource: budgestimate_piechart

In Datasrouces panel, I've added a

-sql over sqlJndi query budgetestimate_query, named budgetestimate_query, that returns a

select distinct budget_or_estimate from budget_or_estimate;

-sql over sqlJndi query named budgetestimate_piechart, that returns a

SELECT  COST_LINE_NAME
        ,amount 
FROM    VI_LINE_COSTS_PIE_CHART
WHERE   budget_or_estimate=${param_budget_or_estimate}
;

Yet, I fire up my dashboard and changing the combobox changes nothing.

What am I doing wrong?

Thanks in advance!


Solution

  • First, you need to create a parameter. Let it be named parameter_one.

    Then, you set your select component to have parameter_one as Parameter property (so it propagates the onchange event's value to the parameter).

    Now, the piechart must have parameter_one as listeners, and parameter_one as parameters (arg=parameter_one, value=parameter_one). So, you declare that whenever parameter_one changes, the piechart should be reoloaded (listener) and that parameter_one's value is relevant to the calculation (parameter).

    Finally, the piechart DataSource should look like:

    select A.id,A.value
    FROM
        (
            select '1' as id, 10 as value
            union all
            select '2' as id, 20 as value
        ) A
    WHERE A.id=${parameter_one}
    ;