@antv/f2
Version:
Charts for mobile visualization.
93 lines • 2.61 kB
JavaScript
import { __assign, __rest } from "tslib";
import { jsx } from '@antv/f-engine';
import { isArray } from '@antv/util';
export default (function (props, context) {
var originTicks = props.ticks,
coord = props.coord,
style = props.style;
var px2hd = context.px2hd;
var top = coord.top,
right = coord.right,
bottom = coord.bottom;
var grid = style.grid,
tickLine = style.tickLine,
line = style.line,
labelOffset = style.labelOffset,
label = style.label,
symbol = style.symbol;
var ticks = originTicks.filter(function (d) {
return !isNaN(d.value);
});
var symbols = isArray(symbol) ? symbol : [symbol];
var _a = tickLine || {},
tickLineLength = _a.length,
tickLineStyle = __rest(_a, ["length"]);
return 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 jsx("line", {
key: "grid-".concat(tickValue),
style: __assign(__assign({
x1: start.x,
y1: start.y,
x2: end.x,
y2: end.y
}, grid), gridStyle)
});
}) : null, tickLineLength ? ticks.map(function (tick) {
var points = tick.points,
tickValue = tick.tickValue;
var end = points[points.length - 1];
return jsx("line", {
key: "tickLine-".concat(tickValue),
style: __assign({
x1: end.x,
y1: end.y,
x2: end.x + px2hd(tickLineLength),
y2: end.y
}, tickLineStyle)
});
}) : null, symbols[0] ? jsx("marker", {
style: __assign(__assign({
x: right,
y: top
}, symbols[0]), {
symbol: symbols[0].type
})
}) : null, line ? jsx("line", {
style: __assign({
x1: right,
y1: top,
x2: right,
y2: bottom
}, line)
}) : null, symbols[1] ? jsx("marker", {
style: __assign(__assign({
x: right,
y: bottom,
transform: 'rotate(180deg)',
transformOrigin: '50% 50%'
}, symbols[1]), {
symbol: symbols[1].type
})
}) : null, label ? ticks.map(function (tick, _index) {
var tickValue = tick.tickValue,
points = tick.points,
text = tick.text,
labelStyle = tick.labelStyle;
var end = points[points.length - 1];
return jsx("text", {
key: "text-".concat(tickValue),
style: __assign(__assign({
x: end.x + labelOffset,
y: end.y,
textAlign: 'left',
textBaseline: 'middle',
text: text
}, label), labelStyle)
});
}) : null);
});