Hi Team,
Please let me know how to add a color to time format as below.
Below one is not matching with the requirement.
<colorPalette type="expression">if(strptime(value,"%H:%M:%S")>"25200", "#A2CC3E", "#F58F39")</colorPalette>
Time | expecting this color in Time field |
25-05-2024 19:06 | Red |
25-05-2024 22:10 | Red |
25-05-2024 22:16 | Red |
26-05-2024 06:50 | Green |
26-05-2024 06:52 | Green |
26-05-2024 11:50 | Green |
26-05-2024 11:52 | Green |
27-05-2024 07:09 | Red |
27-05-2024 07:10 | Red |
27-05-2024 11:52 | Green |
27-05-2024 11:57 | Green |
Thanks in Advance!
If your Time field is actually an _time field then it will be in epoch format (number of seconds since 1970), if that is the case, then you could try formatting (rather than parsing) - something like this for later than 12:30 pm
<colorPalette type="expression">if(tonumber(strftime(value,"%H%M%S"))>123000, "#A2CC3E", "#F58F39")</colorPalette>
Yes, i agree with you.
But i was looking for time frame colors After 7 AM, 12 PM, 7 PM, 9:35 PM - Red and Before 7 AM, 12 PM, 7 PM, 9:35 PM - Green
Time | expecting this color in Time field | |
25-05-2024 19:06 | Red | After 7PM |
25-05-2024 22:10 | Red | After 10 PM |
25-05-2024 22:16 | Red | After 10 PM |
26-05-2024 06:50 | Green | Before 7AM |
26-05-2024 06:52 | Green | Before 7AM |
26-05-2024 11:50 | Green | Before 12 PM |
26-05-2024 11:52 | Green | Before 12 PM |
27-05-2024 07:09 | Red | After 7AM |
27-05-2024 07:10 | Red | After 7AM |
27-05-2024 11:52 | Green | Before 12 PM |
27-05-2024 11:57 | Green | Before 12 PM |
I am not sure what your question is now or is this solved?
What colour is 10am? It is after 7am but it is also before 12pm!
I have a cycle so data will come in between 6-7 AM, 11-12 PM, 6-7 PM, 9-9:35 PM.
So i want to display the color for the time After 7 AM, 12 PM, 7 PM, 9:35 PM - Red and Before 7 AM, 12 PM, 7 PM, 9:35 PM - Green.
Would it be better to say anything outside the time ranges 6-7 AM, 11-12 PM, 6-7 PM, 9-9:35 PM is red and anything inside the ranges is green?
Exactly!
Try something like this
<colorPalette type="expression">if(tonumber(strftime(value,"%H")) == 6 OR tonumber(strftime(value,"%H")) == 11 OR tonumber(strftime(value,"%H")) == 18 OR (tonumber(strftime(value,"%H")) == 21 AND tonumber(strftime(value,"%M")) < 35), "#A2CC3E", "#F58F39")</colorPalette>
Its working giving proper results only red color is coming on every time
It looks like it might not work with _time fields - try assign a new field to the formatted value e.g.
| eval Time=strftime(_time,"%F %T")
Then change to formatting to take this new field into account
<colorPalette type="expression">if(tonumber(strftime(strptime(value,"%F %T"),"%H")) == 6 OR tonumber(strftime(strptime(value,"%F %T"),"%H")) == 11 OR tonumber(strftime(strptime(value,"%F %T"),"%H")) == 18 OR (tonumber(strftime(strptime(value,"%F %T"),"%H")) == 21 AND tonumber(strftime(strptime(value,"%F %T"),"%M")) < 35), "#A2CC3E", "#F58F39")</colorPalette>
Awesome, Its working!
Thank you very much!