From fa753251de950671d6f534a462e2f1f414a051e0 Mon Sep 17 00:00:00 2001 From: JM <32119686+jiaming743@users.noreply.github.com> Date: Thu, 20 Dec 2018 22:37:03 +0800 Subject: [PATCH] add getAxisPointPos fun --- src/plugins/methodsExtend.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/plugins/methodsExtend.js b/src/plugins/methodsExtend.js index a84ec21..267b688 100644 --- a/src/plugins/methodsExtend.js +++ b/src/plugins/methodsExtend.js @@ -82,6 +82,22 @@ export function getArrayMin (array) { n instanceof Array ? getArrayMin(n) : n)) } +export function getAxisPointsPos ([max, min], value, axisOriginPos, axisWH, tagPos, horizon) { + const minus = max - min + + const percent = (value - min) / minus + + const length = percent * (horizon ? axisWH[0] : axisWH[1]) + + return horizon ? [ + axisOriginPos[0] + length, + tagPos[1] + ] : [ + tagPos[0], + axisOriginPos[1] - length + ] +} + export default function (Vue) { Vue.prototype.deepClone = deepClone Vue.prototype.deleteArrayAllItems = deleteArrayAllItems @@ -94,4 +110,5 @@ export default function (Vue) { Vue.prototype.getArrayMaxMin = getArrayMaxMin Vue.prototype.getArrayMax = getArrayMax Vue.prototype.getArrayMin = getArrayMin + Vue.prototype.getAxisPointsPos = getAxisPointsPos }