grafana / clock-panel

Clock Panel Plugin for Grafana
MIT License
95 stars 62 forks source link

Can the 'Custom format' option support escape characters when setting content #170

Closed ibarryyan closed 7 months ago

ibarryyan commented 10 months ago

When I used Grafana's clock plugin, I found a feature that was incomplete, Steps to reproduce the problem: 1.Edit the panel and select Mode as CountUp under Clock. 2.In the 'Custom format' input box under the CountUp option, enter characters such as M and H to display them, but they will be automatically escaped,And I can't use \n for line wrapping, so I can't do it either.

I suggest making improvements: 1.The use of escape symbols such as \ n can be used for related escapes. 2.Using the +transition symbol can cancel the escape. For example, \ M can display M.

academo commented 7 months ago

Hi @ibarryyan

Internally clock panel uses momentjs to format using the custom format.

The momentjs documentation has a section that indicates you can escape characters in the format if you put them inside square brackets.

So if you'd like to escape something like Month: January you can write [Month:] MMMM where MMMM is the format code to display the full month (refer to the momentjs documentation)

I'll go ahead and add a small link in the panel options so people can refer to the momentjs documentation about this formatting options.