UNPKG

@alicloud/cloud-charts

Version:

![](https://img.shields.io/npm/v/@alicloud/cloud-charts?color=%23ff8200)

76 lines (71 loc) 2.4 kB
'use strict'; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports["default"] = _default; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _common = require("./common"); /** * rectYAxis 直角坐标系的单个Y轴配置 * * @param {this} ctx 组件实例 this 指针 * @param {Chart} chart 图表实例 * @param {Object} config 配置项 * @param {string} yField 数据映射字段 * @param {Object} defaultConfig 组件的自定义配置 * */ function _default(ctx, chart, config, yField, defaultConfig) { if (yField === void 0) { yField = 'y'; } if (config.yAxis === false || config.yAxis && config.yAxis.visible === false) { chart.axis(yField, false); } else { var _ref = config.yAxis || {}, alias = _ref.alias, _ref$autoRotate = _ref.autoRotate, autoRotate = _ref$autoRotate === void 0 ? false : _ref$autoRotate, rotate = _ref.rotate, autoHide = _ref.autoHide, autoEllipsis = _ref.autoEllipsis, label = _ref.label, labelFormatter = _ref.labelFormatter, customConfig = _ref.customConfig; var yConfig = (0, _extends2["default"])({}, defaultConfig, { title: null, // 不展示坐标轴的标题 label: label === undefined ? { autoRotate: autoRotate, rotate: rotate, autoHide: autoHide, autoEllipsis: autoEllipsis, formatter: labelFormatter || (0, _common.customFormatter)((0, _extends2["default"])({ hideZeroUnit: true }, config.yAxis || {})) } : label }); // // 关闭了X轴,需要显示第一条grid // if (config.xAxis === false || (config.xAxis && config.xAxis.visible === false)) { // yConfig.grid = { // hideFirstLine: false, // }; // } // 开启坐标轴标题 if (alias) { yConfig.title = {}; if (yField === 'y1') { // @ts-ignore G2 文档中没有出现的属性,传入角度值,手动设置转动角度 yConfig.title.rotate = Math.PI / 2; } // yConfig.label.textStyle = { // rotate: 0, // }; } // if (componentConfig) { // Object.assign(yConfig, componentConfig); // } if (customConfig) { (0, _common.merge)(yConfig, customConfig); } chart.axis(yField, yConfig); } }