]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
[v3] Add locale to ChartOptions type (#8118)
authorlab900-marcel-samyn <67897574+lab900-marcel-samyn@users.noreply.github.com>
Fri, 4 Dec 2020 06:25:43 +0000 (07:25 +0100)
committerGitHub <noreply@github.com>
Fri, 4 Dec 2020 06:25:43 +0000 (08:25 +0200)
* Add locale to ChartOptions type

* Adds locale options documentation

* fixed typo

* changes links to number format, linking the constructor

* changes to a better sentence

* changes to better sentence (2)

Co-authored-by: stock <stocki.nail@gmail.com>
docs/docs/general/locale.md [new file with mode: 0644]
docs/sidebars.js
types/core/interfaces.d.ts

diff --git a/docs/docs/general/locale.md b/docs/docs/general/locale.md
new file mode 100644 (file)
index 0000000..e1f085b
--- /dev/null
@@ -0,0 +1,25 @@
+---
+title: Locale
+---
+
+For applications where the numbers of ticks on scales must be formatted accordingly with a language sensitive number formatting, you can enable this kind of formatting by setting the `locale` option.
+
+The locale is a string that is a [Unicode BCP 47 locale identifier](https://www.unicode.org/reports/tr35/tr35.html#BCP_47_Conformance).
+
+A Unicode BCP 47 locale identifier consists of
+
+  1. a language code,
+  2. (optionally) a script code,
+  3. (optionally) a region (or country) code,
+  4. (optionally) one or more variant codes, and
+  5. (optionally) one or more extension sequences,
+
+with all present components separated by hyphens. 
+
+By default the chart is using the default locale of the platform which is running on.
+
+## Configuration Options
+
+| Name | Type | Default | Description
+| ---- | ---- | ------- | -----------
+| `locale` | `string` | `undefined` | a string with a BCP 47 language tag, leveraging on [INTL NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat).
index 3300e2114e71331ddeabc157a4fb5082438d1b96..b56c313673d9beba6f41d8d51f0ca75c5fbb764b 100644 (file)
@@ -16,6 +16,7 @@ module.exports = {
                        'general/accessibility',
                        'general/responsive',
                        'general/device-pixel-ratio',
+                       'general/locale',
                        {Interactions: ['general/interactions/index', 'general/interactions/events', 'general/interactions/modes']},
                        'general/options',
                        'general/colors',
index ab82d4e119cbb0f292467e6a8d848bbfe65720a6..ff6e1a2826de2136c105595c2571fdb463e8862a 100644 (file)
@@ -131,6 +131,12 @@ export interface CoreChartOptions extends ParsingOptions {
    * @default 2
    */
   aspectRatio: number;
+       
+  /**
+   * Locale used for number formatting (using `Intl.NumberFormat`).
+   * @default user's browser setting
+   */
+  locale: string;
 
   /**
    * Called when a resize occurs. Gets passed two arguments: the chart instance and the new size.