unovis-vue-skilld
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesef5/unovis @unovis/vue
@unovis/vuef5/unovis @unovis/vue
@unovis/vueModular data visualization framework for React, Angular, Svelte, Vue, and vanilla TypeScript or JavaScript
Version: 1.6.4
Tags: beta: 1.6.5-topojson.0, latest: 1.6.4
References: GitHub Issues — bugs, workarounds, edge cases • GitHub Discussions — Q&A, patterns, recipes • Releases — changelog, breaking changes, new APIs
适用于React、Angular、Svelte、Vue以及原生TypeScript或JavaScript的模块化数据可视化框架
**版本:**1.6.4
**标签:**beta: 1.6.5-topojson.0, latest: 1.6.4
参考链接:GitHub Issues — 问题、解决方案、边缘情况 • GitHub Discussions — 问答、模式、实践方案 • Releases — 更新日志、破坏性变更、新API
API Changes
API变更
This section documents version-specific API changes for — prioritize recent major/minor releases.
@unovis/vue-
NEW:and
VisPlotband— new auxiliary components for highlighting data ranges or specific values sourceVisPlotline -
NEW:— new specialized legend component added in v1.6.0 source
VisRollingPinLegend -
NEW:— new hierarchical data visualization component; includes
VisTreemapandtileShowHtmlTooltipprops as of v1.6.4 sourcetopLevelParent -
NEW:— new component for adding callouts and annotations to charts source
VisAnnotations -
NEW:— new callback available in
onRenderCompleteandVisXYContainerto detect when rendering is finished sourceVisSingleContainer -
NEW:enhancements — added
VisAreafor better visibility of small values and optional line display via core config sourcestackMinHeight -
NEW:updates — new
VisSankeycallback,onLayoutCalculatedmethod, and support for Zoom/Pan and Node selection sourcegetSankeyDepth -
NEW:features — support for custom node rendering functions, SVG link labels, and Zoom start/end callbacks source
VisGraph -
NEW:additions — new
VisCrosshairprop,forceShowAtcallback, andonCrosshairMoveconfiguration sourceskipRangeCheck -
NEW: SSR Readiness — major internal refactor to support SSR (Server-Side Rendering) for Nuxt and other frameworks source
-
NEW: Reactive Map Data —data property is now fully reactive in Vue source
VisLeafletMap -
NEW: Automatic Tooltip Placement —now automatically aligns when used in conjunction with
VisTooltipsourceVisCrosshair -
NEW:— now supports multiple colors per legend item source
VisBulletLegend -
NEW:— improved
VisXYContainerbehavior to ensure consistency across multiple chart types sourcescaleByDomain
Also changed: support in Annotations · accessible theme · refactored wrapper · CSS variables · Crosshair prop
calc()theme-patternsVisFlowLegendaxis grid line dasharrayskipRangeCheck本部分记录的版本专属API变更 — 优先查看近期的主版本/次版本更新。
@unovis/vue-
新增:和
VisPlotband— 用于高亮数据范围或特定值的新辅助组件 来源VisPlotline -
新增:— v1.6.0版本新增的专用图例组件 来源
VisRollingPinLegend -
新增:— 新的层级数据可视化组件;v1.6.4版本起新增
VisTreemap和tileShowHtmlTooltip属性 来源topLevelParent -
新增:— 用于在图表中添加标注和注释的新组件 来源
VisAnnotations -
新增:—
onRenderComplete和VisXYContainer中新增的回调函数,用于检测渲染完成时机 来源VisSingleContainer -
新增:增强功能 — 新增
VisArea属性以提升小数值的可见性,同时支持通过核心配置启用可选线条显示 来源stackMinHeight -
新增:更新 — 新增
VisSankey回调函数、onLayoutCalculated方法,以及缩放/平移和节点选择支持 来源getSankeyDepth -
新增:功能 — 支持自定义节点渲染函数、SVG链接标签,以及缩放开始/结束回调 来源
VisGraph -
新增:扩展 — 新增
VisCrosshair属性、forceShowAt回调函数,以及onCrosshairMove配置项 来源skipRangeCheck -
新增:SSR就绪 — 重大内部重构,以支持Nuxt等框架的SSR(服务端渲染) 来源
-
新增:响应式地图数据 —的data属性现在在Vue中完全支持响应式 来源
VisLeafletMap -
新增:自动工具提示定位 — 当与配合使用时,
VisCrosshair现在会自动对齐 来源VisTooltip -
新增:— 现在支持每个图例项使用多种颜色 来源
VisBulletLegend -
新增:— 改进
VisXYContainer行为,确保多种图表类型之间的一致性 来源scaleByDomain
**其他变更:**Annotations中的支持 · 可访问性主题 · 重构包装器 · CSS变量 · 的属性
calc()theme-patternsVisFlowLegendaxis grid line dasharrayVisCrosshairskipRangeCheckBest Practices
最佳实践
- Support ordinal values in XY components by returning the data index in the accessor and providing a
xto thetickFormatsourceVisAxis
vue
<script setup lang="ts">
const x = (d, i: number) => i
const tickFormat = (i: number) => data[i].category
</script>
<template>
<VisXYContainer :data="data">
<VisStackedBar :x="x" :y="d => d.value" />
<VisAxis type="x" :tick-format="tickFormat" />
</VisXYContainer>
</template>- Define custom SVG gradients or patterns using the property on
svgDefsorVisXYContainersourceVisSingleContainer
vue
<template>
<VisXYContainer :svg-defs="gradientDef">
<VisArea :x="d => d.x" :y="d => d.y" color="url(#gradient-id)" />
</VisXYContainer>
</template>- Display continuous lines across missing data points by filtering values and passing the dataset directly to
nullinstead of the container sourceVisLine
vue
<template>
<VisXYContainer>
<VisLine :data="data.filter(d => d.value !== null)" :x="x" :y="y" />
</VisXYContainer>
</template>- Attach events to axis ticks or other sub-elements using the prop and component-specific selectors source
events
vue
<script setup lang="ts">
import { VisAxisSelectors } from '@unovis/vue'
const axisEvents = {
[VisAxisSelectors.tick]: {
click: (val: number) => console.log('Clicked tick:', val)
}
}
</script>
<template>
<VisAxis type="x" :events="axisEvents" />
</template>- Wrap Unovis components in when using Nuxt or SSR to prevent errors from top-level
<ClientOnly>ordocumentreferences sourcewindow
vue
<template>
<ClientOnly>
<VisXYContainer :data="data">
<VisLine :x="x" :y="y" />
</VisXYContainer>
</ClientOnly>
</template>- Enable tooltips or interactions on TopoJSON map areas using the selector source
feature
vue
<script setup lang="ts">
import { VisTopoJSONMapSelectors } from '@unovis/vue'
const triggers = {
[VisTopoJSONMapSelectors.feature]: d => d.properties.name
}
</script>
<template>
<VisTopoJSONMap :triggers="triggers" ... />
</template>- Fix clipped top or bottom axis labels by increasing the property on the
marginsourceVisXYContainer
vue
<template>
<VisXYContainer :margin="{ top: 10, right: 10, bottom: 10, left: 10 }">
<VisStackedBar ... />
</VisXYContainer>
</template>- Use on
tickTextWidthto enable automatic label wrapping and trimming for long axis labels sourceVisAxis
vue
<template>
<VisAxis type="x" :tick-text-width="100" />
</template>- Display multiple colors within a single legend bullet by passing an array to the property of a legend item source
color
vue
<script setup lang="ts">
const items = [
{ name: 'Multi-segment', color: ['#ff0000', '#00ff00', '#0000ff'] }
]
</script>
<template>
<VisBulletLegend :items="items" />
</template>- Programmatically control crosshair visibility and position using the property for custom sync or interaction logic source
forceShowAt
vue
<template>
<VisCrosshair :force-show-at="{ x: 1707093300 }" />
</template>- 在XY组件中支持序数类型值:在访问器中返回数据索引,并为
x提供VisAxis函数 来源tickFormat
vue
<script setup lang="ts">
const x = (d, i: number) => i
const tickFormat = (i: number) => data[i].category
</script>
<template>
<VisXYContainer :data="data">
<VisStackedBar :x="x" :y="d => d.value" />
<VisAxis type="x" :tick-format="tickFormat" />
</VisXYContainer>
</template>- 在或
VisXYContainer上使用VisSingleContainer属性定义自定义SVG渐变或图案 来源svgDefs
vue
<template>
<VisXYContainer :svg-defs="gradientDef">
<VisArea :x="d => d.x" :y="d => d.y" color="url(#gradient-id)" />
</VisXYContainer>
</template>- 通过过滤值并将数据集直接传递给
null而非容器,来显示跨缺失数据点的连续线条 来源VisLine
vue
<template>
<VisXYContainer>
<VisLine :data="data.filter(d => d.value !== null)" :x="x" :y="y" />
</VisXYContainer>
</template>- 使用属性和组件特定选择器,将事件绑定到轴刻度或其他子元素 来源
events
vue
<script setup lang="ts">
import { VisAxisSelectors } from '@unovis/vue'
const axisEvents = {
[VisAxisSelectors.tick]: {
click: (val: number) => console.log('Clicked tick:', val)
}
}
</script>
<template>
<VisAxis type="x" :events="axisEvents" />
</template>- 在使用Nuxt或SSR时,将Unovis组件包裹在中,以避免顶级
<ClientOnly>或document引用导致的错误 来源window
vue
<template>
<ClientOnly>
<VisXYContainer :data="data">
<VisLine :x="x" :y="y" />
</VisXYContainer>
</ClientOnly>
</template>- 使用选择器为TopoJSON地图区域启用工具提示或交互 来源
feature
vue
<script setup lang="ts">
import { VisTopoJSONMapSelectors } from '@unovis/vue'
const triggers = {
[VisTopoJSONMapSelectors.feature]: d => d.properties.name
}
</script>
<template>
<VisTopoJSONMap :triggers="triggers" ... />
</template>- 通过增加上的
VisXYContainer属性来修复顶部或底部轴标签被截断的问题 来源margin
vue
<template>
<VisXYContainer :margin="{ top: 10, right: 10, bottom: 10, left: 10 }">
<VisStackedBar ... />
</VisXYContainer>
</template>- 在上使用
VisAxis属性,为长轴标签启用自动换行和截断 来源tickTextWidth
vue
<template>
<VisAxis type="x" :tick-text-width="100" />
</template>- 通过为图例项的属性传递数组,在单个图例标记中显示多种颜色 来源
color
vue
<script setup lang="ts">
const items = [
{ name: 'Multi-segment', color: ['#ff0000', '#00ff00', '#0000ff'] }
]
</script>
<template>
<VisBulletLegend :items="items" />
</template>- 使用属性以编程方式控制十字准线的可见性和位置,用于自定义同步或交互逻辑 来源
forceShowAt
vue
<template>
<VisCrosshair :force-show-at="{ x: 1707093300 }" />
</template>