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.

include `formatLocale` and `timeFormatLocale` parameters in options

See original GitHub issue

Reasoning: I would like to set the formatLocale and formatTimeLocale as part of the embed_options in Altair.

At the vega repo, @jheer did comment once that you will need to invoke the formatLocale and formatTimeLocale methods prior instantiation of a Vega View (https://github.com/vega/vega/pull/313#issuecomment-297562302).

Using this approach I can set it in VegaEmbed: https://observablehq.com/@mattijn/usage-of-timeformatlocale-formatlocale-in-vega-embed, but this is prior the invokation of the View constructor.

Basically its just:

embed = require("vega-embed@4")
formatlocale = await (await fetch("https://unpkg.com/d3-format@1/locale/nl-NL.json")).json()
timeformatlocale = await (await fetch("https://unpkg.com/d3-time-format@1/locale/nl-NL.json")).json()
embed.vega.timeFormatLocale(timeformatlocale)
embed.vega.formatLocale(formatlocale)

viewof view = embed({
  "$schema": "https://vega.github.io/schema/vega-lite/v3.json",
  "description": "Google's stock price over time.",
  "width": 700,
  "data": {"url": "https://raw.githubusercontent.com/vega/vega-datasets/master/data/stocks.csv"},
  "transform": [{"filter": "datum.symbol==='GOOG'"}],
  "mark": {
    "type": "area",
    "color": "lightblue",
    "interpolate": "step-after",
    "line": true
  },
  "encoding": {
    "x": {"field": "date", "type": "temporal"},
    "y": {"field": "price", "type": "quantitative"},
    "tooltip": [
      {"type": "quantitative", "field": "price", "format": "$,"},
      {"type": "temporal", "field": "date"}
    ],
  },
  "selection": {
    "zoom_x": {"type": "interval", "bind": "scales", "encodings": ["x"]}
  },
})

Would it be possible to provide these locale settings as options in the Vega-Embed View?

Other sources of similar requests for Altair:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
domoritzcommented, Nov 17, 2019

Fixed and released in 6.1.0.

0reactions
victornoelcommented, Nov 16, 2019

@domoritz maybe just delegate the responsibility of handling this to vega itself by considering the following reasoning:

  • vega exposes methods to change its instance locales
  • vega-embed just uses those methods, and don’t “know” that actually d3 is globally scoped

It’s a bit cheating instead of dealing with the problem, but at the same time, think that where this problem can be fixed is at the level of vega itself when it uses d3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting Altair FormatLocale isn't working - Stack Overflow
alt.renderers settings only apply to charts being displayed by a renderer, e.g. in Jupyter Notebook: it does not affect charts being saved ...
Read more >
VegaEmbedOptions class - vega_embed_flutter library
Represents the VegaEmbed Options like theme, renderer etc. ... formatLocale, TimeFormatLocale timeFormatLocale}): Embed options for VegaLiteEmbedder.
Read more >
E-FLUID: Time fields Formatting Does Not Respect the Default ...
Find the Locale Code en-us. 7. Set, for User Option Time Format, Locale Code en-us, the Override Value of M (M = 24...
Read more >
Locale API | Vega
To display number and date values, by default Vega uses formatting rules for ... files for a variety of languages, see the d3-time-format...
Read more >
Set Agent Locale based on Service Desk System Settings and ...
Can we have Agent's locale (in Agent Panel -> Profile) default to the same as the service desk System ... Date/Time Format: Locale...
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