UNPKG

@antv/g2plot

Version:

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

98 lines 3.08 kB
import { __extends } from "tslib"; import * as _ from '@antv/util'; import ElementParser from '../base'; var CircleParser = /** @class */ (function (_super) { __extends(CircleParser, _super); function CircleParser() { return _super !== null && _super.apply(this, arguments) || this; } CircleParser.prototype.init = function () { var props = this.plot.options; this.style = props.pointStyle; if (!props.xField || !props.yField) { return; } this.config = { type: 'point', position: { fields: [props.xField, props.yField], }, }; this.parseColor(); this.parseSize(); if (props.shape) { this.parseShape(props.shape); } if (props.pointStyle) { this.parseStyle(); } }; CircleParser.prototype.parseColor = function () { var props = this.plot.options; var config = {}; var colorField = props.colorField; if (colorField) { config.fields = _.isArray(colorField) ? colorField : [colorField]; } if (props.color) { this._parseColor(props, config); } this.config.color = config; }; CircleParser.prototype.parseSize = function () { var props = this.plot.options; var config = {}; if (props.sizeField) { config.fields = [props.sizeField]; } if (props.pointSize) { config.values = props.pointSize; } this.config.size = config; }; CircleParser.prototype.parseShape = function (shapeName) { var config = { values: [shapeName], }; this.config.shape = config; }; CircleParser.prototype.parseStyle = function () { var props = this.plot.options; var styleProps = props.pointStyle; var config = { fields: null, callback: null, cfg: null, }; var xField = props.xField, yField = props.yField, colorField = props.colorField; if (_.isFunction(styleProps)) { if (colorField) { config.fields = _.isArray(colorField) ? [xField, yField, colorField].concat(colorField) : [xField, yField, colorField]; } else { config.fields = [xField, yField]; } config.callback = styleProps; } else { config.cfg = styleProps; } this.config.style = config; }; CircleParser.prototype._parseColor = function (props, config) { if (_.isString(props.color)) { config.values = [props.color]; } else if (_.isFunction(props.color)) { config.callback = props.color; } else if (_.isArray(props.color)) { config.values = props.color; } }; return CircleParser; }(ElementParser)); export default CircleParser; //# sourceMappingURL=circle.js.map