【vue】简洁优雅的火花线、趋势线

来由

在github发现个好看易用的vue趋势线组件,特此记录。

效果

趋势图生成后效果如上,线条为渐变色,可设置是否平滑。具体线条走势,根据数据动态生成。

使用

安装

javascript 复制代码
npm i vuetrend -S

引入

javascript 复制代码
import Vue from "vue"
import Trend from "vuetrend"

Vue.use(Trend)

使用

javascript 复制代码
<trend
  :data="[0, 2, 5, 9, 5, 10, 3, 5, 0, 0, 1, 8, 2, 9, 0]"
  :gradient="['#6fa8dc', '#42b983', '#2c3e50']"
  auto-draw
  smooth
>
</trend>

其他可配置项

Name Type Default Description Example
data Number|Object undefined The data accepted by Vue Trend is incredibly simple: An array of y-axis values to graph. [120, 149, 193.4, 200, 92] or [{ value: 4 }, { value: 6 }, { value: 8 }]
gradient String ['#000'] Colour can be specified as any SVG-supported format (named, rgb, hex, etc). ['#0FF', '#F0F', '#FF0']
gradientDirection String top Top, Bottom, Left or Right.
width Number auto Set an explicit width for your SVG. -
height Number auto Set an explicit height for your SVG. -
padding Number 8 If you set a very large strokeWidth on your line, you may notice that it gets "cropped" towards the edges. -
smooth Boolean false Smooth allows the peaks to be 'rounded' out so that the line has no jagged edges. -
radius Number 10 When using smoothing , you may wish to control the amount of curve around each point. This prop has no effect if smooth isn't set to true. -
autoDraw Boolean false Allow the line to draw itself on mount. Set to true to enable, and customize using autoDrawDuration and autoDrawEasing. -
autoDrawDuration Number 2000 The amount of time, in milliseconds, that the autoDraw animation should span. This prop has no effect if autoDraw isn't set to true. -
autoDrawEasing String ease The easing function to use for the autoDraw animation. Accepts any transition timing function within the CSS spec (eg. linear, ease, ease-in, cubic-bezier...). -
max Number -Infinity Specify max value -
min Number Infinity Specify min value, This is useful if you have multiple lines. See #8 -

组件来自于:GitHub - QingWei-Li/vue-trend: 🌈 Simple, elegant spark lines for Vue.js

相关推荐
前端程序媛-Tian12 分钟前
前端 AI 提效实战:从 0 到 1 打造团队专属 AI 代码评审工具
前端·人工智能·ai
支付宝体验科技14 分钟前
Ant Design Pro v6.0.0 发布
前端
T畅N39 分钟前
审批流设计器(前端)
前端·elementui·vue·html·流程图·js
AlunYegeer1 小时前
JAVA,以后端的视角理解前端。在全栈的路上迈出第一步。
java·开发语言·前端
IT_陈寒1 小时前
Redis这个内存杀手,差点让我们运维半夜追杀我
前端·人工智能·后端
子兮曰1 小时前
DeepSeek TUI:原生 Rust 打造的终端 AI 编码 Agent
前端·javascript·后端
暗不需求2 小时前
# 深入 React Todos:从零实现一个状态提升与本地持久化的待办应用
javascript·react.js·全栈
DFT计算杂谈2 小时前
自动化脚本一键绘制三元化合物相图
java·运维·服务器·开发语言·前端·python·自动化
子兮曰2 小时前
深入 Superpowers:180k Stars 的开源 AI 编程方法论是如何工作的
前端·javascript·后端
沸点小助手2 小时前
「新晋AI顶流PK:GPT-5.5 vs DeepSeek V4&掘友吐槽小会」沸点获奖名单公示|本周互动话题上新🎊
前端·人工智能