#locale
#en-US-locale
英文 locale 测试
Loading...
import { VBI } from '@visactor/vbi'
import { DEMO_CONNECTOR_ID, VSeedRender } from '@components'
import { useEffect, useState } from 'react'
export default () => {
const [vseed, setVSeed] = useState(null)
useEffect(() => {
const run = async () => {
const builder = VBI.createChart({
connectorId: DEMO_CONNECTOR_ID,
chartType: 'bar',
dimensions: [{ field: 'province', alias: 'Province' }],
measures: [{ field: 'sales', alias: 'Sales', encoding: 'yAxis', aggregate: { func: 'sum' } }],
whereFilter: { id: 'root', op: 'and', conditions: [] },
havingFilter: { id: 'root', op: 'and', conditions: [] },
theme: 'light',
locale: 'en-US',
version: 1,
limit: 10,
})
const applyBuilder = (builder: VBIChartBuilder) => {
const nextLocale = 'en-US'
if (builder.locale.getLocale() !== nextLocale) {
builder.locale.setLocale(nextLocale)
}
}
applyBuilder(builder)
const result = await builder.buildVSeed()
setVSeed(result)
}
run()
}, [])
if (!vseed) return <div>Loading...</div>
return <VSeedRender vseed={vseed} />
}#zh-CN-locale
中文 locale 测试
Loading...
import { VBI } from '@visactor/vbi'
import { DEMO_CONNECTOR_ID, VSeedRender } from '@components'
import { useEffect, useState } from 'react'
export default () => {
const [vseed, setVSeed] = useState(null)
useEffect(() => {
const run = async () => {
const builder = VBI.createChart({
connectorId: DEMO_CONNECTOR_ID,
chartType: 'bar',
dimensions: [{ field: 'province', alias: '省份' }],
measures: [{ field: 'sales', alias: '销售额', encoding: 'yAxis', aggregate: { func: 'sum' } }],
whereFilter: { id: 'root', op: 'and', conditions: [] },
havingFilter: { id: 'root', op: 'and', conditions: [] },
theme: 'light',
locale: 'zh-CN',
version: 1,
limit: 10,
})
const applyBuilder = (builder: VBIChartBuilder) => {
const nextLocale = 'zh-CN'
if (builder.locale.getLocale() !== nextLocale) {
builder.locale.setLocale(nextLocale)
}
}
applyBuilder(builder)
const result = await builder.buildVSeed()
setVSeed(result)
}
run()
}, [])
if (!vseed) return <div>Loading...</div>
return <VSeedRender vseed={vseed} />
}