oracle-apexoracle-apex-19.1

How To Change Oracle Apex Chart Type Programmatically


I have a simple Chart Region: with

Static ID: Chart_Region

Attribute Type: Pie

Chart Serie: Salary Chart

Sql Query: Select Department_id, Sum(Salary) Sum_Sal From Employees Group by Department_Id;

Column Mapping: Label: Department_ID , Value: Sum_Sal and Static ID: Chart_ID

Simply I want to enable the end user to change the Chart Type: Pie to Type: Bar at the runtime (using toggle buttons that I have added). Any Idea please !.

Thank you in advance.


Solution

  • I found it with Javascript like so:

    apex.region('Chart_Region').widget.ojChart({type:'bar'});
    

    and

    apex.region('Chart_Region').widget.ojChart({type:'pie'});
    

    available values for type are:

    area, bar, boxPlot, bubble, combo, funnel, line, lineWithArea, pie, pyramid, scatter, stock