简体   繁体   中英

Hour:Minute format on an APEX chart is not possible

I use Oracle APEX (v22.1) and on a page I created a (line) chart, but I have the following problem for the visualization of the graphic:

On the y-axis it is not possible to show the values in the format 'hh:mi' and I need a help for this.

Details for the axis:

  • x-axis: A date column represented as a string: to_char(time2, 'YYYY-MM')
  • y-axis: Two date columns and the average of the difference will be calculated: AVG(time2 - time1); the date time2 is the same as the date in the x-axis.

So I have the following SQL query for the visualization of the series:

SELECT DISTINCT to_char(time2, 'YYYY-MM') AS YEAR_MONTH --x-axis, 
AVG(time2 - time1) AS AVERAGE_VALUE --y-axis
FROM users
GROUP BY to_char(time2, 'YYYY-MM')
ORDER BY to_char(time2, 'YYYY-MM')

I have another problem to solve it in another way: I am not familiar with JavaScript, if the solution is only possible in this way. Because I started new with APEX, but I have seen in different tutorials that you can use JS. So, when JS is the only solution, I would be happy to get a short description what I must do on the page. (I don't know if this point is important for this case: The values time1 and time2 are updated daily.)

  • On the attributes of the chart I enabled the 'Time Axis Type' under Settings
  • On the y-axis I change the format to "Time - Short" and I tried with different pattern like ##:## but in this case you see for every value and also on the y-axis the value '01:00' although the line chart was represented in the right way. But when I change the format to Decimal the values are shown correct as the line chart.
  • I also tried it with the EXTRACT function for the value like 'EXTRACT(HOUR FROM AVG(time2 - time1))|| ':' || EXTRACT(MINUTE FROM AVG(time2 - time1))' but in this case I get an error message

So where is my mistake or is it more difficult to solve this?

ROUND(TRUNC(avg(time2 - time1)/60) + mod(avg(time2 - time1),60)/100, 2) AS Y

will get close to what you want, you can set Y Axis minimum 0 maximum 24

then 12.23 means 12 hour and 23 minutes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM