1.0.9 • Published 1 year ago

coordinate-draw-line v1.0.9

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

CoordinateDrawLine

一个基于 vue3 开发的轻量、高效的坐标绘制线条工具

在线演示和使用手册(DEMO)

GIT地址

https://gitee.com/ericfang/coordinate-draw-line

安装

使用以下命令安装 coordinate-draw-line

npm install coordinate-draw-line
# 或
yarn add coordinate-draw-line

导入组件

全局导入

main.js 中全局引入 coordinate-draw-line

import {createApp} from "vue";
import App from "./App.vue";
// v3-drag-zoom 组件
import CoordinateDrawLine from "coordinate-draw-line";

createApp(App).use(CoordinateDrawLine).mount("#app");

按需导入

在需要的组件中导入 coordinate-draw-line

<script setup lang="ts">
  import {CoordinateDrawLine} from "coordinate-draw-line";

</script>

<template>
  <div class="" style="width: 800px;height: 480px;">
    <coordinate-draw-line
        :x-end="200"
        :y-end="100"
    ></coordinate-draw-line>
  </div>
</template>

API参数

CoordinateDrawLine

Props

参数名类型默认值是否必须说明
xStartnumber0坐标系左下角x起始大小
yStartnumber0坐标系左下角y起始大小
xEndnumber坐标系右上角x结束大小
yEndnumber坐标系右上角y结束大小
xAxisSplitint10X轴分割线的数量
yAxisSplitint10Y轴分割线的数量
splitStyleLineStyle分割线样式
axisStyleLineStyle轴线样式
lineStyleLineStyle默认线条样式
lineHoverStyleLineStyle默认鼠标悬浮在线条上样式
pointStylePointStyle默认点样式
pointHoverStylePointStyle默认鼠标悬浮在点上样式
textStyleTextStyle刻度文本样式
textDistancenumber5文本与轴线的距离
paddingnumber20坐标系与容器之间的距离

Event

事件参数说明
changing(point:Point | null, lines: Line[]) => void鼠标拖动点过程中触发
changed(point:Point | null, lines: Line[]) => void鼠标拖动完成触发一次(删除线条等也会触发一次)

Exposed

方法参数说明
addLine(line:Line)=>void添加线条
removeLine(line:line)=>void移除线条
clearLines()=>void清除所有线条
draw() => void强制绘制一次canvas

Point

属性类型说明
xnumberx坐标
ynumbery坐标
lineLine所属线条
stylePointStyle样式
hoverStylePointStyle鼠标悬浮样式

PointStyle

属性类型说明
radiusnumber半径
fillStylestring填充色
strokeStylestring边框色
lineWidthnumber边框宽度

Line

属性类型说明
startPoint起点
endPoint终点
styleLineStyle样式
hoverStyleLineStyle鼠标悬浮样式
pointsPoint[]点列表
xDullDullType单调性
yDullDullType单调性
fixednumber保留小数位数
mergeDistancenumber点合并距离(小于0将不会合并)

LineStyle

属性类型说明
strokeStylestring线条颜色
lineWidthnumber线条宽度

DullType

说明
increase单调上升
decrease单调下降
undefined无约束

Text

属性类型说明
textstring文本内容
pointPoint所在位置
align"left" | "center" | "right"对齐方式
styleTextStyle文本样式

TextStyle

属性类型说明
fontstring字体(12 Arial)
fillStylestring填充颜色(#000)
1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1

1 year ago