0
Vegaでの視覚化のロケールを設定したいと思います。私は小数点の区切り記号としてカンマ(,
)が必要であることを意味するドイツ語の数字形式が必要です。 Vegaでは設定がなければ、小数点(.
)がセパレータとして使用されます。Vegaでロケール(グローバル)を設定する方法
ここには、単純な棒グラフを示す完全な実例があります。下の画像でわかるように、y軸上の数値と小数点以下2桁の小節内の値の書式を設定します。
特定のロケール(たとえばドイツ語)を視覚化全体または個別の数値形式ごとにグローバルに設定するにはどうすればよいですか? (私は、グローバル設定を好むだろう。)
(注意:あなたは私の棒グラフの例を貼り付け、試してVega Editorを使用することができます)
{
"width": 600,
"height": 300,
"padding": {"top": 10, "left": 35, "bottom": 30, "right": 10},
"data": [
{
"name": "table",
"values": [
{"x": 1, "y": 0.5},
{"x": 2, "y": 0.8},
{"x": 3, "y": 0.3},
{"x": 4, "y": 0.6}
]
}
],
"scales": [
{
"name": "x",
"type": "ordinal",
"range": "width",
"domain": {"data": "table", "field": "x"},
"padding": 0.1
},
{
"name": "y",
"type": "linear",
"range": "height",
"domain": {"data": "table", "field": "y"}
}
],
"axes": [
{"type": "x", "scale": "x"},
{"type": "y", "scale": "y", "format": ".2f"}
],
"marks": [
{
"type": "rect",
"from": {"data": "table"},
"properties": {
"enter": {
"x": {"scale": "x", "field": "x"},
"width": {"scale": "x", "band": true, "offset": -1},
"y": {"scale": "y", "field": "y"},
"y2": {"scale": "y", "value": 0}
},
"update": {
"fill": {"value": "steelblue"}
}
}
},
{
"type": "text",
"from": {"mark": "bars"},
"properties": {
"enter": {
"y": {"field": "y", "offset": 10},
"x": {"field": "x"},
"dx": {"field": "width", "mult": 0.6},
"fill": {"value": "white"},
"align": {"value": "right"},
"baseline": {"value": "middle"},
"text": {"template": "{{datum.datum.y | number:'.2f'}}"}
}
}
}
]
}