@antv/f2
Version:
Charts for mobile visualization.
123 lines (122 loc) • 3.42 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _jsx = require("../../../jsx");
var _default = function _default(props, context) {
var ticks = props.ticks,
coord = props.coord,
style = props.style,
animation = props.animation;
var px2hd = context.px2hd;
var left = coord.left,
right = coord.right,
bottom = coord.bottom;
var grid = style.grid,
tickLine = style.tickLine,
line = style.line,
labelOffset = style.labelOffset,
label = style.label;
return (0, _jsx.jsx)("group", null, grid ? ticks.map(function (tick) {
var points = tick.points,
tickValue = tick.tickValue,
gridStyle = tick.gridStyle;
var start = points[0];
var end = points[points.length - 1];
return (0, _jsx.jsx)("line", {
key: tickValue,
attrs: (0, _objectSpread2.default)((0, _objectSpread2.default)({
x1: start.x,
y1: start.y,
x2: end.x,
y2: end.y
}, grid), gridStyle)
});
}) : null, tickLine && tickLine.length ? ticks.map(function (tick) {
var points = tick.points,
tickValue = tick.tickValue;
var start = points[0];
return (0, _jsx.jsx)("line", {
key: tickValue,
attrs: (0, _objectSpread2.default)({
x1: start.x,
y1: start.y,
x2: start.x,
y2: start.y + px2hd(tickLine.length)
}, tickLine)
});
}) : null, line ? (0, _jsx.jsx)("line", {
attrs: (0, _objectSpread2.default)({
x1: left,
y1: bottom,
x2: right,
y2: bottom
}, line)
}) : null, label ? ticks.map(function (tick, index) {
var points = tick.points,
text = tick.text,
tickValue = tick.tickValue,
labelStyle = tick.labelStyle;
var start = points[0];
var _ref = labelStyle || label || {},
_ref$align = _ref.align,
align = _ref$align === void 0 ? 'center' : _ref$align;
var textAttrs = (0, _objectSpread2.default)((0, _objectSpread2.default)({
x: start.x,
y: start.y + labelOffset,
textBaseline: 'top',
text: text
}, label), labelStyle);
if (align === 'between') {
if (index === 0) {
textAttrs.textAlign = 'start';
} else if (index === ticks.length - 1) {
textAttrs.textAlign = 'end';
} else {
textAttrs.textAlign = 'center';
}
} else {
textAttrs.textAlign = align;
}
return (0, _jsx.jsx)("text", {
key: tickValue,
attrs: textAttrs,
animation: animation || {
appear: {
easing: 'linear',
duration: 300,
delay: 0,
property: ['fillOpacity'],
start: {
fillOpacity: 0
},
end: {
fillOpacity: 1
}
},
update: {
easing: 'linear',
duration: 450,
delay: 0,
property: ['x', 'y']
},
leave: {
easing: 'linear',
duration: 450,
delay: 0,
property: ['fillOpacity'],
start: {
fillOpacity: 1
},
end: {
fillOpacity: 0
}
}
}
});
}) : null);
};
exports.default = _default;
;