5 Replies Latest reply on May 15, 2019 1:28 PM by Hilary Farrell-Oracle

    Apex Pie chart custom color issue

    vinaysimha

      Hi,

      We have a requirement to have standard colors for the open/closed risk items. The green/red color combination gets applied to Bar charts just fine.

      When the same thing is applied to pie charts and the value for appearance is set to &COLOR. the charts change color to black. Any guidance regarding this will be much appreciated.

       

      The sql we use is below  -

      select label,cnt,metric_def,case label

             when 'Open' then 'Tomato'

             when 'Completed' then 'LimeGreen'

             end as Color

      from (

          select 'Completed' label,

                 sum(actual_nbr) cnt,

                 mi.metric_def

            from ( select sm_subtype_lov,

                          sum(actual_nbr) actual_nbr

                     from metrics

                    where metric_type_lov = lov_pkg.gk('METRIC_TYPE','CERTS')

                      and metric_date = ( select max(metric_date) from metrics

                                           where metric_type_lov = lov_pkg.gk('METRIC_TYPE','CERTS') 

                                             and metric_subtype_lov =  cert_pkg.get_metric(1)

                                        )

                  -- VFK539/04-30-2019 -- commented out line 18,35 and replaced with 19,36 because the mover pie chart was changing values when the cert cycle values were being changed

                  --  and metric_subtype_lov = cert_pkg.get_metric(nvl(:p2100_cert,cert_pkg.get_cert_id()))

                  and metric_subtype_lov = cert_pkg.get_metric(1)

                    group by sm_subtype_lov

                ) a,

                metric_infos mi

          where mi.metric_type_lov = lov_pkg.gk('METRIC_TYPE','CERT SUMMARY')

          group by mi.metric_def

      union

          select 'Open',

                 sum(missing_nbr) cnt,

                 mi.metric_def

            from ( select sm_subtype_lov,

                          sum(missing_nbr) missing_nbr

                     from metrics

                    where metric_type_lov = lov_pkg.gk('METRIC_TYPE','CERTS')

                      and metric_date = ( select max(metric_date) from metrics

                                           where metric_type_lov = lov_pkg.gk('METRIC_TYPE','CERTS') 

                                       --      and metric_subtype_lov =  cert_pkg.get_metric(nvl(:p2100_cert,cert_pkg.get_cert_id()))

                                         and metric_subtype_lov = cert_pkg.get_metric(1)

                                        )

                      and metric_subtype_lov = cert_pkg.get_metric(1)

                    group by sm_subtype_lov

                 ) a,

                 metric_infos mi

            where mi.metric_type_lov = lov_pkg.gk('METRIC_TYPE','CERT SUMMARY')

            group by mi.metric_def          

      )      

        • 1. Re: Apex Pie chart custom color issue
          Hilary Farrell-Oracle

          Hi,

           

          As we don't have access to an actual testcase, I would suggest that you:

           

          1) Run your SQL query in SQL Workshop > SQL Commands, and verify that the resulting dataset is correctly setting a colour for each row of data returned.

          2) In Page Designer, verify that the 'Color' attribute is referencing your column alias using the required syntax i.e. &COLOR. - with & at the start and . on the end.

           

           

          3) Take a look at the example in the Sample Charts app, specifically the 'Products (Colors set via SQL Query)' example, which demonstrates the very use case that you're trying to achieve.

           

          Regards,

          Hilary

          • 2. Re: Apex Pie chart custom color issue
            Neil Clare

            There is an issue in 18.2 (not sure if it still exists in 19) that some of the charts (including Pie) don't process named colours correctly.

            Basic colours, such as black, white, red, etc. render correctly, but others, such as Tomato you use above don't.

             

            Try replacing the colour name with the rgb or hex values.

            • 3. Re: Apex Pie chart custom color issue
              Hilary Farrell-Oracle

              Hi Neil,

               

              I'm not aware of any such issue with rendering specific colours in APEX 18.x, and I'm currently unable to reproduce the issue you're mentioned with APEX 18.2 - do you have an example of specific colours that you experienced issues with?  Using our own 18.2 dev instance, I've tested the colours mentioned in the example above, Tomato and LimeGreen, and both render without issue on a Pie chart in 18.2:

               

               

               

              Regards,

              Hilary

              • 4. Re: Apex Pie chart custom color issue
                Neil Clare

                Hillary,

                 

                I've just tested a pie chart on apex.oracle.com and colours do render correctly.

                However, one thing I've tried that doesn't work is the axes on a bar chart.

                 

                I've set the axes using the following

                 

                function( options ){

                    options.yAxis.titleStyle= "color:Green";

                    options.xAxis.titleStyle= "color:LimeGreen";

                //    options.xAxis.titleStyle= "color:#32CD32";

                    return options;

                }

                 

                The Y axis does appear Green, but the X axis is not LimeGreen.

                If I swap to the # value, it does appear as expected.

                 

                See https://apex.oracle.com/pls/apex/f?p=93685:1

                (Use demo/demo to logon)

                • 5. Re: Apex Pie chart custom color issue
                  Hilary Farrell-Oracle

                  Thanks Neil,

                   

                  So in your initial response where you mentioned:

                   

                  There is an issue in 18.2 (not sure if it still exists in 19) that some of the charts (including Pie) don't process named colours correctly

                  ..were you referring to the x-axis title formatting specifically?

                   

                  The behaviour you're reporting with the text colour is actually reproducible on the JET Cookbook, https://www.oracle.com/webfolder/technetwork/jet/jetCookbook.html?component=barChart&demo=styles , if you try updating the Text Styles 'titleStyle' attribute with a value such as 'Tomato' for color.  So the behaviour you're seeing in that respect is not APEX-specific.  In relation the customer's reported issue with the colouring of the pie elements, that is something that I would expect to work - and does work for me in my tests on APEX 18.x and 19.1.  So hopefully that customer will be able to provide some follow-up information so we can establish when the colours aren't being picked up in that instance.

                   

                  Regards,

                  Hilary