question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Localized measurement units for time scale?

See original GitHub issue

Hi,

is it possible to have localized moment.js patterns for the time units for the time scale (Chart.js V2.0)? Currently, the configuration of time unit patterns (for hour, day, week etc.) are stored in a local variable in the ‘TimeScale’ object, line 25ff. in file ‘scale.time.js’. Unfortunately, they are not really suitable for countries that don’t use the anglo-american style of a time expression. E.g. in Germany we don’t use ‘am’ and ‘pm’ because we’re using the 24h clock here.

It would be cool if it’s possible to overwrite the patterns using the options for the time scale, e.g.

options: {
...
                scales: {
                    xAxes: [{
                        type: 'time',
                        time: {
                          measurements: {
                            day: '< custom moment.js pattern >'
                          }
                        }
                    }]
                }
            }
...
}

Kind regards

Werner

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
etimbergcommented, Nov 30, 2015

@wwillms try setting

options: {
    scales: {
        xAxes: [{
            type: 'time',
            time: {
                displayFormat: '<custom moment pattern>'
            }
        }]
    }
}

It’s no ideal (since you need to know the unit) but its a start.

0reactions
wwillmscommented, Dec 1, 2015

@etimberg Wow, that was really fast, awesome! I’ve just integrated that into our project and it works perfectly. Using that configuration:

displayFormats: {
    second: 'HH:mm:ss',
    minute: 'HH:mm',
    hour: 'MMM D, H[h]'
}

Thanks a lot, mate!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Localize Units of Measurement per User - AIMMS How-To
An AIMMS application can easily localize its interaction with numeric data. This is achieved by selecting the units and conversion factors ...
Read more >
Tips for the localization of measurement units in DITA
Best practices for unit conversion​​ Converting measurement units requires more than the translation by a linguist. A Subject Matter Expert should at least ......
Read more >
Best Practices for Localizing Measurements and Numeric ...
Localize in bulk – but be careful!​​ Localizing your numeric content all at once can be an excellent way to ensure consistency and...
Read more >
Measurement and Unit — Displaying Human-Friendly Content
A formatter provides localized representations of units and measurements. MeasurementFormatter has an instance method string that takes the ...
Read more >
Time and Frequency from A to Z, Ti | NIST
Seconds are then counted to measure longer units of time interval, such as minutes, hours, and days. Modern time scales such as UTC...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found