Vega: Support Intl Format Methods

Created on 18 Dec 2019  路  3Comments  路  Source: vega/vega

Problem: How do i use different type of calendar as y instead of default JS calendar system (gregorian)

As example of I need instead of hard coded calendar or formatted i need the standard

:globe_with_meridians:Intl.DateTimeFormat that currently support by many browsers

Here the official vega documentation:

{
  "data": {"url": "data/seattle-weather.csv"},
  "mark": "bar",
  "encoding": {
    "x": {
      "timeUnit": "month",
      "field": "date",
      "type": "ordinal",
      "axis": {"title": "Month of the year"}
    },
    "y": {
      "aggregate": "count",
      "type": "quantitative"
    },
    "color": {
      "field": "weather",
      "type": "nominal",
      "scale": {
        "domain": ["sun", "fog", "drizzle", "rain", "snow"],
        "range": ["#e7ba52", "#c7c7c7", "#aec7e8", "#1f77b4", "#9467bd"]
      },
      "legend": {"title": "Weather type"}
    }
  }
}

I think it's good to we have a key like:

{
  "timeUnit": "month",
  "i18n": {
    "l": "en-GB",
    "ca": "persian",
    "nu": "latn"
  }
}
new Intl.DateTimeFormat('en-GB-u-nu-latn-ca-persian').format(new Date());

More info https://mhf-ir.github.io/i18nplease/

feature-request

Most helpful comment

In addition to Intl.DateTimeFormat, we should also look at Intl.NumberFormat.

All 3 comments

Thank you for raising the issue. We will need support for internationalization to Vega.

Thanks! For now, Vega provides only the support afforded by the d3-time-format library. It supports a level of internationalization through locale configuration, but is not as comprehensive. Definitely an area for future development.

In addition to Intl.DateTimeFormat, we should also look at Intl.NumberFormat.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

keizer619 picture keizer619  路  3Comments

sonlichao picture sonlichao  路  4Comments

jheer picture jheer  路  5Comments

nyurik picture nyurik  路  3Comments

mattijn picture mattijn  路  3Comments