Skip to content

[Feature] Pass a Function to time.tooltipFormat option #4904

Description

@fleebzz

Hi, I'm facing a problem with time.tooltipFormat and french language. I want MM YYYY format but with capitalized month name.

Currently it gives : oct. 2017 but I'd like Oct. 2017.

I know this is not a problem from ChartJS but the moment team is stuck on this problem since 4 years.

When I'm in plain JS I can do :

_.capitalize(moment().format(`MMM`))

but in ChartJS I only have a moment's format string possibility.

Do you think it'd be crazy to pass a Function to the tooltipFormat option ?

Example of code I could do with this feature :

...
xAxes: [{
  type : `time`,
  time : {
    unit   : `month`,
    parser : `YYYYMM`,
    tooltipFormat (label, value) {
      return _.capitalize(moment(value, `YYYYMM`).format(`MMM`));
    },
  },
}]
...

PS : Example code could be improved and I'm ok to work on a PR if you agree on the main principle.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions