Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add date and numbers extension formatting seetings for rendered and exported vega charts #60

Open
stenzengel opened this issue Jan 26, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@stenzengel
Copy link

Is it possible to set timeFormatLocale and formatLocale to non-default values for the preview and when exporting images?

This is supported by Vega and Vega-Lite:

E.g I would like to see a preview and export an SVG image in the German locale:

  1. formatLocale
{
  "decimal": ",",
  "thousands": ".",
  "grouping": [3],
  "currency": ["", "\u00a0"]
}
  1. timeFormatLocale
{
  "dateTime": "%A, der %e. %B %Y, %X",
  "date": "%d.%m.%Y",
  "time": "%H:%M:%S",
  "periods": ["AM", "PM"],
  "days": ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"],
  "shortDays": ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
  "months": ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
  "shortMonths": ["Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"]
}

My personal favorite solution would be to be able to define this in the VS Code Settings (User, Folder or Workspace) and not have to do this every time I open a preview.

Any help greatly appreciated.

@RandomFractals RandomFractals added the enhancement New feature or request label Jan 26, 2020
@RandomFractals RandomFractals changed the title Setting timeFormatLocale and formatLocale add date and numbers extension formatting seetings for rendered and exported vega charts Jan 27, 2020
@RandomFractals
Copy link
Owner

RandomFractals commented Jan 27, 2020

@stenzengel so, I like the idea, however that's a lot of settings to add and config.

What if we just add date/time and numbers locale settings and then let vega-embed handle the rest via JS, etc.

So, I propose we specify Date/Time default locale setting i.e. en-US, etc. Similar for numbers.

Then sort it out on the Vega spec and rendering side.

Also, I do believe you have ability to do this in vega specs if your charts are locale sensitive.

What am I missing so far?

@stenzengel
Copy link
Author

@RandomFractals Yes, to only specify the locale in the VS Code settings (User, Folder or Workspace) is my preferred solution. Personally, I do not need to specify each property of the locale settings (e.g. decimal or thousands) individually, only specifying "de-DE" would be the easiest form me. I think it should be ok, to specify only one locale which is used for both vega-lite settings (formatLocale, timeFormatLocale), but specifying both is perhaps easier to implement.

I did not find the ability to specify the locale in the vega specs (e.g. in the json file). If it is possible, can you give me a URL to the vega-lite documentation?

@RandomFractals
Copy link
Owner

ok. I'll just add locales for numbers and date formatting to this extension Settings then. You will be able to set them in User settings for all Vega renders, or Workspace settings for a poject.

I had a brief chat with @domoritz from Vega team and he preferred this simple solution to configure it too.

I'll dig into Vega api to see if there is a way to do it by locale name, rather than fine settings you outlined originally to keep it simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants