三次贝塞尔加圆弧组成的飞线

效果图

10. BesselArcFlyline 组件 - 图1

飞线使用

引入

  1. import Vue from 'vue'
  2. import {BesselArcFlyline} from 'special-ui'
  3. Vue.use(BesselArcFlyline)

使用

  1. <template>
  2. <div class="container">
  3. <bessel-arc-flyline :width="1820" :height="900" :dataset="data" :config="config"></bessel-arc-flyline>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'App',
  9. data () {
  10. return {
  11. data: [
  12. {
  13. from: { x: 1700, y: 300},
  14. to: { x: 1500, y: 500},
  15. end: { x: 1000, y: 300},
  16. r: 100,
  17. firstControlFactor: -0.5,
  18. secondControlFactor: 0.1,
  19. speedBezierFactor: 8000,
  20. speedArcFactor: 200,
  21. startArcAngle: -Math.PI / 2,
  22. endArcAngle: Math.PI * 1.8,
  23. counterclockwise: true
  24. },
  25. {
  26. from: { x: 100, y: 300},
  27. to: { x: 600, y: 500},
  28. end: { x: 800, y: 300},
  29. r: 100,
  30. firstControlFactor: -0.5,
  31. secondControlFactor: 0.1,
  32. speedBezierFactor: 8000,
  33. speedArcFactor: 200,
  34. startArcAngle: -Math.PI / 2,
  35. endArcAngle: Math.PI * 3 / 2.6
  36. },
  37. {
  38. from: { x: 1700, y: 700},
  39. to: { x: 1500, y: 500},
  40. end: { x: 1000, y: 790},
  41. r: 100,
  42. firstControlFactor: 0.5,
  43. secondControlFactor: -0.1,
  44. speedBezierFactor: 8000,
  45. speedArcFactor: 200,
  46. startArcAngle: -Math.PI * 3 / 2,
  47. endArcAngle: Math.PI / 6,
  48. arcDirction: 'top'
  49. },
  50. {
  51. from: { x: 100, y: 700},
  52. to: { x: 600, y: 500},
  53. end: { x: 800, y: 790},
  54. r: 100,
  55. firstControlFactor: 0.5,
  56. secondControlFactor: -0.1,
  57. speedBezierFactor: 8000,
  58. speedArcFactor: 200,
  59. startArcAngle: -Math.PI * 3 / 2,
  60. endArcAngle: Math.PI * 0.9,
  61. counterclockwise: true,
  62. arcDirction: 'top'
  63. },
  64. ],
  65. config: {
  66. //marker点半径
  67. // markerRadius: 2,
  68. //marker点颜色,为空或null则默认取线条颜色
  69. // markerColor: null,
  70. // 线条类型 solid、dashed; 有lineDash并且设值则dashed
  71. lineDash: [5, 4],
  72. //线条宽度
  73. lineWidth: 1,
  74. //线条颜色
  75. colors: ['#F9815C', '#F8AB60', '#EDCC72', '#E2F194', '#94E08A', '#4ECDA5'],
  76. //移动点半径
  77. moveRadius: 2,
  78. //移动点颜色
  79. fillColor: '#fff',
  80. //移动点阴影颜色
  81. shadowColor: '#fff',
  82. //移动点阴影大小
  83. shadowBlur: 1
  84. }
  85. }
  86. }
  87. }
  88. </script>
  89. <style>
  90. .container {
  91. height: 100%;
  92. }
  93. </style>

组件参数

属性 说明 默认值
width 画布宽度 0
height 画布高度 0
dataset 飞线数组 []
config 飞线参数配置 {}

config: 数组

属性 说明 默认值
markerRadius marker点半径 3, 为0则没有圆点显示
markerColor marker颜色 null, 不设置则和线条颜色一致
lineWidth 线条宽度 1
lineDash 虚线设置 [], 为空数组则显示实线
colors 飞线颜色 []
moveRadius 移动点半径 3
fillColor 移动点颜色 ‘#fff’
shadowColor 移动点阴影颜色 ‘#fff’
shadowColor 移动点阴影颜色 ‘#fff’
shadowBlur 移动点阴影大小 5

dataset对象参数说明:

属性 说明
from 三次贝塞尔起点坐标
to 三次贝塞尔中间点坐标
end 三次贝塞尔终点点坐标
r 连接贝塞尔的弧线半径
firstControlFactor 三次贝塞尔第一个曲线系数
secondControlFactor 三次贝塞尔第二个曲线系数
speedBezierFactor 贝塞尔动画系数,越大越慢
speedArcFactor 圆弧动画系数,越大越慢
startArcAngle 开始弧度
endArcAngle 结束弧度
counterclockwise 是否逆时针画弧度
arcDirction 圆弧朝向,默认朝下