5 Replies Latest reply: Apr 26, 2013 1:14 PM by switbeck RSS

    Chart Labels In Apex

    switbeck
      So I'm trying to create a chart that groups an aggregate function by the primary key. On the label, I cannot figure out how to query a lable that shows the primary key and the name of the customer that is located in a different table. I'm learning how to develop in Apex so I'm using the sample database right now. The following query adds up the order total by customer but I want the label to not just say the primary key (customer_ID) but also the customer last name (Cust_last_name) located in the demo_customers table. Here is the query:

      select null link, CUSTOMER_ID label, SUM(ORDER_TOTAL) value1
      from "LEARNING"."DEMO_ORDERS"
      group by CUSTOMER_ID

      Also I built this query with the query builder. Can someone explain the purpose of the "Null Link" in the select clause? And how can I get the percentages to show in a pie chart?

      Edited by: 1001737 on Apr 22, 2013 2:23 PM
        • 1. Re: Chart Labels In Apex
          switbeck
          _

          Edited by: 1001737 on Apr 22, 2013 2:23 PM
          • 2. Re: Chart Labels In Apex
            jwellsnh
            Hi, welcome to the forum. Please access your Control Panel and update your handle to something a bit more personal than 1001737.

            When you said:
            I want the label to not just say the primary key (customer_ID) but also the customer last name (Cust_last_name) located in the demo_customers table
            You were half way there, you just need to join your current query to the demo_customers table to retrieve the customers last name and use that as the label on your chart.

            Try this version of the query in your chart series; I find that a pie chart is best for this purpose:
            select
               null link,
               cust_last_name label,
               round(sum(order_total/total.tot),
               2) value  -- determine percentage of all orders  
            from
               demo_orders,
               demo_customers,
               (select
                  sum(order_total)tot 
               from
                  demo_orders) total -- sum all orders  
            where
               demo_orders.customer_id = demo_customers.customer_id  
            group by
               cust_last_name
            You asked
            Can someone explain the purpose of the "Null Link" in the select clause?
            Placing NULL here states that you are choosing not to allow the action of a link when one of the chart labels is clicked. See this site for some excellent charting examples and further explanation:
            [url [http://apex.oracle.com/pls/apex/f?p=36648]Sample Charts, Maps, Gantts and Trees
            And how can I get the percentages to show in a pie chart?
            Percentages need to be calculated; to add the *%* to the label, set the Postfix within the Display Settings of Chart Attributes.

            Jeff
            • 3. Re: Chart Labels In Apex
              switbeck
              I added the postfix but the labels all say 0%, the portions of the pie graph are correct but the labels all say 0%.
              • 4. Re: Chart Labels In Apex
                jwellsnh
                Again under Display Settings, enter 2 in Decimal Places
                • 5. Re: Chart Labels In Apex
                  switbeck
                  Thank you, you've been very helpful.