| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773 |
- "use strict";
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.axis = axis;
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
- var _updater = require("../class/updater.class");
- var _config = require("../config");
- var _util = require("../util");
- var _util2 = require("@jiaminghi/c-render/lib/plugin/util");
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
- var axisConfig = {
- xAxisConfig: _config.xAxisConfig,
- yAxisConfig: _config.yAxisConfig
- };
- var min = Math.min,
- max = Math.max,
- abs = Math.abs,
- pow = Math.pow;
- function axis(chart) {
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var xAxis = option.xAxis,
- yAxis = option.yAxis,
- series = option.series;
- var allAxis = [];
- if (xAxis && yAxis && series) {
- allAxis = getAllAxis(xAxis, yAxis);
- allAxis = mergeDefaultAxisConfig(allAxis);
- allAxis = allAxis.filter(function (_ref) {
- var show = _ref.show;
- return show;
- });
- allAxis = mergeDefaultBoundaryGap(allAxis);
- allAxis = calcAxisLabelData(allAxis, series);
- allAxis = setAxisPosition(allAxis);
- allAxis = calcAxisLinePosition(allAxis, chart);
- allAxis = calcAxisTickPosition(allAxis, chart);
- allAxis = calcAxisNamePosition(allAxis, chart);
- allAxis = calcSplitLinePosition(allAxis, chart);
- }
- (0, _updater.doUpdate)({
- chart: chart,
- series: allAxis,
- key: 'axisLine',
- getGraphConfig: getLineConfig
- });
- (0, _updater.doUpdate)({
- chart: chart,
- series: allAxis,
- key: 'axisTick',
- getGraphConfig: getTickConfig
- });
- (0, _updater.doUpdate)({
- chart: chart,
- series: allAxis,
- key: 'axisLabel',
- getGraphConfig: getLabelConfig
- });
- (0, _updater.doUpdate)({
- chart: chart,
- series: allAxis,
- key: 'axisName',
- getGraphConfig: getNameConfig
- });
- (0, _updater.doUpdate)({
- chart: chart,
- series: allAxis,
- key: 'splitLine',
- getGraphConfig: getSplitLineConfig
- });
- chart.axisData = allAxis;
- }
- function getAllAxis(xAxis, yAxis) {
- var allXAxis = [],
- allYAxis = [];
- if (xAxis instanceof Array) {
- var _allXAxis;
- (_allXAxis = allXAxis).push.apply(_allXAxis, (0, _toConsumableArray2["default"])(xAxis));
- } else {
- allXAxis.push(xAxis);
- }
- if (yAxis instanceof Array) {
- var _allYAxis;
- (_allYAxis = allYAxis).push.apply(_allYAxis, (0, _toConsumableArray2["default"])(yAxis));
- } else {
- allYAxis.push(yAxis);
- }
- allXAxis.splice(2);
- allYAxis.splice(2);
- allXAxis = allXAxis.map(function (axis, i) {
- return _objectSpread(_objectSpread({}, axis), {}, {
- index: i,
- axis: 'x'
- });
- });
- allYAxis = allYAxis.map(function (axis, i) {
- return _objectSpread(_objectSpread({}, axis), {}, {
- index: i,
- axis: 'y'
- });
- });
- return [].concat((0, _toConsumableArray2["default"])(allXAxis), (0, _toConsumableArray2["default"])(allYAxis));
- }
- function mergeDefaultAxisConfig(allAxis) {
- var xAxis = allAxis.filter(function (_ref2) {
- var axis = _ref2.axis;
- return axis === 'x';
- });
- var yAxis = allAxis.filter(function (_ref3) {
- var axis = _ref3.axis;
- return axis === 'y';
- });
- xAxis = xAxis.map(function (axis) {
- return (0, _util.deepMerge)((0, _util2.deepClone)(_config.xAxisConfig), axis);
- });
- yAxis = yAxis.map(function (axis) {
- return (0, _util.deepMerge)((0, _util2.deepClone)(_config.yAxisConfig), axis);
- });
- return [].concat((0, _toConsumableArray2["default"])(xAxis), (0, _toConsumableArray2["default"])(yAxis));
- }
- function mergeDefaultBoundaryGap(allAxis) {
- var valueAxis = allAxis.filter(function (_ref4) {
- var data = _ref4.data;
- return data === 'value';
- });
- var labelAxis = allAxis.filter(function (_ref5) {
- var data = _ref5.data;
- return data !== 'value';
- });
- valueAxis.forEach(function (axis) {
- if (typeof axis.boundaryGap === 'boolean') return;
- axis.boundaryGap = false;
- });
- labelAxis.forEach(function (axis) {
- if (typeof axis.boundaryGap === 'boolean') return;
- axis.boundaryGap = true;
- });
- return [].concat((0, _toConsumableArray2["default"])(valueAxis), (0, _toConsumableArray2["default"])(labelAxis));
- }
- function calcAxisLabelData(allAxis, series) {
- var valueAxis = allAxis.filter(function (_ref6) {
- var data = _ref6.data;
- return data === 'value';
- });
- var labelAxis = allAxis.filter(function (_ref7) {
- var data = _ref7.data;
- return data instanceof Array;
- });
- valueAxis = calcValueAxisLabelData(valueAxis, series);
- labelAxis = calcLabelAxisLabelData(labelAxis);
- return [].concat((0, _toConsumableArray2["default"])(valueAxis), (0, _toConsumableArray2["default"])(labelAxis));
- }
- function calcValueAxisLabelData(valueAxis, series) {
- return valueAxis.map(function (axis) {
- var minMaxValue = getValueAxisMaxMinValue(axis, series);
- var _getTrueMinMax = getTrueMinMax(axis, minMaxValue),
- _getTrueMinMax2 = (0, _slicedToArray2["default"])(_getTrueMinMax, 2),
- min = _getTrueMinMax2[0],
- max = _getTrueMinMax2[1];
- var interval = getValueInterval(min, max, axis);
- var formatter = axis.axisLabel.formatter;
- var label = [];
- if (min < 0 && max > 0) {
- label = getValueAxisLabelFromZero(min, max, interval);
- } else {
- label = getValueAxisLabelFromMin(min, max, interval);
- }
- label = label.map(function (l) {
- return parseFloat(l.toFixed(2));
- });
- return _objectSpread(_objectSpread({}, axis), {}, {
- maxValue: label.slice(-1)[0],
- minValue: label[0],
- label: getAfterFormatterLabel(label, formatter)
- });
- });
- }
- function getValueAxisMaxMinValue(axis, series) {
- series = series.filter(function (_ref8) {
- var show = _ref8.show,
- type = _ref8.type;
- if (show === false) return false;
- if (type === 'pie') return false;
- return true;
- });
- if (series.length === 0) return [0, 0];
- var index = axis.index,
- axisType = axis.axis;
- series = mergeStackData(series);
- var axisName = axisType + 'Axis';
- var valueSeries = series.filter(function (s) {
- return s[axisName] === index;
- });
- if (!valueSeries.length) valueSeries = series;
- return getSeriesMinMaxValue(valueSeries);
- }
- function getSeriesMinMaxValue(series) {
- if (!series) return;
- var minValue = Math.min.apply(Math, (0, _toConsumableArray2["default"])(series.map(function (_ref9) {
- var data = _ref9.data;
- return Math.min.apply(Math, (0, _toConsumableArray2["default"])((0, _util.filterNonNumber)(data)));
- })));
- var maxValue = Math.max.apply(Math, (0, _toConsumableArray2["default"])(series.map(function (_ref10) {
- var data = _ref10.data;
- return Math.max.apply(Math, (0, _toConsumableArray2["default"])((0, _util.filterNonNumber)(data)));
- })));
- return [minValue, maxValue];
- }
- function mergeStackData(series) {
- var seriesCloned = (0, _util2.deepClone)(series, true);
- series.forEach(function (item, i) {
- var data = (0, _util.mergeSameStackData)(item, series);
- seriesCloned[i].data = data;
- });
- return seriesCloned;
- }
- function getTrueMinMax(_ref11, _ref12) {
- var min = _ref11.min,
- max = _ref11.max,
- axis = _ref11.axis;
- var _ref13 = (0, _slicedToArray2["default"])(_ref12, 2),
- minValue = _ref13[0],
- maxValue = _ref13[1];
- var minType = (0, _typeof2["default"])(min),
- maxType = (0, _typeof2["default"])(max);
- if (!testMinMaxType(min)) {
- min = axisConfig[axis + 'AxisConfig'].min;
- minType = 'string';
- }
- if (!testMinMaxType(max)) {
- max = axisConfig[axis + 'AxisConfig'].max;
- maxType = 'string';
- }
- if (minType === 'string') {
- min = parseInt(minValue - abs(minValue * parseFloat(min) / 100));
- var lever = getValueLever(min);
- min = parseFloat((min / lever - 0.1).toFixed(1)) * lever;
- }
- if (maxType === 'string') {
- max = parseInt(maxValue + abs(maxValue * parseFloat(max) / 100));
- var _lever = getValueLever(max);
- max = parseFloat((max / _lever + 0.1).toFixed(1)) * _lever;
- }
- return [min, max];
- }
- function getValueLever(value) {
- var valueString = abs(value).toString();
- var valueLength = valueString.length;
- var firstZeroIndex = valueString.replace(/0*$/g, '').indexOf('0');
- var pow10Num = valueLength - 1;
- if (firstZeroIndex !== -1) pow10Num -= firstZeroIndex;
- return pow(10, pow10Num);
- }
- function testMinMaxType(val) {
- var valType = (0, _typeof2["default"])(val);
- var isValidString = valType === 'string' && /^\d+%$/.test(val);
- var isValidNumber = valType === 'number';
- return isValidString || isValidNumber;
- }
- function getValueAxisLabelFromZero(min, max, interval) {
- var negative = [],
- positive = [];
- var currentNegative = 0,
- currentPositive = 0;
- do {
- negative.push(currentNegative -= interval);
- } while (currentNegative > min);
- do {
- positive.push(currentPositive += interval);
- } while (currentPositive < max);
- return [].concat((0, _toConsumableArray2["default"])(negative.reverse()), [0], (0, _toConsumableArray2["default"])(positive));
- }
- function getValueAxisLabelFromMin(min, max, interval) {
- var label = [min],
- currentValue = min;
- do {
- label.push(currentValue += interval);
- } while (currentValue < max);
- return label;
- }
- function getAfterFormatterLabel(label, formatter) {
- if (!formatter) return label;
- if (typeof formatter === 'string') label = label.map(function (l) {
- return formatter.replace('{value}', l);
- });
- if (typeof formatter === 'function') label = label.map(function (value, index) {
- return formatter({
- value: value,
- index: index
- });
- });
- return label;
- }
- function calcLabelAxisLabelData(labelAxis) {
- return labelAxis.map(function (axis) {
- var data = axis.data,
- formatter = axis.axisLabel.formatter;
- return _objectSpread(_objectSpread({}, axis), {}, {
- label: getAfterFormatterLabel(data, formatter)
- });
- });
- }
- function getValueInterval(min, max, axis) {
- var interval = axis.interval,
- minInterval = axis.minInterval,
- maxInterval = axis.maxInterval,
- splitNumber = axis.splitNumber,
- axisType = axis.axis;
- var config = axisConfig[axisType + 'AxisConfig'];
- if (typeof interval !== 'number') interval = config.interval;
- if (typeof minInterval !== 'number') minInterval = config.minInterval;
- if (typeof maxInterval !== 'number') maxInterval = config.maxInterval;
- if (typeof splitNumber !== 'number') splitNumber = config.splitNumber;
- if (typeof interval === 'number') return interval;
- var valueInterval = parseInt((max - min) / (splitNumber - 1));
- if (valueInterval.toString().length > 1) valueInterval = parseInt(valueInterval.toString().replace(/\d$/, '0'));
- if (valueInterval === 0) valueInterval = 1;
- if (typeof minInterval === 'number' && valueInterval < minInterval) return minInterval;
- if (typeof maxInterval === 'number' && valueInterval > maxInterval) return maxInterval;
- return valueInterval;
- }
- function setAxisPosition(allAxis) {
- var xAxis = allAxis.filter(function (_ref14) {
- var axis = _ref14.axis;
- return axis === 'x';
- });
- var yAxis = allAxis.filter(function (_ref15) {
- var axis = _ref15.axis;
- return axis === 'y';
- });
- if (xAxis[0] && !xAxis[0].position) xAxis[0].position = _config.xAxisConfig.position;
- if (xAxis[1] && !xAxis[1].position) {
- xAxis[1].position = xAxis[0].position === 'bottom' ? 'top' : 'bottom';
- }
- if (yAxis[0] && !yAxis[0].position) yAxis[0].position = _config.yAxisConfig.position;
- if (yAxis[1] && !yAxis[1].position) {
- yAxis[1].position = yAxis[0].position === 'left' ? 'right' : 'left';
- }
- return [].concat((0, _toConsumableArray2["default"])(xAxis), (0, _toConsumableArray2["default"])(yAxis));
- }
- function calcAxisLinePosition(allAxis, chart) {
- var _chart$gridArea = chart.gridArea,
- x = _chart$gridArea.x,
- y = _chart$gridArea.y,
- w = _chart$gridArea.w,
- h = _chart$gridArea.h;
- allAxis = allAxis.map(function (axis) {
- var position = axis.position;
- var linePosition = [];
- if (position === 'left') {
- linePosition = [[x, y], [x, y + h]].reverse();
- } else if (position === 'right') {
- linePosition = [[x + w, y], [x + w, y + h]].reverse();
- } else if (position === 'top') {
- linePosition = [[x, y], [x + w, y]];
- } else if (position === 'bottom') {
- linePosition = [[x, y + h], [x + w, y + h]];
- }
- return _objectSpread(_objectSpread({}, axis), {}, {
- linePosition: linePosition
- });
- });
- return allAxis;
- }
- function calcAxisTickPosition(allAxis, chart) {
- return allAxis.map(function (axisItem) {
- var axis = axisItem.axis,
- linePosition = axisItem.linePosition,
- position = axisItem.position,
- label = axisItem.label,
- boundaryGap = axisItem.boundaryGap;
- if (typeof boundaryGap !== 'boolean') boundaryGap = axisConfig[axis + 'AxisConfig'].boundaryGap;
- var labelNum = label.length;
- var _linePosition = (0, _slicedToArray2["default"])(linePosition, 2),
- _linePosition$ = (0, _slicedToArray2["default"])(_linePosition[0], 2),
- startX = _linePosition$[0],
- startY = _linePosition$[1],
- _linePosition$2 = (0, _slicedToArray2["default"])(_linePosition[1], 2),
- endX = _linePosition$2[0],
- endY = _linePosition$2[1];
- var gapLength = axis === 'x' ? endX - startX : endY - startY;
- var gap = gapLength / (boundaryGap ? labelNum : labelNum - 1);
- var tickPosition = new Array(labelNum).fill(0).map(function (foo, i) {
- if (axis === 'x') {
- return [startX + gap * (boundaryGap ? i + 0.5 : i), startY];
- }
- return [startX, startY + gap * (boundaryGap ? i + 0.5 : i)];
- });
- var tickLinePosition = getTickLinePosition(axis, boundaryGap, position, tickPosition, gap);
- return _objectSpread(_objectSpread({}, axisItem), {}, {
- tickPosition: tickPosition,
- tickLinePosition: tickLinePosition,
- tickGap: gap
- });
- });
- }
- function getTickLinePosition(axisType, boundaryGap, position, tickPosition, gap) {
- var index = axisType === 'x' ? 1 : 0;
- var plus = 5;
- if (axisType === 'x' && position === 'top') plus = -5;
- if (axisType === 'y' && position === 'left') plus = -5;
- var tickLinePosition = tickPosition.map(function (lineStart) {
- var lineEnd = (0, _util2.deepClone)(lineStart);
- lineEnd[index] += plus;
- return [(0, _util2.deepClone)(lineStart), lineEnd];
- });
- if (!boundaryGap) return tickLinePosition;
- index = axisType === 'x' ? 0 : 1;
- plus = gap / 2;
- tickLinePosition.forEach(function (_ref16) {
- var _ref17 = (0, _slicedToArray2["default"])(_ref16, 2),
- lineStart = _ref17[0],
- lineEnd = _ref17[1];
- lineStart[index] += plus;
- lineEnd[index] += plus;
- });
- return tickLinePosition;
- }
- function calcAxisNamePosition(allAxis, chart) {
- return allAxis.map(function (axisItem) {
- var nameGap = axisItem.nameGap,
- nameLocation = axisItem.nameLocation,
- position = axisItem.position,
- linePosition = axisItem.linePosition;
- var _linePosition2 = (0, _slicedToArray2["default"])(linePosition, 2),
- lineStart = _linePosition2[0],
- lineEnd = _linePosition2[1];
- var namePosition = (0, _toConsumableArray2["default"])(lineStart);
- if (nameLocation === 'end') namePosition = (0, _toConsumableArray2["default"])(lineEnd);
- if (nameLocation === 'center') {
- namePosition[0] = (lineStart[0] + lineEnd[0]) / 2;
- namePosition[1] = (lineStart[1] + lineEnd[1]) / 2;
- }
- var index = 0;
- if (position === 'top' && nameLocation === 'center') index = 1;
- if (position === 'bottom' && nameLocation === 'center') index = 1;
- if (position === 'left' && nameLocation !== 'center') index = 1;
- if (position === 'right' && nameLocation !== 'center') index = 1;
- var plus = nameGap;
- if (position === 'top' && nameLocation !== 'end') plus *= -1;
- if (position === 'left' && nameLocation !== 'start') plus *= -1;
- if (position === 'bottom' && nameLocation === 'start') plus *= -1;
- if (position === 'right' && nameLocation === 'end') plus *= -1;
- namePosition[index] += plus;
- return _objectSpread(_objectSpread({}, axisItem), {}, {
- namePosition: namePosition
- });
- });
- }
- function calcSplitLinePosition(allAxis, chart) {
- var _chart$gridArea2 = chart.gridArea,
- w = _chart$gridArea2.w,
- h = _chart$gridArea2.h;
- return allAxis.map(function (axisItem) {
- var tickLinePosition = axisItem.tickLinePosition,
- position = axisItem.position,
- boundaryGap = axisItem.boundaryGap;
- var index = 0,
- plus = w;
- if (position === 'top' || position === 'bottom') index = 1;
- if (position === 'top' || position === 'bottom') plus = h;
- if (position === 'right' || position === 'bottom') plus *= -1;
- var splitLinePosition = tickLinePosition.map(function (_ref18) {
- var _ref19 = (0, _slicedToArray2["default"])(_ref18, 1),
- startPoint = _ref19[0];
- var endPoint = (0, _toConsumableArray2["default"])(startPoint);
- endPoint[index] += plus;
- return [(0, _toConsumableArray2["default"])(startPoint), endPoint];
- });
- if (!boundaryGap) splitLinePosition.shift();
- return _objectSpread(_objectSpread({}, axisItem), {}, {
- splitLinePosition: splitLinePosition
- });
- });
- }
- function getLineConfig(axisItem) {
- var animationCurve = axisItem.animationCurve,
- animationFrame = axisItem.animationFrame,
- rLevel = axisItem.rLevel;
- return [{
- name: 'polyline',
- index: rLevel,
- visible: axisItem.axisLine.show,
- animationCurve: animationCurve,
- animationFrame: animationFrame,
- shape: getLineShape(axisItem),
- style: getLineStyle(axisItem)
- }];
- }
- function getLineShape(axisItem) {
- var linePosition = axisItem.linePosition;
- return {
- points: linePosition
- };
- }
- function getLineStyle(axisItem) {
- return axisItem.axisLine.style;
- }
- function getTickConfig(axisItem) {
- var animationCurve = axisItem.animationCurve,
- animationFrame = axisItem.animationFrame,
- rLevel = axisItem.rLevel;
- var shapes = getTickShapes(axisItem);
- var style = getTickStyle(axisItem);
- return shapes.map(function (shape) {
- return {
- name: 'polyline',
- index: rLevel,
- visible: axisItem.axisTick.show,
- animationCurve: animationCurve,
- animationFrame: animationFrame,
- shape: shape,
- style: style
- };
- });
- }
- function getTickShapes(axisItem) {
- var tickLinePosition = axisItem.tickLinePosition;
- return tickLinePosition.map(function (points) {
- return {
- points: points
- };
- });
- }
- function getTickStyle(axisItem) {
- return axisItem.axisTick.style;
- }
- function getLabelConfig(axisItem) {
- var animationCurve = axisItem.animationCurve,
- animationFrame = axisItem.animationFrame,
- rLevel = axisItem.rLevel;
- var shapes = getLabelShapes(axisItem);
- var styles = getLabelStyle(axisItem, shapes);
- return shapes.map(function (shape, i) {
- return {
- name: 'text',
- index: rLevel,
- visible: axisItem.axisLabel.show,
- animationCurve: animationCurve,
- animationFrame: animationFrame,
- shape: shape,
- style: styles[i],
- setGraphCenter: function setGraphCenter() {
- return void 0;
- }
- };
- });
- }
- function getLabelShapes(axisItem) {
- var label = axisItem.label,
- tickPosition = axisItem.tickPosition,
- position = axisItem.position;
- return tickPosition.map(function (point, i) {
- return {
- position: getLabelRealPosition(point, position),
- content: label[i].toString()
- };
- });
- }
- function getLabelRealPosition(points, position) {
- var index = 0,
- plus = 10;
- if (position === 'top' || position === 'bottom') index = 1;
- if (position === 'top' || position === 'left') plus = -10;
- points = (0, _util2.deepClone)(points);
- points[index] += plus;
- return points;
- }
- function getLabelStyle(axisItem, shapes) {
- var position = axisItem.position;
- var style = axisItem.axisLabel.style;
- var align = getAxisLabelRealAlign(position);
- style = (0, _util.deepMerge)(align, style);
- var styles = shapes.map(function (_ref20) {
- var position = _ref20.position;
- return _objectSpread(_objectSpread({}, style), {}, {
- graphCenter: position
- });
- });
- return styles;
- }
- function getAxisLabelRealAlign(position) {
- if (position === 'left') return {
- textAlign: 'right',
- textBaseline: 'middle'
- };
- if (position === 'right') return {
- textAlign: 'left',
- textBaseline: 'middle'
- };
- if (position === 'top') return {
- textAlign: 'center',
- textBaseline: 'bottom'
- };
- if (position === 'bottom') return {
- textAlign: 'center',
- textBaseline: 'top'
- };
- }
- function getNameConfig(axisItem) {
- var animationCurve = axisItem.animationCurve,
- animationFrame = axisItem.animationFrame,
- rLevel = axisItem.rLevel;
- return [{
- name: 'text',
- index: rLevel,
- animationCurve: animationCurve,
- animationFrame: animationFrame,
- shape: getNameShape(axisItem),
- style: getNameStyle(axisItem)
- }];
- }
- function getNameShape(axisItem) {
- var name = axisItem.name,
- namePosition = axisItem.namePosition;
- return {
- content: name,
- position: namePosition
- };
- }
- function getNameStyle(axisItem) {
- var nameLocation = axisItem.nameLocation,
- position = axisItem.position,
- style = axisItem.nameTextStyle;
- var align = getNameRealAlign(position, nameLocation);
- return (0, _util.deepMerge)(align, style);
- }
- function getNameRealAlign(position, location) {
- if (position === 'top' && location === 'start' || position === 'bottom' && location === 'start' || position === 'left' && location === 'center') return {
- textAlign: 'right',
- textBaseline: 'middle'
- };
- if (position === 'top' && location === 'end' || position === 'bottom' && location === 'end' || position === 'right' && location === 'center') return {
- textAlign: 'left',
- textBaseline: 'middle'
- };
- if (position === 'top' && location === 'center' || position === 'left' && location === 'end' || position === 'right' && location === 'end') return {
- textAlign: 'center',
- textBaseline: 'bottom'
- };
- if (position === 'bottom' && location === 'center' || position === 'left' && location === 'start' || position === 'right' && location === 'start') return {
- textAlign: 'center',
- textBaseline: 'top'
- };
- }
- function getSplitLineConfig(axisItem) {
- var animationCurve = axisItem.animationCurve,
- animationFrame = axisItem.animationFrame,
- rLevel = axisItem.rLevel;
- var shapes = getSplitLineShapes(axisItem);
- var style = getSplitLineStyle(axisItem);
- return shapes.map(function (shape) {
- return {
- name: 'polyline',
- index: rLevel,
- visible: axisItem.splitLine.show,
- animationCurve: animationCurve,
- animationFrame: animationFrame,
- shape: shape,
- style: style
- };
- });
- }
- function getSplitLineShapes(axisItem) {
- var splitLinePosition = axisItem.splitLinePosition;
- return splitLinePosition.map(function (points) {
- return {
- points: points
- };
- });
- }
- function getSplitLineStyle(axisItem) {
- return axisItem.splitLine.style;
- }
|