How to render a new chart each time a new record is added to the table in Oracle Apex

49 views Asked by At

I'm developing a system using Oracle Apex. I have a table called PM_KPI, this table contains information about KPIs, each record of the table represents a new KPI. What I want to do is that, for each KPI/record that is approved, a new chart is rendered on the page. Is it possible to do that in Oracle Apex? if yes, How... here is the DDL of the PM_KPI table: CREATE TABLE "PM_KPI" ( "ID" NUMBER GENERATED BY DEFAULT AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOKEEP NOSCALE NOT NULL ENABLE, "NAME_EN" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "NAME_AR" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "EQUATION_TYPE_EN" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "EQUATION_TYPE_AR" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "DATA_SOURCE_EN" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "DATA_SOURCE_AR" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "NUMERATOR" VARCHAR2(20) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "DENOMINATOR" VARCHAR2(20) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "NUMERATOR_DATA_SOURCE_EN" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "NUMERATOR_DATA_SOURCE_AR" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "DENOMINATOR_DATA_SOURCE_EN" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "DENOMINATOR_DATA_SOURCE_AR" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "CLASSIFICATION_EN" VARCHAR2(50 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "CALSSIFICATION_AR" VARCHAR2(50 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "DESCRIPTION_EN" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "DESCRIPTION_AR" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "SCOPE_EN" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "SCOPE_AR" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "KPI_TYPE_EN" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "KPI_TYPE_AR" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "STRATEGIC_GOAL_EN" VARCHAR2(100 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "STRATEGIC_GOAL_AR" VARCHAR2(100 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "OPERATIONAL_GOAL_EN" VARCHAR2(100 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "OPERATIONAL_GOAL_AR" VARCHAR2(100 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "PROCESSES_AND_SERVICES_EN" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "PROCESSES_AND_SERVICES_AR" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "OWNER_ID" NUMBER NOT NULL ENABLE, "MEASURER_ID" NUMBER, "STAKEHOLDERS_EN" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "STAKEHOLDERS_AR" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "IS_PLANNED" CHAR(1 CHAR) COLLATE "USING_NLS_COMP", "MEASURING_NATURE_EN" VARCHAR2(50 CHAR) COLLATE "USING_NLS_COMP", "MEASURING_NATURE_AR" VARCHAR2(50 CHAR) COLLATE "USING_NLS_COMP", "MEASURING_UNIT_EN" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP", "MEASURING_UNIT_AR" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP", "BASE_YEAR" VARCHAR2(20) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "POLARITY_EN" VARCHAR2(50 CHAR) COLLATE "USING_NLS_COMP", "POLARITY_AR" VARCHAR2(50 CHAR) COLLATE "USING_NLS_COMP", "STEREOTYPE_EN" VARCHAR2(50 CHAR) COLLATE "USING_NLS_COMP", "STEREOTYPE_AR" VARCHAR2(50 CHAR) COLLATE "USING_NLS_COMP", "LOCAL_ENTITIES_BENCHMARK_EN" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "LOCAL_ENTITIES_BENCHMARK_AR" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "LOCAL_ENTITIES_JUSTIFICATION_EN" VARCHAR2(400 CHAR) COLLATE "USING_NLS_COMP", "LOCAL_ENTITIES_JUSTIFICATION_AR" VARCHAR2(400 CHAR) COLLATE "USING_NLS_COMP", "LOCAL_BENCHMARK_YEAR" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP", "LOCAL_RANKING" NUMBER, "REGIONAL_ENTITIES_BENCHMARK_EN" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "REGIONAL_ENTITIES_BENCHMARK_AR" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "REGIONAL_ENTITIES_JUSTIFICATION_EN" VARCHAR2(400 CHAR) COLLATE "USING_NLS_COMP", "REGIONAL_ENTITIES_JUSTIFICATION_AR" VARCHAR2(400 CHAR) COLLATE "USING_NLS_COMP", "REGIONAL_BENCHMARK_YEAR" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP", "REGIONAL_RANKING" NUMBER, "GLOBAL_ENTITIES_BENCHMARK_EN" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "GLOBAL_ENTITIES_BENCHMARK_AR" VARCHAR2(200 CHAR) COLLATE "USING_NLS_COMP", "GLOBAL_ENTITIES_JUSTIFICATION_EN" VARCHAR2(400 CHAR) COLLATE "USING_NLS_COMP", "GLOBAL_ENTITIES_JUSTIFICATION_AR" VARCHAR2(400 CHAR) COLLATE "USING_NLS_COMP", "GLOBAL_BENCHMARK_YEAR" VARCHAR2(20 CHAR) COLLATE "USING_NLS_COMP", "GLOBAL_RANKING" NUMBER, "IMPROVEMENT_PROCEDURES_EN" VARCHAR2(400 CHAR) COLLATE "USING_NLS_COMP", "IMPROVEMENT_PROCEDURES_AR" VARCHAR2(400 CHAR) COLLATE "USING_NLS_COMP", "RESPONSIBLE_TEAM_ID" NUMBER NOT NULL ENABLE, "INITIATOR_ID" NUMBER, "STATUS" VARCHAR2(100 CHAR) COLLATE "USING_NLS_COMP", "APPROVER_ID" NUMBER, "DECISION_DATE" DATE, "INITIATION_DATE" DATE, CONSTRAINT "PM_KPI_PK" PRIMARY KEY ("ID") USING INDEX ENABLE ) DEFAULT COLLATION "USING_NLS_COMP" ; ALTER TABLE "PM_KPI" ADD CONSTRAINT "PM_KPI_OWNER_ID_FK" FOREIGN KEY ("OWNER_ID") REFERENCES "PM_UNITS" ("ID") ON DELETE CASCADE ENABLE NOVALIDATE; ALTER TABLE "PM_KPI" ADD CONSTRAINT "PM_KPI_MEASURER_ID_FK" FOREIGN KEY ("MEASURER_ID") REFERENCES "PM_UNITS" ("ID") ON DELETE SET NULL ENABLE NOVALIDATE; ALTER TABLE "PM_KPI" ADD CONSTRAINT "PM_KPI_TEAM_ID_FK" FOREIGN KEY ("RESPONSIBLE_TEAM_ID") REFERENCES "PM_TEAM" ("ID") ON DELETE SET NULL ENABLE; ALTER TABLE "PM_KPI" ADD CONSTRAINT "PM_KPI_INITIATOR_ID_FK" FOREIGN KEY ("INITIATOR_ID") REFERENCES "PM_EMPLOYEES" ("ID") ON DELETE SET NULL ENABLE NOVALIDATE; ALTER TABLE "PM_KPI" ADD CONSTRAINT "PM_KPI_APPROVER_ID_FK" FOREIGN KEY ("APPROVER_ID") REFERENCES "PM_EMPLOYEES" ("ID") ON DELETE SET NULL ENABLE NOVALIDATE;

I've tried to have a card region with the following html code in the media section:

but it looks so basic and unprofessional. Is there any other way to do what I'm looking for?

1

There are 1 answers

0
Koen Lostrie On

A chart is a region. Out of the box you cannot create regions on the fly. One possible workaround is to create a number of predefined regions and decide to render them if the KPI exists.

Suppose your KPI table has 3 rows and you expect that to grow to 10 in the future. They you could create a region for each of the 10 apis with a number of parameters (region title, display order etc, display y/n etc). In a pre-rendering process, define what regions need to be rendered based on the data in your kpi table.

Note that you are always limited by the number of regions you pre-define on the table.

A better solution would be to write a custom region plugin that renders the number of charts needed. This is pretty high level apex stuff - plugins have a steep learning curve and it's harder to get help.