title: ORACLE APEX 5.1.1: Chart based on PL/SQL Function shows values in wrong label
body: <p>I'm using ORACLE APEX 5.1.1 and want to show a chart based on "PL/SQL Function Body returning SQL Query". The function changes the SQL-Query based on the value of a Select List. So the Chart should change whenever the Select List gets changed. I have set up all the queries and Dynamic Actions needed and the functionality works just fine. But the Chart displays the values in the wrong "Label slots" (categories on the x-axis). To clarify the wrong chart display I also created a classic report based on the exact same function, which displays the value correctly.</p>
  
  <p>I replicated a mininmal example on my evaluation account on <a href="https://apex.oracle.com" rel="nofollow noreferrer">https://apex.oracle.com</a>. There everything is just the way it's supposed to be. apex.oracle.com is currently at version 5.1.3. So I'm wondering whether this is a bug in version 5.1.1 that got fixed. I can't find anything about this issue in the release notes, though. <strong>Does anyone know about this bug or can help me with my issue in 5.1.1?</strong> Unfortunately, I can't upgrade to 5.1.3 in my corporate environment for now.</p>
  
  <p>Here is the PL/SQL I use for both, the classic report and the chart:</p>
  
  <pre><code>declare
    q varchar2(32767);
  
  begin
    q :=
  '
  select
      type1, type2, sum(to_number(val)) as val
  from (
  SELECT ''a'' as type1, ''x'' as type2, ''1'' as val
    FROM DUAL
  UNION ALL
  SELECT ''a'' as type1, ''y'' as type2, ''2'' as val
    FROM DUAL
  UNION ALL
  SELECT ''a'' as type1, ''z'' as type2, ''3'' as val
    FROM DUAL
  UNION ALL
  SELECT ''b'' as type1, ''x'' as type2, ''3'' as val
    FROM DUAL
  UNION ALL
  SELECT ''b'' as type1, ''z'' as type2, ''3'' as val
    FROM DUAL
    UNION ALL
  SELECT ''c'' as type1, ''x'' as type2, ''2'' as val
    FROM DUAL
    UNION ALL
  SELECT ''c'' as type1, ''y'' as type2, ''-2'' as val
    FROM DUAL
    UNION ALL
  SELECT ''d'' as type1, ''y'' as type2, ''-3'' as val
    FROM DUAL
    UNION ALL
  SELECT ''d'' as type1, ''z'' as type2, ''1'' as val
    FROM DUAL
  UNION ALL
  SELECT ''e'' as type1, ''x'' as type2, ''1'' as val
    FROM DUAL
  UNION ALL
  SELECT ''a'' as type1, ''z'' as type2, ''3'' as val
    FROM DUAL
  )
  '
  ;
    if :TEST_VALS = 'only positive' then q := q || ' where val &gt;= 0';
    elsif :TEST_VALS = 'only negative' then q := q || ' where val &lt;= 0';  
    end if;
    q := q || ' group by type1, type2 order by type1, type2';
    return q;
  end;
  </code></pre>
  
  <p><code>:TEST_VALS</code> refers to a static Select List with the values <code>all, only positive, only negative</code>. The Dynamic actions are set up with Refresh on Change at the Select List and "Page Items to Submit" at the classic report and the chart.</p>
  
  <p>Below you see 3 screenshots showing the bug in 5.1.1 and the correct chart display in 5.1.3.</p>
  
  <p>Wrong chart with 5.1.1 and selection "all":
  <a href="https://i.stack.imgur.com/We4Ju.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/We4Ju.png" alt="enter image description here"></a></p>
  
  <p>Wrong chart with 5.1.1 and selection "only positive values":
  <a href="https://i.stack.imgur.com/8n01J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8n01J.png" alt="enter image description here"></a></p>
  
  <p>Correct chart with 5.1.3 (on web evaluation account):
  <a href="https://i.stack.imgur.com/kqXSp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kqXSp.png" alt="enter image description here"></a></p>