UNPKG

@antv/f2

Version:

Charts for mobile visualization.

59 lines 2.05 kB
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; import _createClass from "@babel/runtime/helpers/esm/createClass"; import _inherits from "@babel/runtime/helpers/esm/inherits"; import _createSuper from "@babel/runtime/helpers/esm/createSuper"; import { jsx } from '../../jsx'; import Component from '../../base/component'; var getPoint = function getPoint(cener, angle, r) { var x = cener.x + Math.cos(angle) * r; var y = cener.y + Math.sin(angle) * r; return { x: x, y: y }; }; var getTicks = function getTicks(start, end, tickCount, center, r, tickOffset, tickLength) { var ticks = []; var diff = end - start; for (var i = 0; i <= tickCount; i++) { var tickValue = start + diff * i / tickCount; var startPoint = getPoint(center, tickValue, r + tickOffset - tickLength); var endPoint = getPoint(center, tickValue, r + tickOffset); ticks.push({ tickValue: tickValue, start: startPoint, end: endPoint }); } return ticks; }; export default (function (View) { return /*#__PURE__*/function (_Component) { _inherits(Guage, _Component); var _super = _createSuper(Guage); function Guage() { _classCallCheck(this, Guage); return _super.apply(this, arguments); } _createClass(Guage, [{ key: "render", value: function render() { var props = this.props, context = this.context; var startAngle = props.startAngle, endAngle = props.endAngle, tickCount = props.tickCount, center = props.center, r = props.r, tickOffset = props.tickOffset, tickLength = props.tickLength; var ticks = getTicks(startAngle, endAngle, tickCount, center, context.px2hd(r), context.px2hd(tickOffset), context.px2hd(tickLength)); return jsx(View, _objectSpread(_objectSpread({}, props), {}, { ticks: ticks })); } }]); return Guage; }(Component); });