UNPKG

@antv/g2plot

Version:

G2 Plot, a market of plots built with the Grammar of Graphics'

90 lines 2.75 kB
import * as _ from '@antv/util'; function AxisStyleParser(axisCfg, axis) { if (axis.line) { if (axis.line.visible === false) { axisCfg.line = null; } else if (axis.line.style) { axisCfg.line = _.clone(axis.line.style); } } if (axis.title) { if (axis.title.visible === false) { axisCfg.showTitle = false; } else { if (axis.title.visible === true) { axisCfg.showTitle = true; } if (axisCfg.autoRotate) { axisCfg.autoRotateTitle = axisCfg.autoRotate; } axisCfg.title = _.clone(axis.title); if (axisCfg.title.style) { axisCfg.title.textStyle = axisCfg.title.style; delete axisCfg.title.style; } } } if (axis.tickLine) { if (axis.tickLine.visible === false) { axisCfg.tickLine = null; } else if (axis.tickLine.style) { axisCfg.tickLine = _.clone(axis.tickLine.style); } } if (Object.prototype.hasOwnProperty.call(axis, 'autoHideLabel')) { axisCfg.autoHideLabel = axis.autoHideLabel; } if (Object.prototype.hasOwnProperty.call(axis, 'autoRotateLabel')) { axisCfg.autoRotateLabel = axis.autoRotateLabel; } if (axis.label) { if (axis.label.visible === false) { axisCfg.label = null; } else { var newLabel_1 = _.clone(axis.label); if (newLabel_1.style) { newLabel_1.textStyle = newLabel_1.style; delete newLabel_1.style; } if (axis.label.formatter) { var textFormatter_1 = axis.label.formatter; axisCfg.label = function (text) { newLabel_1.text = textFormatter_1(text); return newLabel_1; }; } else { axisCfg.label = newLabel_1; } } } if (axis.grid) { if (axis.grid.visible === false) { axisCfg.grid = null; } else { axisCfg.grid = _.clone(axis.grid); if (axis.grid.style) { axisCfg.grid = _.clone(axis.grid.style); } } } } function TooltipStyleParser() { } function LabelStyleParser(theme, style) { var labelCfg = theme.label; labelCfg.textStyle = style; } function AnnotationStyleParser() { } function checkNull(cfg) { if (cfg === null) { return {}; } return cfg; } export { AxisStyleParser, TooltipStyleParser, LabelStyleParser, AnnotationStyleParser }; //# sourceMappingURL=style-parser.js.map