first commit
This commit is contained in:
+337
@@ -0,0 +1,337 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
import * as zrUtil from 'zrender/lib/core/util.js';
|
||||
import * as graphic from '../../util/graphic.js';
|
||||
import { createTextStyle } from '../../label/labelStyle.js';
|
||||
import Model from '../../model/Model.js';
|
||||
import AxisView from './AxisView.js';
|
||||
import AxisBuilder from './AxisBuilder.js';
|
||||
import { getECData } from '../../util/innerStore.js';
|
||||
var elementList = ['axisLine', 'axisLabel', 'axisTick', 'minorTick', 'splitLine', 'minorSplitLine', 'splitArea'];
|
||||
function getAxisLineShape(polar, rExtent, angle) {
|
||||
rExtent[1] > rExtent[0] && (rExtent = rExtent.slice().reverse());
|
||||
var start = polar.coordToPoint([rExtent[0], angle]);
|
||||
var end = polar.coordToPoint([rExtent[1], angle]);
|
||||
return {
|
||||
x1: start[0],
|
||||
y1: start[1],
|
||||
x2: end[0],
|
||||
y2: end[1]
|
||||
};
|
||||
}
|
||||
function getRadiusIdx(polar) {
|
||||
var radiusAxis = polar.getRadiusAxis();
|
||||
return radiusAxis.inverse ? 0 : 1;
|
||||
}
|
||||
// Remove the last tick which will overlap the first tick
|
||||
function fixAngleOverlap(list) {
|
||||
var firstItem = list[0];
|
||||
var lastItem = list[list.length - 1];
|
||||
if (firstItem && lastItem && Math.abs(Math.abs(firstItem.coord - lastItem.coord) - 360) < 1e-4) {
|
||||
list.pop();
|
||||
}
|
||||
}
|
||||
var AngleAxisView = /** @class */function (_super) {
|
||||
__extends(AngleAxisView, _super);
|
||||
function AngleAxisView() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.type = AngleAxisView.type;
|
||||
_this.axisPointerClass = 'PolarAxisPointer';
|
||||
return _this;
|
||||
}
|
||||
AngleAxisView.prototype.render = function (angleAxisModel, ecModel) {
|
||||
this.group.removeAll();
|
||||
if (!angleAxisModel.get('show')) {
|
||||
return;
|
||||
}
|
||||
var angleAxis = angleAxisModel.axis;
|
||||
var polar = angleAxis.polar;
|
||||
var radiusExtent = polar.getRadiusAxis().getExtent();
|
||||
var ticksAngles = angleAxis.getTicksCoords({
|
||||
breakTicks: 'none'
|
||||
});
|
||||
var minorTickAngles = angleAxis.getMinorTicksCoords();
|
||||
var labels = zrUtil.map(angleAxis.getViewLabels(), function (labelItem) {
|
||||
labelItem = zrUtil.clone(labelItem);
|
||||
var scale = angleAxis.scale;
|
||||
var tickValue = scale.type === 'ordinal' ? scale.getRawOrdinalNumber(labelItem.tickValue) : labelItem.tickValue;
|
||||
labelItem.coord = angleAxis.dataToCoord(tickValue);
|
||||
return labelItem;
|
||||
});
|
||||
fixAngleOverlap(labels);
|
||||
fixAngleOverlap(ticksAngles);
|
||||
zrUtil.each(elementList, function (name) {
|
||||
if (angleAxisModel.get([name, 'show']) && (!angleAxis.scale.isBlank() || name === 'axisLine')) {
|
||||
angelAxisElementsBuilders[name](this.group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent, labels);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
AngleAxisView.type = 'angleAxis';
|
||||
return AngleAxisView;
|
||||
}(AxisView);
|
||||
var angelAxisElementsBuilders = {
|
||||
axisLine: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
|
||||
var lineStyleModel = angleAxisModel.getModel(['axisLine', 'lineStyle']);
|
||||
var angleAxis = polar.getAngleAxis();
|
||||
var RADIAN = Math.PI / 180;
|
||||
var angleExtent = angleAxis.getExtent();
|
||||
// extent id of the axis radius (r0 and r)
|
||||
var rId = getRadiusIdx(polar);
|
||||
var r0Id = rId ? 0 : 1;
|
||||
var shape;
|
||||
var shapeType = Math.abs(angleExtent[1] - angleExtent[0]) === 360 ? 'Circle' : 'Arc';
|
||||
if (radiusExtent[r0Id] === 0) {
|
||||
shape = new graphic[shapeType]({
|
||||
shape: {
|
||||
cx: polar.cx,
|
||||
cy: polar.cy,
|
||||
r: radiusExtent[rId],
|
||||
startAngle: -angleExtent[0] * RADIAN,
|
||||
endAngle: -angleExtent[1] * RADIAN,
|
||||
clockwise: angleAxis.inverse
|
||||
},
|
||||
style: lineStyleModel.getLineStyle(),
|
||||
z2: 1,
|
||||
silent: true
|
||||
});
|
||||
} else {
|
||||
shape = new graphic.Ring({
|
||||
shape: {
|
||||
cx: polar.cx,
|
||||
cy: polar.cy,
|
||||
r: radiusExtent[rId],
|
||||
r0: radiusExtent[r0Id]
|
||||
},
|
||||
style: lineStyleModel.getLineStyle(),
|
||||
z2: 1,
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
shape.style.fill = null;
|
||||
group.add(shape);
|
||||
},
|
||||
axisTick: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
|
||||
var tickModel = angleAxisModel.getModel('axisTick');
|
||||
var tickLen = (tickModel.get('inside') ? -1 : 1) * tickModel.get('length');
|
||||
var radius = radiusExtent[getRadiusIdx(polar)];
|
||||
var lines = zrUtil.map(ticksAngles, function (tickAngleItem) {
|
||||
return new graphic.Line({
|
||||
shape: getAxisLineShape(polar, [radius, radius + tickLen], tickAngleItem.coord)
|
||||
});
|
||||
});
|
||||
group.add(graphic.mergePath(lines, {
|
||||
style: zrUtil.defaults(tickModel.getModel('lineStyle').getLineStyle(), {
|
||||
stroke: angleAxisModel.get(['axisLine', 'lineStyle', 'color'])
|
||||
})
|
||||
}));
|
||||
},
|
||||
minorTick: function (group, angleAxisModel, polar, tickAngles, minorTickAngles, radiusExtent) {
|
||||
if (!minorTickAngles.length) {
|
||||
return;
|
||||
}
|
||||
var tickModel = angleAxisModel.getModel('axisTick');
|
||||
var minorTickModel = angleAxisModel.getModel('minorTick');
|
||||
var tickLen = (tickModel.get('inside') ? -1 : 1) * minorTickModel.get('length');
|
||||
var radius = radiusExtent[getRadiusIdx(polar)];
|
||||
var lines = [];
|
||||
for (var i = 0; i < minorTickAngles.length; i++) {
|
||||
for (var k = 0; k < minorTickAngles[i].length; k++) {
|
||||
lines.push(new graphic.Line({
|
||||
shape: getAxisLineShape(polar, [radius, radius + tickLen], minorTickAngles[i][k].coord)
|
||||
}));
|
||||
}
|
||||
}
|
||||
group.add(graphic.mergePath(lines, {
|
||||
style: zrUtil.defaults(minorTickModel.getModel('lineStyle').getLineStyle(), zrUtil.defaults(tickModel.getLineStyle(), {
|
||||
stroke: angleAxisModel.get(['axisLine', 'lineStyle', 'color'])
|
||||
}))
|
||||
}));
|
||||
},
|
||||
axisLabel: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent, labels) {
|
||||
var rawCategoryData = angleAxisModel.getCategories(true);
|
||||
var commonLabelModel = angleAxisModel.getModel('axisLabel');
|
||||
var labelMargin = commonLabelModel.get('margin');
|
||||
var triggerEvent = angleAxisModel.get('triggerEvent');
|
||||
// Use length of ticksAngles because it may remove the last tick to avoid overlapping
|
||||
zrUtil.each(labels, function (labelItem, idx) {
|
||||
var labelModel = commonLabelModel;
|
||||
var tickValue = labelItem.tickValue;
|
||||
var r = radiusExtent[getRadiusIdx(polar)];
|
||||
var p = polar.coordToPoint([r + labelMargin, labelItem.coord]);
|
||||
var cx = polar.cx;
|
||||
var cy = polar.cy;
|
||||
var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3 ? 'center' : p[0] > cx ? 'left' : 'right';
|
||||
var labelTextVerticalAlign = Math.abs(p[1] - cy) / r < 0.3 ? 'middle' : p[1] > cy ? 'top' : 'bottom';
|
||||
if (rawCategoryData && rawCategoryData[tickValue]) {
|
||||
var rawCategoryItem = rawCategoryData[tickValue];
|
||||
if (zrUtil.isObject(rawCategoryItem) && rawCategoryItem.textStyle) {
|
||||
labelModel = new Model(rawCategoryItem.textStyle, commonLabelModel, commonLabelModel.ecModel);
|
||||
}
|
||||
}
|
||||
var textEl = new graphic.Text({
|
||||
silent: AxisBuilder.isLabelSilent(angleAxisModel),
|
||||
style: createTextStyle(labelModel, {
|
||||
x: p[0],
|
||||
y: p[1],
|
||||
fill: labelModel.getTextColor() || angleAxisModel.get(['axisLine', 'lineStyle', 'color']),
|
||||
text: labelItem.formattedLabel,
|
||||
align: labelTextAlign,
|
||||
verticalAlign: labelTextVerticalAlign
|
||||
})
|
||||
});
|
||||
group.add(textEl);
|
||||
graphic.setTooltipConfig({
|
||||
el: textEl,
|
||||
componentModel: angleAxisModel,
|
||||
itemName: labelItem.formattedLabel,
|
||||
formatterParamsExtra: {
|
||||
isTruncated: function () {
|
||||
return textEl.isTruncated;
|
||||
},
|
||||
value: labelItem.rawLabel,
|
||||
tickIndex: idx
|
||||
}
|
||||
});
|
||||
// Pack data for mouse event
|
||||
if (triggerEvent) {
|
||||
var eventData = AxisBuilder.makeAxisEventDataBase(angleAxisModel);
|
||||
eventData.targetType = 'axisLabel';
|
||||
eventData.value = labelItem.rawLabel;
|
||||
getECData(textEl).eventData = eventData;
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
splitLine: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
|
||||
var splitLineModel = angleAxisModel.getModel('splitLine');
|
||||
var lineStyleModel = splitLineModel.getModel('lineStyle');
|
||||
var lineColors = lineStyleModel.get('color');
|
||||
var lineCount = 0;
|
||||
lineColors = lineColors instanceof Array ? lineColors : [lineColors];
|
||||
var splitLines = [];
|
||||
for (var i = 0; i < ticksAngles.length; i++) {
|
||||
var colorIndex = lineCount++ % lineColors.length;
|
||||
splitLines[colorIndex] = splitLines[colorIndex] || [];
|
||||
splitLines[colorIndex].push(new graphic.Line({
|
||||
shape: getAxisLineShape(polar, radiusExtent, ticksAngles[i].coord)
|
||||
}));
|
||||
}
|
||||
// Simple optimization
|
||||
// Batching the lines if color are the same
|
||||
for (var i = 0; i < splitLines.length; i++) {
|
||||
group.add(graphic.mergePath(splitLines[i], {
|
||||
style: zrUtil.defaults({
|
||||
stroke: lineColors[i % lineColors.length]
|
||||
}, lineStyleModel.getLineStyle()),
|
||||
silent: true,
|
||||
z: angleAxisModel.get('z')
|
||||
}));
|
||||
}
|
||||
},
|
||||
minorSplitLine: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
|
||||
if (!minorTickAngles.length) {
|
||||
return;
|
||||
}
|
||||
var minorSplitLineModel = angleAxisModel.getModel('minorSplitLine');
|
||||
var lineStyleModel = minorSplitLineModel.getModel('lineStyle');
|
||||
var lines = [];
|
||||
for (var i = 0; i < minorTickAngles.length; i++) {
|
||||
for (var k = 0; k < minorTickAngles[i].length; k++) {
|
||||
lines.push(new graphic.Line({
|
||||
shape: getAxisLineShape(polar, radiusExtent, minorTickAngles[i][k].coord)
|
||||
}));
|
||||
}
|
||||
}
|
||||
group.add(graphic.mergePath(lines, {
|
||||
style: lineStyleModel.getLineStyle(),
|
||||
silent: true,
|
||||
z: angleAxisModel.get('z')
|
||||
}));
|
||||
},
|
||||
splitArea: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
|
||||
if (!ticksAngles.length) {
|
||||
return;
|
||||
}
|
||||
var splitAreaModel = angleAxisModel.getModel('splitArea');
|
||||
var areaStyleModel = splitAreaModel.getModel('areaStyle');
|
||||
var areaColors = areaStyleModel.get('color');
|
||||
var lineCount = 0;
|
||||
areaColors = areaColors instanceof Array ? areaColors : [areaColors];
|
||||
var splitAreas = [];
|
||||
var RADIAN = Math.PI / 180;
|
||||
var prevAngle = -ticksAngles[0].coord * RADIAN;
|
||||
var r0 = Math.min(radiusExtent[0], radiusExtent[1]);
|
||||
var r1 = Math.max(radiusExtent[0], radiusExtent[1]);
|
||||
var clockwise = angleAxisModel.get('clockwise');
|
||||
for (var i = 1, len = ticksAngles.length; i <= len; i++) {
|
||||
var coord = i === len ? ticksAngles[0].coord : ticksAngles[i].coord;
|
||||
var colorIndex = lineCount++ % areaColors.length;
|
||||
splitAreas[colorIndex] = splitAreas[colorIndex] || [];
|
||||
splitAreas[colorIndex].push(new graphic.Sector({
|
||||
shape: {
|
||||
cx: polar.cx,
|
||||
cy: polar.cy,
|
||||
r0: r0,
|
||||
r: r1,
|
||||
startAngle: prevAngle,
|
||||
endAngle: -coord * RADIAN,
|
||||
clockwise: clockwise
|
||||
},
|
||||
silent: true
|
||||
}));
|
||||
prevAngle = -coord * RADIAN;
|
||||
}
|
||||
// Simple optimization
|
||||
// Batching the lines if color are the same
|
||||
for (var i = 0; i < splitAreas.length; i++) {
|
||||
group.add(graphic.mergePath(splitAreas[i], {
|
||||
style: zrUtil.defaults({
|
||||
fill: areaColors[i % areaColors.length]
|
||||
}, areaStyleModel.getAreaStyle()),
|
||||
silent: true
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
export default AngleAxisView;
|
||||
+1032
File diff suppressed because it is too large
Load Diff
+119
@@ -0,0 +1,119 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
import * as axisPointerModelHelper from '../axisPointer/modelHelper.js';
|
||||
import ComponentView from '../../view/Component.js';
|
||||
var axisPointerClazz = {};
|
||||
/**
|
||||
* Base class of AxisView.
|
||||
*/
|
||||
var AxisView = /** @class */function (_super) {
|
||||
__extends(AxisView, _super);
|
||||
function AxisView() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.type = AxisView.type;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
AxisView.prototype.render = function (axisModel, ecModel, api, payload) {
|
||||
// FIXME
|
||||
// This process should proformed after coordinate systems updated
|
||||
// (axis scale updated), and should be performed each time update.
|
||||
// So put it here temporarily, although it is not appropriate to
|
||||
// put a model-writing procedure in `view`.
|
||||
this.axisPointerClass && axisPointerModelHelper.fixValue(axisModel);
|
||||
_super.prototype.render.apply(this, arguments);
|
||||
this._doUpdateAxisPointerClass(axisModel, api, true);
|
||||
};
|
||||
/**
|
||||
* Action handler.
|
||||
*/
|
||||
AxisView.prototype.updateAxisPointer = function (axisModel, ecModel, api, payload) {
|
||||
this._doUpdateAxisPointerClass(axisModel, api, false);
|
||||
};
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
AxisView.prototype.remove = function (ecModel, api) {
|
||||
var axisPointer = this._axisPointer;
|
||||
axisPointer && axisPointer.remove(api);
|
||||
};
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
AxisView.prototype.dispose = function (ecModel, api) {
|
||||
this._disposeAxisPointer(api);
|
||||
_super.prototype.dispose.apply(this, arguments);
|
||||
};
|
||||
AxisView.prototype._doUpdateAxisPointerClass = function (axisModel, api, forceRender) {
|
||||
var Clazz = AxisView.getAxisPointerClass(this.axisPointerClass);
|
||||
if (!Clazz) {
|
||||
return;
|
||||
}
|
||||
var axisPointerModel = axisPointerModelHelper.getAxisPointerModel(axisModel);
|
||||
axisPointerModel ? (this._axisPointer || (this._axisPointer = new Clazz())).render(axisModel, axisPointerModel, api, forceRender) : this._disposeAxisPointer(api);
|
||||
};
|
||||
AxisView.prototype._disposeAxisPointer = function (api) {
|
||||
this._axisPointer && this._axisPointer.dispose(api);
|
||||
this._axisPointer = null;
|
||||
};
|
||||
AxisView.registerAxisPointerClass = function (type, clazz) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (axisPointerClazz[type]) {
|
||||
throw new Error('axisPointer ' + type + ' exists');
|
||||
}
|
||||
}
|
||||
axisPointerClazz[type] = clazz;
|
||||
};
|
||||
;
|
||||
AxisView.getAxisPointerClass = function (type) {
|
||||
return type && axisPointerClazz[type];
|
||||
};
|
||||
;
|
||||
AxisView.type = 'axis';
|
||||
return AxisView;
|
||||
}(ComponentView);
|
||||
export default AxisView;
|
||||
+228
@@ -0,0 +1,228 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
import * as zrUtil from 'zrender/lib/core/util.js';
|
||||
import * as graphic from '../../util/graphic.js';
|
||||
import AxisView from './AxisView.js';
|
||||
import { rectCoordAxisBuildSplitArea, rectCoordAxisHandleRemove } from './axisSplitHelper.js';
|
||||
import { getAxisBreakHelper } from './axisBreakHelper.js';
|
||||
import { shouldAxisShow } from '../../coord/axisHelper.js';
|
||||
var selfBuilderAttrs = ['splitArea', 'splitLine', 'minorSplitLine', 'breakArea'];
|
||||
var CartesianAxisView = /** @class */function (_super) {
|
||||
__extends(CartesianAxisView, _super);
|
||||
function CartesianAxisView() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.type = CartesianAxisView.type;
|
||||
_this.axisPointerClass = 'CartesianAxisPointer';
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
CartesianAxisView.prototype.render = function (axisModel, ecModel, api, payload) {
|
||||
this.group.removeAll();
|
||||
var oldAxisGroup = this._axisGroup;
|
||||
this._axisGroup = new graphic.Group();
|
||||
this.group.add(this._axisGroup);
|
||||
if (!shouldAxisShow(axisModel)) {
|
||||
return;
|
||||
}
|
||||
this._axisGroup.add(axisModel.axis.axisBuilder.group);
|
||||
zrUtil.each(selfBuilderAttrs, function (name) {
|
||||
if (axisModel.get([name, 'show'])) {
|
||||
axisElementBuilders[name](this, this._axisGroup, axisModel, axisModel.getCoordSysModel(), api);
|
||||
}
|
||||
}, this);
|
||||
// THIS is a special case for bar racing chart.
|
||||
// Update the axis label from the natural initial layout to
|
||||
// sorted layout should has no animation.
|
||||
var isInitialSortFromBarRacing = payload && payload.type === 'changeAxisOrder' && payload.isInitSort;
|
||||
if (!isInitialSortFromBarRacing) {
|
||||
graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
|
||||
}
|
||||
_super.prototype.render.call(this, axisModel, ecModel, api, payload);
|
||||
};
|
||||
CartesianAxisView.prototype.remove = function () {
|
||||
rectCoordAxisHandleRemove(this);
|
||||
};
|
||||
CartesianAxisView.type = 'cartesianAxis';
|
||||
return CartesianAxisView;
|
||||
}(AxisView);
|
||||
var axisElementBuilders = {
|
||||
splitLine: function (axisView, axisGroup, axisModel, gridModel, api) {
|
||||
var axis = axisModel.axis;
|
||||
if (axis.scale.isBlank()) {
|
||||
return;
|
||||
}
|
||||
var splitLineModel = axisModel.getModel('splitLine');
|
||||
var lineStyleModel = splitLineModel.getModel('lineStyle');
|
||||
var lineColors = lineStyleModel.get('color');
|
||||
var showMinLine = splitLineModel.get('showMinLine') !== false;
|
||||
var showMaxLine = splitLineModel.get('showMaxLine') !== false;
|
||||
lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors];
|
||||
var gridRect = gridModel.coordinateSystem.getRect();
|
||||
var isHorizontal = axis.isHorizontal();
|
||||
var lineCount = 0;
|
||||
var ticksCoords = axis.getTicksCoords({
|
||||
tickModel: splitLineModel,
|
||||
breakTicks: 'none',
|
||||
pruneByBreak: 'preserve_extent_bound'
|
||||
});
|
||||
var p1 = [];
|
||||
var p2 = [];
|
||||
var lineStyle = lineStyleModel.getLineStyle();
|
||||
for (var i = 0; i < ticksCoords.length; i++) {
|
||||
var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
|
||||
if (i === 0 && !showMinLine || i === ticksCoords.length - 1 && !showMaxLine) {
|
||||
continue;
|
||||
}
|
||||
var tickValue = ticksCoords[i].tickValue;
|
||||
if (isHorizontal) {
|
||||
p1[0] = tickCoord;
|
||||
p1[1] = gridRect.y;
|
||||
p2[0] = tickCoord;
|
||||
p2[1] = gridRect.y + gridRect.height;
|
||||
} else {
|
||||
p1[0] = gridRect.x;
|
||||
p1[1] = tickCoord;
|
||||
p2[0] = gridRect.x + gridRect.width;
|
||||
p2[1] = tickCoord;
|
||||
}
|
||||
var colorIndex = lineCount++ % lineColors.length;
|
||||
var line = new graphic.Line({
|
||||
anid: tickValue != null ? 'line_' + tickValue : null,
|
||||
autoBatch: true,
|
||||
shape: {
|
||||
x1: p1[0],
|
||||
y1: p1[1],
|
||||
x2: p2[0],
|
||||
y2: p2[1]
|
||||
},
|
||||
style: zrUtil.defaults({
|
||||
stroke: lineColors[colorIndex]
|
||||
}, lineStyle),
|
||||
silent: true
|
||||
});
|
||||
graphic.subPixelOptimizeLine(line.shape, lineStyle.lineWidth);
|
||||
axisGroup.add(line);
|
||||
}
|
||||
},
|
||||
minorSplitLine: function (axisView, axisGroup, axisModel, gridModel, api) {
|
||||
var axis = axisModel.axis;
|
||||
var minorSplitLineModel = axisModel.getModel('minorSplitLine');
|
||||
var lineStyleModel = minorSplitLineModel.getModel('lineStyle');
|
||||
var gridRect = gridModel.coordinateSystem.getRect();
|
||||
var isHorizontal = axis.isHorizontal();
|
||||
var minorTicksCoords = axis.getMinorTicksCoords();
|
||||
if (!minorTicksCoords.length) {
|
||||
return;
|
||||
}
|
||||
var p1 = [];
|
||||
var p2 = [];
|
||||
var lineStyle = lineStyleModel.getLineStyle();
|
||||
for (var i = 0; i < minorTicksCoords.length; i++) {
|
||||
for (var k = 0; k < minorTicksCoords[i].length; k++) {
|
||||
var tickCoord = axis.toGlobalCoord(minorTicksCoords[i][k].coord);
|
||||
if (isHorizontal) {
|
||||
p1[0] = tickCoord;
|
||||
p1[1] = gridRect.y;
|
||||
p2[0] = tickCoord;
|
||||
p2[1] = gridRect.y + gridRect.height;
|
||||
} else {
|
||||
p1[0] = gridRect.x;
|
||||
p1[1] = tickCoord;
|
||||
p2[0] = gridRect.x + gridRect.width;
|
||||
p2[1] = tickCoord;
|
||||
}
|
||||
var line = new graphic.Line({
|
||||
anid: 'minor_line_' + minorTicksCoords[i][k].tickValue,
|
||||
autoBatch: true,
|
||||
shape: {
|
||||
x1: p1[0],
|
||||
y1: p1[1],
|
||||
x2: p2[0],
|
||||
y2: p2[1]
|
||||
},
|
||||
style: lineStyle,
|
||||
silent: true
|
||||
});
|
||||
graphic.subPixelOptimizeLine(line.shape, lineStyle.lineWidth);
|
||||
axisGroup.add(line);
|
||||
}
|
||||
}
|
||||
},
|
||||
splitArea: function (axisView, axisGroup, axisModel, gridModel, api) {
|
||||
rectCoordAxisBuildSplitArea(axisView, axisGroup, axisModel, gridModel);
|
||||
},
|
||||
breakArea: function (axisView, axisGroup, axisModel, gridModel, api) {
|
||||
var axisBreakHelper = getAxisBreakHelper();
|
||||
var scale = axisModel.axis.scale;
|
||||
if (axisBreakHelper && scale.type !== 'ordinal') {
|
||||
axisBreakHelper.rectCoordBuildBreakAxis(axisGroup, axisView, axisModel, gridModel.coordinateSystem.getRect(), api);
|
||||
}
|
||||
}
|
||||
};
|
||||
var CartesianXAxisView = /** @class */function (_super) {
|
||||
__extends(CartesianXAxisView, _super);
|
||||
function CartesianXAxisView() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.type = CartesianXAxisView.type;
|
||||
return _this;
|
||||
}
|
||||
CartesianXAxisView.type = 'xAxis';
|
||||
return CartesianXAxisView;
|
||||
}(CartesianAxisView);
|
||||
export { CartesianXAxisView };
|
||||
var CartesianYAxisView = /** @class */function (_super) {
|
||||
__extends(CartesianYAxisView, _super);
|
||||
function CartesianYAxisView() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.type = CartesianXAxisView.type;
|
||||
return _this;
|
||||
}
|
||||
CartesianYAxisView.type = 'yAxis';
|
||||
return CartesianYAxisView;
|
||||
}(CartesianAxisView);
|
||||
export { CartesianYAxisView };
|
||||
export default CartesianAxisView;
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
import * as zrUtil from 'zrender/lib/core/util.js';
|
||||
import AxisBuilder from './AxisBuilder.js';
|
||||
import BrushController from '../helper/BrushController.js';
|
||||
import * as brushHelper from '../helper/brushHelper.js';
|
||||
import * as graphic from '../../util/graphic.js';
|
||||
import ComponentView from '../../view/Component.js';
|
||||
var ParallelAxisView = /** @class */function (_super) {
|
||||
__extends(ParallelAxisView, _super);
|
||||
function ParallelAxisView() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.type = ParallelAxisView.type;
|
||||
return _this;
|
||||
}
|
||||
ParallelAxisView.prototype.init = function (ecModel, api) {
|
||||
_super.prototype.init.apply(this, arguments);
|
||||
(this._brushController = new BrushController(api.getZr())).on('brush', zrUtil.bind(this._onBrush, this));
|
||||
};
|
||||
ParallelAxisView.prototype.render = function (axisModel, ecModel, api, payload) {
|
||||
if (fromAxisAreaSelect(axisModel, ecModel, payload)) {
|
||||
return;
|
||||
}
|
||||
this.axisModel = axisModel;
|
||||
this.api = api;
|
||||
this.group.removeAll();
|
||||
var oldAxisGroup = this._axisGroup;
|
||||
this._axisGroup = new graphic.Group();
|
||||
this.group.add(this._axisGroup);
|
||||
if (!axisModel.get('show')) {
|
||||
return;
|
||||
}
|
||||
var coordSysModel = getCoordSysModel(axisModel, ecModel);
|
||||
var coordSys = coordSysModel.coordinateSystem;
|
||||
var areaSelectStyle = axisModel.getAreaSelectStyle();
|
||||
var areaWidth = areaSelectStyle.width;
|
||||
var dim = axisModel.axis.dim;
|
||||
var axisLayout = coordSys.getAxisLayout(dim);
|
||||
var builderOpt = zrUtil.extend({
|
||||
strokeContainThreshold: areaWidth
|
||||
}, axisLayout);
|
||||
var axisBuilder = new AxisBuilder(axisModel, api, builderOpt);
|
||||
axisBuilder.build();
|
||||
this._axisGroup.add(axisBuilder.group);
|
||||
this._refreshBrushController(builderOpt, areaSelectStyle, axisModel, coordSysModel, areaWidth, api);
|
||||
graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
|
||||
};
|
||||
// /**
|
||||
// * @override
|
||||
// */
|
||||
// updateVisual(axisModel, ecModel, api, payload) {
|
||||
// this._brushController && this._brushController
|
||||
// .updateCovers(getCoverInfoList(axisModel));
|
||||
// }
|
||||
ParallelAxisView.prototype._refreshBrushController = function (builderOpt, areaSelectStyle, axisModel, coordSysModel, areaWidth, api) {
|
||||
// After filtering, axis may change, select area needs to be update.
|
||||
var extent = axisModel.axis.getExtent();
|
||||
var extentLen = extent[1] - extent[0];
|
||||
var extra = Math.min(30, Math.abs(extentLen) * 0.1); // Arbitrary value.
|
||||
// width/height might be negative, which will be
|
||||
// normalized in BoundingRect.
|
||||
var rect = graphic.BoundingRect.create({
|
||||
x: extent[0],
|
||||
y: -areaWidth / 2,
|
||||
width: extentLen,
|
||||
height: areaWidth
|
||||
});
|
||||
rect.x -= extra;
|
||||
rect.width += 2 * extra;
|
||||
this._brushController.mount({
|
||||
enableGlobalPan: true,
|
||||
rotation: builderOpt.rotation,
|
||||
x: builderOpt.position[0],
|
||||
y: builderOpt.position[1]
|
||||
}).setPanels([{
|
||||
panelId: 'pl',
|
||||
clipPath: brushHelper.makeRectPanelClipPath(rect),
|
||||
isTargetByCursor: brushHelper.makeRectIsTargetByCursor(rect, api, coordSysModel),
|
||||
getLinearBrushOtherExtent: brushHelper.makeLinearBrushOtherExtent(rect, 0)
|
||||
}]).enableBrush({
|
||||
brushType: 'lineX',
|
||||
brushStyle: areaSelectStyle,
|
||||
removeOnClick: true
|
||||
}).updateCovers(getCoverInfoList(axisModel));
|
||||
};
|
||||
ParallelAxisView.prototype._onBrush = function (eventParam) {
|
||||
var coverInfoList = eventParam.areas;
|
||||
// Do not cache these object, because the mey be changed.
|
||||
var axisModel = this.axisModel;
|
||||
var axis = axisModel.axis;
|
||||
var intervals = zrUtil.map(coverInfoList, function (coverInfo) {
|
||||
return [axis.coordToData(coverInfo.range[0], true), axis.coordToData(coverInfo.range[1], true)];
|
||||
});
|
||||
// If realtime is true, action is not dispatched on drag end, because
|
||||
// the drag end emits the same params with the last drag move event,
|
||||
// and may have some delay when using touch pad.
|
||||
if (!axisModel.option.realtime === eventParam.isEnd || eventParam.removeOnClick) {
|
||||
// jshint ignore:line
|
||||
this.api.dispatchAction({
|
||||
type: 'axisAreaSelect',
|
||||
parallelAxisId: axisModel.id,
|
||||
intervals: intervals
|
||||
});
|
||||
}
|
||||
};
|
||||
ParallelAxisView.prototype.dispose = function () {
|
||||
this._brushController.dispose();
|
||||
};
|
||||
ParallelAxisView.type = 'parallelAxis';
|
||||
return ParallelAxisView;
|
||||
}(ComponentView);
|
||||
function fromAxisAreaSelect(axisModel, ecModel, payload) {
|
||||
return payload && payload.type === 'axisAreaSelect' && ecModel.findComponents({
|
||||
mainType: 'parallelAxis',
|
||||
query: payload
|
||||
})[0] === axisModel;
|
||||
}
|
||||
function getCoverInfoList(axisModel) {
|
||||
var axis = axisModel.axis;
|
||||
return zrUtil.map(axisModel.activeIntervals, function (interval) {
|
||||
return {
|
||||
brushType: 'lineX',
|
||||
panelId: 'pl',
|
||||
range: [axis.dataToCoord(interval[0], true), axis.dataToCoord(interval[1], true)]
|
||||
};
|
||||
});
|
||||
}
|
||||
function getCoordSysModel(axisModel, ecModel) {
|
||||
return ecModel.getComponent('parallel', axisModel.get('parallelIndex'));
|
||||
}
|
||||
export default ParallelAxisView;
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
import * as zrUtil from 'zrender/lib/core/util.js';
|
||||
import * as graphic from '../../util/graphic.js';
|
||||
import AxisBuilder from './AxisBuilder.js';
|
||||
import AxisView from './AxisView.js';
|
||||
var selfBuilderAttrs = ['splitLine', 'splitArea', 'minorSplitLine'];
|
||||
var RadiusAxisView = /** @class */function (_super) {
|
||||
__extends(RadiusAxisView, _super);
|
||||
function RadiusAxisView() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.type = RadiusAxisView.type;
|
||||
_this.axisPointerClass = 'PolarAxisPointer';
|
||||
return _this;
|
||||
}
|
||||
RadiusAxisView.prototype.render = function (radiusAxisModel, ecModel, api) {
|
||||
this.group.removeAll();
|
||||
if (!radiusAxisModel.get('show')) {
|
||||
return;
|
||||
}
|
||||
var oldAxisGroup = this._axisGroup;
|
||||
var newAxisGroup = this._axisGroup = new graphic.Group();
|
||||
this.group.add(newAxisGroup);
|
||||
var radiusAxis = radiusAxisModel.axis;
|
||||
var polar = radiusAxis.polar;
|
||||
var angleAxis = polar.getAngleAxis();
|
||||
var ticksCoords = radiusAxis.getTicksCoords();
|
||||
var minorTicksCoords = radiusAxis.getMinorTicksCoords();
|
||||
var axisAngle = angleAxis.getExtent()[0];
|
||||
var radiusExtent = radiusAxis.getExtent();
|
||||
var layout = layoutAxis(polar, radiusAxisModel, axisAngle);
|
||||
var axisBuilder = new AxisBuilder(radiusAxisModel, api, layout);
|
||||
axisBuilder.build();
|
||||
newAxisGroup.add(axisBuilder.group);
|
||||
graphic.groupTransition(oldAxisGroup, newAxisGroup, radiusAxisModel);
|
||||
zrUtil.each(selfBuilderAttrs, function (name) {
|
||||
if (radiusAxisModel.get([name, 'show']) && !radiusAxis.scale.isBlank()) {
|
||||
axisElementBuilders[name](this.group, radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords, minorTicksCoords);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
RadiusAxisView.type = 'radiusAxis';
|
||||
return RadiusAxisView;
|
||||
}(AxisView);
|
||||
var axisElementBuilders = {
|
||||
splitLine: function (group, radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
|
||||
var splitLineModel = radiusAxisModel.getModel('splitLine');
|
||||
var lineStyleModel = splitLineModel.getModel('lineStyle');
|
||||
var lineColors = lineStyleModel.get('color');
|
||||
var lineCount = 0;
|
||||
var angleAxis = polar.getAngleAxis();
|
||||
var RADIAN = Math.PI / 180;
|
||||
var angleExtent = angleAxis.getExtent();
|
||||
var shapeType = Math.abs(angleExtent[1] - angleExtent[0]) === 360 ? 'Circle' : 'Arc';
|
||||
lineColors = lineColors instanceof Array ? lineColors : [lineColors];
|
||||
var splitLines = [];
|
||||
for (var i = 0; i < ticksCoords.length; i++) {
|
||||
var colorIndex = lineCount++ % lineColors.length;
|
||||
splitLines[colorIndex] = splitLines[colorIndex] || [];
|
||||
splitLines[colorIndex].push(new graphic[shapeType]({
|
||||
shape: {
|
||||
cx: polar.cx,
|
||||
cy: polar.cy,
|
||||
// ensure circle radius >= 0
|
||||
r: Math.max(ticksCoords[i].coord, 0),
|
||||
startAngle: -angleExtent[0] * RADIAN,
|
||||
endAngle: -angleExtent[1] * RADIAN,
|
||||
clockwise: angleAxis.inverse
|
||||
}
|
||||
}));
|
||||
}
|
||||
// Simple optimization
|
||||
// Batching the lines if color are the same
|
||||
for (var i = 0; i < splitLines.length; i++) {
|
||||
group.add(graphic.mergePath(splitLines[i], {
|
||||
style: zrUtil.defaults({
|
||||
stroke: lineColors[i % lineColors.length],
|
||||
fill: null
|
||||
}, lineStyleModel.getLineStyle()),
|
||||
silent: true
|
||||
}));
|
||||
}
|
||||
},
|
||||
minorSplitLine: function (group, radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords, minorTicksCoords) {
|
||||
if (!minorTicksCoords.length) {
|
||||
return;
|
||||
}
|
||||
var minorSplitLineModel = radiusAxisModel.getModel('minorSplitLine');
|
||||
var lineStyleModel = minorSplitLineModel.getModel('lineStyle');
|
||||
var lines = [];
|
||||
for (var i = 0; i < minorTicksCoords.length; i++) {
|
||||
for (var k = 0; k < minorTicksCoords[i].length; k++) {
|
||||
lines.push(new graphic.Circle({
|
||||
shape: {
|
||||
cx: polar.cx,
|
||||
cy: polar.cy,
|
||||
r: minorTicksCoords[i][k].coord
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
group.add(graphic.mergePath(lines, {
|
||||
style: zrUtil.defaults({
|
||||
fill: null
|
||||
}, lineStyleModel.getLineStyle()),
|
||||
silent: true
|
||||
}));
|
||||
},
|
||||
splitArea: function (group, radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
|
||||
if (!ticksCoords.length) {
|
||||
return;
|
||||
}
|
||||
var splitAreaModel = radiusAxisModel.getModel('splitArea');
|
||||
var areaStyleModel = splitAreaModel.getModel('areaStyle');
|
||||
var areaColors = areaStyleModel.get('color');
|
||||
var lineCount = 0;
|
||||
areaColors = areaColors instanceof Array ? areaColors : [areaColors];
|
||||
var splitAreas = [];
|
||||
var prevRadius = ticksCoords[0].coord;
|
||||
for (var i = 1; i < ticksCoords.length; i++) {
|
||||
var colorIndex = lineCount++ % areaColors.length;
|
||||
splitAreas[colorIndex] = splitAreas[colorIndex] || [];
|
||||
splitAreas[colorIndex].push(new graphic.Sector({
|
||||
shape: {
|
||||
cx: polar.cx,
|
||||
cy: polar.cy,
|
||||
r0: prevRadius,
|
||||
r: ticksCoords[i].coord,
|
||||
startAngle: 0,
|
||||
endAngle: Math.PI * 2
|
||||
},
|
||||
silent: true
|
||||
}));
|
||||
prevRadius = ticksCoords[i].coord;
|
||||
}
|
||||
// Simple optimization
|
||||
// Batching the lines if color are the same
|
||||
for (var i = 0; i < splitAreas.length; i++) {
|
||||
group.add(graphic.mergePath(splitAreas[i], {
|
||||
style: zrUtil.defaults({
|
||||
fill: areaColors[i % areaColors.length]
|
||||
}, areaStyleModel.getAreaStyle()),
|
||||
silent: true
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @inner
|
||||
*/
|
||||
function layoutAxis(polar, radiusAxisModel, axisAngle) {
|
||||
return {
|
||||
position: [polar.cx, polar.cy],
|
||||
rotation: axisAngle / 180 * Math.PI,
|
||||
labelDirection: -1,
|
||||
tickDirection: -1,
|
||||
nameDirection: 1,
|
||||
labelRotate: radiusAxisModel.getModel('axisLabel').get('rotate'),
|
||||
// Over splitLine and splitArea
|
||||
z2: 1
|
||||
};
|
||||
}
|
||||
export default RadiusAxisView;
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
import * as zrUtil from 'zrender/lib/core/util.js';
|
||||
import AxisBuilder from './AxisBuilder.js';
|
||||
import * as graphic from '../../util/graphic.js';
|
||||
import * as singleAxisHelper from '../../coord/single/singleAxisHelper.js';
|
||||
import AxisView from './AxisView.js';
|
||||
import { rectCoordAxisBuildSplitArea, rectCoordAxisHandleRemove } from './axisSplitHelper.js';
|
||||
import { getAxisBreakHelper } from './axisBreakHelper.js';
|
||||
var selfBuilderAttrs = ['splitArea', 'splitLine', 'breakArea'];
|
||||
var SingleAxisView = /** @class */function (_super) {
|
||||
__extends(SingleAxisView, _super);
|
||||
function SingleAxisView() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.type = SingleAxisView.type;
|
||||
_this.axisPointerClass = 'SingleAxisPointer';
|
||||
return _this;
|
||||
}
|
||||
SingleAxisView.prototype.render = function (axisModel, ecModel, api, payload) {
|
||||
var group = this.group;
|
||||
group.removeAll();
|
||||
var oldAxisGroup = this._axisGroup;
|
||||
this._axisGroup = new graphic.Group();
|
||||
var layout = singleAxisHelper.layout(axisModel);
|
||||
var axisBuilder = new AxisBuilder(axisModel, api, layout);
|
||||
axisBuilder.build();
|
||||
group.add(this._axisGroup);
|
||||
group.add(axisBuilder.group);
|
||||
zrUtil.each(selfBuilderAttrs, function (name) {
|
||||
if (axisModel.get([name, 'show'])) {
|
||||
axisElementBuilders[name](this, this.group, this._axisGroup, axisModel, api);
|
||||
}
|
||||
}, this);
|
||||
graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
|
||||
_super.prototype.render.call(this, axisModel, ecModel, api, payload);
|
||||
};
|
||||
SingleAxisView.prototype.remove = function () {
|
||||
rectCoordAxisHandleRemove(this);
|
||||
};
|
||||
SingleAxisView.type = 'singleAxis';
|
||||
return SingleAxisView;
|
||||
}(AxisView);
|
||||
var axisElementBuilders = {
|
||||
splitLine: function (axisView, group, axisGroup, axisModel, api) {
|
||||
var axis = axisModel.axis;
|
||||
if (axis.scale.isBlank()) {
|
||||
return;
|
||||
}
|
||||
var splitLineModel = axisModel.getModel('splitLine');
|
||||
var lineStyleModel = splitLineModel.getModel('lineStyle');
|
||||
var lineColors = lineStyleModel.get('color');
|
||||
lineColors = lineColors instanceof Array ? lineColors : [lineColors];
|
||||
var lineWidth = lineStyleModel.get('width');
|
||||
var gridRect = axisModel.coordinateSystem.getRect();
|
||||
var isHorizontal = axis.isHorizontal();
|
||||
var splitLines = [];
|
||||
var lineCount = 0;
|
||||
var ticksCoords = axis.getTicksCoords({
|
||||
tickModel: splitLineModel,
|
||||
breakTicks: 'none',
|
||||
pruneByBreak: 'preserve_extent_bound'
|
||||
});
|
||||
var p1 = [];
|
||||
var p2 = [];
|
||||
for (var i = 0; i < ticksCoords.length; ++i) {
|
||||
var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
|
||||
if (isHorizontal) {
|
||||
p1[0] = tickCoord;
|
||||
p1[1] = gridRect.y;
|
||||
p2[0] = tickCoord;
|
||||
p2[1] = gridRect.y + gridRect.height;
|
||||
} else {
|
||||
p1[0] = gridRect.x;
|
||||
p1[1] = tickCoord;
|
||||
p2[0] = gridRect.x + gridRect.width;
|
||||
p2[1] = tickCoord;
|
||||
}
|
||||
var line = new graphic.Line({
|
||||
shape: {
|
||||
x1: p1[0],
|
||||
y1: p1[1],
|
||||
x2: p2[0],
|
||||
y2: p2[1]
|
||||
},
|
||||
silent: true
|
||||
});
|
||||
graphic.subPixelOptimizeLine(line.shape, lineWidth);
|
||||
var colorIndex = lineCount++ % lineColors.length;
|
||||
splitLines[colorIndex] = splitLines[colorIndex] || [];
|
||||
splitLines[colorIndex].push(line);
|
||||
}
|
||||
var lineStyle = lineStyleModel.getLineStyle(['color']);
|
||||
for (var i = 0; i < splitLines.length; ++i) {
|
||||
group.add(graphic.mergePath(splitLines[i], {
|
||||
style: zrUtil.defaults({
|
||||
stroke: lineColors[i % lineColors.length]
|
||||
}, lineStyle),
|
||||
silent: true
|
||||
}));
|
||||
}
|
||||
},
|
||||
splitArea: function (axisView, group, axisGroup, axisModel, api) {
|
||||
rectCoordAxisBuildSplitArea(axisView, axisGroup, axisModel, axisModel);
|
||||
},
|
||||
breakArea: function (axisView, group, axisGroup, axisModel, api) {
|
||||
var axisBreakHelper = getAxisBreakHelper();
|
||||
var scale = axisModel.axis.scale;
|
||||
if (axisBreakHelper && scale.type !== 'ordinal') {
|
||||
axisBreakHelper.rectCoordBuildBreakAxis(group, axisView, axisModel, axisModel.coordinateSystem.getRect(), api);
|
||||
}
|
||||
}
|
||||
};
|
||||
export default SingleAxisView;
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { parseFinder } from '../../util/model.js';
|
||||
import { defaults, each } from 'zrender/lib/core/util.js';
|
||||
export var AXIS_BREAK_EXPAND_ACTION_TYPE = 'expandAxisBreak';
|
||||
export var AXIS_BREAK_COLLAPSE_ACTION_TYPE = 'collapseAxisBreak';
|
||||
export var AXIS_BREAK_TOGGLE_ACTION_TYPE = 'toggleAxisBreak';
|
||||
var AXIS_BREAK_CHANGED_EVENT_TYPE = 'axisbreakchanged';
|
||||
var expandAxisBreakActionInfo = {
|
||||
type: AXIS_BREAK_EXPAND_ACTION_TYPE,
|
||||
event: AXIS_BREAK_CHANGED_EVENT_TYPE,
|
||||
update: 'update',
|
||||
refineEvent: refineAxisBreakChangeEvent
|
||||
};
|
||||
var collapseAxisBreakActionInfo = {
|
||||
type: AXIS_BREAK_COLLAPSE_ACTION_TYPE,
|
||||
event: AXIS_BREAK_CHANGED_EVENT_TYPE,
|
||||
update: 'update',
|
||||
refineEvent: refineAxisBreakChangeEvent
|
||||
};
|
||||
var toggleAxisBreakActionInfo = {
|
||||
type: AXIS_BREAK_TOGGLE_ACTION_TYPE,
|
||||
event: AXIS_BREAK_CHANGED_EVENT_TYPE,
|
||||
update: 'update',
|
||||
refineEvent: refineAxisBreakChangeEvent
|
||||
};
|
||||
function refineAxisBreakChangeEvent(actionResultBatch, payload, ecModel, api) {
|
||||
var breaks = [];
|
||||
each(actionResultBatch, function (actionResult) {
|
||||
breaks = breaks.concat(actionResult.eventBreaks);
|
||||
});
|
||||
return {
|
||||
eventContent: {
|
||||
breaks: breaks
|
||||
}
|
||||
};
|
||||
}
|
||||
export function registerAction(registers) {
|
||||
registers.registerAction(expandAxisBreakActionInfo, actionHandler);
|
||||
registers.registerAction(collapseAxisBreakActionInfo, actionHandler);
|
||||
registers.registerAction(toggleAxisBreakActionInfo, actionHandler);
|
||||
function actionHandler(payload, ecModel) {
|
||||
var eventBreaks = [];
|
||||
var finderResult = parseFinder(ecModel, payload);
|
||||
function dealUpdate(modelProp, indexProp) {
|
||||
each(finderResult[modelProp], function (axisModel) {
|
||||
var result = axisModel.updateAxisBreaks(payload);
|
||||
each(result.breaks, function (item) {
|
||||
var _a;
|
||||
eventBreaks.push(defaults((_a = {}, _a[indexProp] = axisModel.componentIndex, _a), item));
|
||||
});
|
||||
});
|
||||
}
|
||||
dealUpdate('xAxisModels', 'xAxisIndex');
|
||||
dealUpdate('yAxisModels', 'yAxisIndex');
|
||||
dealUpdate('singleAxisModels', 'singleAxisIndex');
|
||||
return {
|
||||
eventBreaks: eventBreaks
|
||||
};
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var _impl = null;
|
||||
export function registerAxisBreakHelperImpl(impl) {
|
||||
if (!_impl) {
|
||||
_impl = impl;
|
||||
}
|
||||
}
|
||||
export function getAxisBreakHelper() {
|
||||
return _impl;
|
||||
}
|
||||
+473
@@ -0,0 +1,473 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { makeInner } from '../../util/model.js';
|
||||
import { assert, each, extend, find, map } from 'zrender/lib/core/util.js';
|
||||
import { getScaleBreakHelper } from '../../scale/break.js';
|
||||
import { subPixelOptimizeLine } from 'zrender/lib/graphic/helper/subPixelOptimize.js';
|
||||
import { applyTransform } from 'zrender/lib/core/vector.js';
|
||||
import * as matrixUtil from 'zrender/lib/core/matrix.js';
|
||||
import { AXIS_BREAK_COLLAPSE_ACTION_TYPE, AXIS_BREAK_EXPAND_ACTION_TYPE, AXIS_BREAK_TOGGLE_ACTION_TYPE } from './axisAction.js';
|
||||
import { labelIntersect, labelLayoutApplyTranslation } from '../../label/labelLayoutHelper.js';
|
||||
import { registerAxisBreakHelperImpl } from './axisBreakHelper.js';
|
||||
import { warn } from '../../util/log.js';
|
||||
import { Group, Line, Point, Polygon, Polyline, WH, XY } from '../../util/graphic.js';
|
||||
/**
|
||||
* @caution
|
||||
* Must not export anything except `installAxisBreakHelper`
|
||||
*/
|
||||
/**
|
||||
* The zigzag shapes for axis breaks are generated according to some random
|
||||
* factors. It should persist as much as possible to avoid constantly
|
||||
* changing by every user operation.
|
||||
*/
|
||||
var viewCache = makeInner();
|
||||
function ensureVisualInCache(visualList, targetBreak) {
|
||||
var visual = find(visualList, function (item) {
|
||||
return getScaleBreakHelper().identifyAxisBreak(item.parsedBreak.breakOption, targetBreak.breakOption);
|
||||
});
|
||||
if (!visual) {
|
||||
visualList.push(visual = {
|
||||
zigzagRandomList: [],
|
||||
parsedBreak: targetBreak,
|
||||
shouldRemove: false
|
||||
});
|
||||
}
|
||||
return visual;
|
||||
}
|
||||
function resetCacheVisualRemoveFlag(visualList) {
|
||||
each(visualList, function (item) {
|
||||
return item.shouldRemove = true;
|
||||
});
|
||||
}
|
||||
function removeUnusedCacheVisual(visualList) {
|
||||
for (var i = visualList.length - 1; i >= 0; i--) {
|
||||
if (visualList[i].shouldRemove) {
|
||||
visualList.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
function rectCoordBuildBreakAxis(axisGroup, axisView, axisModel, coordSysRect, api) {
|
||||
var axis = axisModel.axis;
|
||||
if (axis.scale.isBlank() || !getScaleBreakHelper()) {
|
||||
return;
|
||||
}
|
||||
var breakPairs = getScaleBreakHelper().retrieveAxisBreakPairs(axis.scale.getTicks({
|
||||
breakTicks: 'only_break'
|
||||
}), function (tick) {
|
||||
return tick["break"];
|
||||
}, false);
|
||||
if (!breakPairs.length) {
|
||||
return;
|
||||
}
|
||||
var breakAreaModel = axisModel.getModel('breakArea');
|
||||
var zigzagAmplitude = breakAreaModel.get('zigzagAmplitude');
|
||||
var zigzagMinSpan = breakAreaModel.get('zigzagMinSpan');
|
||||
var zigzagMaxSpan = breakAreaModel.get('zigzagMaxSpan');
|
||||
// Use arbitrary value to avoid dead loop if user gives inappropriate settings.
|
||||
zigzagMinSpan = Math.max(2, zigzagMinSpan || 0);
|
||||
zigzagMaxSpan = Math.max(zigzagMinSpan, zigzagMaxSpan || 0);
|
||||
var expandOnClick = breakAreaModel.get('expandOnClick');
|
||||
var zigzagZ = breakAreaModel.get('zigzagZ');
|
||||
var itemStyleModel = breakAreaModel.getModel('itemStyle');
|
||||
var itemStyle = itemStyleModel.getItemStyle();
|
||||
var borderColor = itemStyle.stroke;
|
||||
var borderWidth = itemStyle.lineWidth;
|
||||
var borderType = itemStyle.lineDash;
|
||||
var color = itemStyle.fill;
|
||||
var group = new Group({
|
||||
ignoreModelZ: true
|
||||
});
|
||||
var isAxisHorizontal = axis.isHorizontal();
|
||||
var cachedVisualList = viewCache(axisView).visualList || (viewCache(axisView).visualList = []);
|
||||
resetCacheVisualRemoveFlag(cachedVisualList);
|
||||
var _loop_1 = function (i) {
|
||||
var parsedBreak = breakPairs[i][0]["break"].parsedBreak;
|
||||
// Even if brk.gap is 0, we should also draw the breakArea because
|
||||
// border is sometimes required to be visible (as a line)
|
||||
var coords = [];
|
||||
coords[0] = axis.toGlobalCoord(axis.dataToCoord(parsedBreak.vmin, true));
|
||||
coords[1] = axis.toGlobalCoord(axis.dataToCoord(parsedBreak.vmax, true));
|
||||
if (coords[1] < coords[0]) {
|
||||
coords.reverse();
|
||||
}
|
||||
var cachedVisual = ensureVisualInCache(cachedVisualList, parsedBreak);
|
||||
cachedVisual.shouldRemove = false;
|
||||
var breakGroup = new Group();
|
||||
addZigzagShapes(cachedVisual.zigzagRandomList, breakGroup, coords[0], coords[1], isAxisHorizontal, parsedBreak);
|
||||
if (expandOnClick) {
|
||||
breakGroup.on('click', function () {
|
||||
var payload = {
|
||||
type: AXIS_BREAK_EXPAND_ACTION_TYPE,
|
||||
breaks: [{
|
||||
start: parsedBreak.breakOption.start,
|
||||
end: parsedBreak.breakOption.end
|
||||
}]
|
||||
};
|
||||
payload[axis.dim + "AxisIndex"] = axisModel.componentIndex;
|
||||
api.dispatchAction(payload);
|
||||
});
|
||||
}
|
||||
breakGroup.silent = !expandOnClick;
|
||||
group.add(breakGroup);
|
||||
};
|
||||
for (var i = 0; i < breakPairs.length; i++) {
|
||||
_loop_1(i);
|
||||
}
|
||||
axisGroup.add(group);
|
||||
removeUnusedCacheVisual(cachedVisualList);
|
||||
function addZigzagShapes(zigzagRandomList, breakGroup, startCoord, endCoord, isAxisHorizontal, trimmedBreak) {
|
||||
var polylineStyle = {
|
||||
stroke: borderColor,
|
||||
lineWidth: borderWidth,
|
||||
lineDash: borderType,
|
||||
fill: 'none'
|
||||
};
|
||||
var dimBrk = isAxisHorizontal ? 0 : 1;
|
||||
var dimZigzag = 1 - dimBrk;
|
||||
var zigzagCoordMax = coordSysRect[XY[dimZigzag]] + coordSysRect[WH[dimZigzag]];
|
||||
// Apply `subPixelOptimizeLine` for alignning with break ticks.
|
||||
function subPixelOpt(brkCoord) {
|
||||
var pBrk = [];
|
||||
var dummyP = [];
|
||||
pBrk[dimBrk] = dummyP[dimBrk] = brkCoord;
|
||||
pBrk[dimZigzag] = coordSysRect[XY[dimZigzag]];
|
||||
dummyP[dimZigzag] = zigzagCoordMax;
|
||||
var dummyShape = {
|
||||
x1: pBrk[0],
|
||||
y1: pBrk[1],
|
||||
x2: dummyP[0],
|
||||
y2: dummyP[1]
|
||||
};
|
||||
subPixelOptimizeLine(dummyShape, dummyShape, {
|
||||
lineWidth: 1
|
||||
});
|
||||
pBrk[0] = dummyShape.x1;
|
||||
pBrk[1] = dummyShape.y1;
|
||||
return pBrk[dimBrk];
|
||||
}
|
||||
startCoord = subPixelOpt(startCoord);
|
||||
endCoord = subPixelOpt(endCoord);
|
||||
var pointsA = [];
|
||||
var pointsB = [];
|
||||
var isSwap = true;
|
||||
var current = coordSysRect[XY[dimZigzag]];
|
||||
for (var idx = 0;; idx++) {
|
||||
// Use `isFirstPoint` `isLastPoint` to ensure the intersections between zigzag
|
||||
// and axis are precise, thus it can join its axis tick correctly.
|
||||
var isFirstPoint = current === coordSysRect[XY[dimZigzag]];
|
||||
var isLastPoint = current >= zigzagCoordMax;
|
||||
if (isLastPoint) {
|
||||
current = zigzagCoordMax;
|
||||
}
|
||||
var pA = [];
|
||||
var pB = [];
|
||||
pA[dimBrk] = startCoord;
|
||||
pB[dimBrk] = endCoord;
|
||||
if (!isFirstPoint && !isLastPoint) {
|
||||
pA[dimBrk] += isSwap ? -zigzagAmplitude : zigzagAmplitude;
|
||||
pB[dimBrk] -= !isSwap ? -zigzagAmplitude : zigzagAmplitude;
|
||||
}
|
||||
pA[dimZigzag] = current;
|
||||
pB[dimZigzag] = current;
|
||||
pointsA.push(pA);
|
||||
pointsB.push(pB);
|
||||
var randomVal = void 0;
|
||||
if (idx < zigzagRandomList.length) {
|
||||
randomVal = zigzagRandomList[idx];
|
||||
} else {
|
||||
randomVal = Math.random();
|
||||
zigzagRandomList.push(randomVal);
|
||||
}
|
||||
current += randomVal * (zigzagMaxSpan - zigzagMinSpan) + zigzagMinSpan;
|
||||
isSwap = !isSwap;
|
||||
if (isLastPoint) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
var anidSuffix = getScaleBreakHelper().serializeAxisBreakIdentifier(trimmedBreak.breakOption);
|
||||
// Create two polylines and add them to the breakGroup
|
||||
breakGroup.add(new Polyline({
|
||||
anid: "break_a_" + anidSuffix,
|
||||
shape: {
|
||||
points: pointsA
|
||||
},
|
||||
style: polylineStyle,
|
||||
z: zigzagZ
|
||||
}));
|
||||
/* Add the second polyline and a polygon only if the gap is not zero
|
||||
* Otherwise if the polyline is with dashed line or being opaque,
|
||||
* it may not be constant with breaks with non-zero gaps. */
|
||||
if (trimmedBreak.gapReal !== 0) {
|
||||
breakGroup.add(new Polyline({
|
||||
anid: "break_b_" + anidSuffix,
|
||||
shape: {
|
||||
// Not reverse to keep the dash stable when dragging resizing.
|
||||
points: pointsB
|
||||
},
|
||||
style: polylineStyle,
|
||||
z: zigzagZ
|
||||
}));
|
||||
// Creating the polygon that fills the area between the polylines
|
||||
// From end to start for polygon.
|
||||
var pointsB2 = pointsB.slice();
|
||||
pointsB2.reverse();
|
||||
var polygonPoints = pointsA.concat(pointsB2);
|
||||
breakGroup.add(new Polygon({
|
||||
anid: "break_c_" + anidSuffix,
|
||||
shape: {
|
||||
points: polygonPoints
|
||||
},
|
||||
style: {
|
||||
fill: color,
|
||||
opacity: itemStyle.opacity
|
||||
},
|
||||
z: zigzagZ
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
function buildAxisBreakLine(axisModel, group, transformGroup, pathBaseProp) {
|
||||
var axis = axisModel.axis;
|
||||
var transform = transformGroup.transform;
|
||||
assert(pathBaseProp.style);
|
||||
var extent = axis.getExtent();
|
||||
if (axis.inverse) {
|
||||
extent = extent.slice();
|
||||
extent.reverse();
|
||||
}
|
||||
var breakPairs = getScaleBreakHelper().retrieveAxisBreakPairs(axis.scale.getTicks({
|
||||
breakTicks: 'only_break'
|
||||
}), function (tick) {
|
||||
return tick["break"];
|
||||
}, false);
|
||||
var brkLayoutList = map(breakPairs, function (breakPair) {
|
||||
var parsedBreak = breakPair[0]["break"].parsedBreak;
|
||||
var coordPair = [axis.dataToCoord(parsedBreak.vmin, true), axis.dataToCoord(parsedBreak.vmax, true)];
|
||||
coordPair[0] > coordPair[1] && coordPair.reverse();
|
||||
return {
|
||||
coordPair: coordPair,
|
||||
brkId: getScaleBreakHelper().serializeAxisBreakIdentifier(parsedBreak.breakOption)
|
||||
};
|
||||
});
|
||||
brkLayoutList.sort(function (layout1, layout2) {
|
||||
return layout1.coordPair[0] - layout2.coordPair[0];
|
||||
});
|
||||
var ySegMin = extent[0];
|
||||
var lastLayout = null;
|
||||
for (var idx = 0; idx < brkLayoutList.length; idx++) {
|
||||
var layout = brkLayoutList[idx];
|
||||
var brkTirmmedMin = Math.max(layout.coordPair[0], extent[0]);
|
||||
var brkTirmmedMax = Math.min(layout.coordPair[1], extent[1]);
|
||||
if (ySegMin <= brkTirmmedMin) {
|
||||
addSeg(ySegMin, brkTirmmedMin, lastLayout, layout);
|
||||
}
|
||||
ySegMin = brkTirmmedMax;
|
||||
lastLayout = layout;
|
||||
}
|
||||
if (ySegMin <= extent[1]) {
|
||||
addSeg(ySegMin, extent[1], lastLayout, null);
|
||||
}
|
||||
function addSeg(min, max, layout1, layout2) {
|
||||
function trans(p1, p2) {
|
||||
if (transform) {
|
||||
applyTransform(p1, p1, transform);
|
||||
applyTransform(p2, p2, transform);
|
||||
}
|
||||
}
|
||||
function subPixelOptimizePP(p1, p2) {
|
||||
var shape = {
|
||||
x1: p1[0],
|
||||
y1: p1[1],
|
||||
x2: p2[0],
|
||||
y2: p2[1]
|
||||
};
|
||||
subPixelOptimizeLine(shape, shape, pathBaseProp.style);
|
||||
p1[0] = shape.x1;
|
||||
p1[1] = shape.y1;
|
||||
p2[0] = shape.x2;
|
||||
p2[1] = shape.y2;
|
||||
}
|
||||
var lineP1 = [min, 0];
|
||||
var lineP2 = [max, 0];
|
||||
// dummy tick is used to align the line segment ends with axis ticks
|
||||
// after `subPixelOptimizeLine` being applied.
|
||||
var dummyTickEnd1 = [min, 5];
|
||||
var dummyTickEnd2 = [max, 5];
|
||||
trans(lineP1, dummyTickEnd1);
|
||||
subPixelOptimizePP(lineP1, dummyTickEnd1);
|
||||
trans(lineP2, dummyTickEnd2);
|
||||
subPixelOptimizePP(lineP2, dummyTickEnd2);
|
||||
// Apply it keeping the same as the normal axis line.
|
||||
subPixelOptimizePP(lineP1, lineP2);
|
||||
var seg = new Line(extend({
|
||||
shape: {
|
||||
x1: lineP1[0],
|
||||
y1: lineP1[1],
|
||||
x2: lineP2[0],
|
||||
y2: lineP2[1]
|
||||
}
|
||||
}, pathBaseProp));
|
||||
group.add(seg);
|
||||
// Animation should be precise to be consistent with tick and split line animation.
|
||||
seg.anid = "breakLine_" + (layout1 ? layout1.brkId : '\0') + "_\0_" + (layout2 ? layout2.brkId : '\0');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Resolve the overlap of a pair of labels.
|
||||
*
|
||||
* [CAUTION] Only label.x/y are allowed to change.
|
||||
*/
|
||||
function adjustBreakLabelPair(axisInverse, axisRotation, layoutPair) {
|
||||
if (find(layoutPair, function (item) {
|
||||
return !item;
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
var mtv = new Point();
|
||||
if (!labelIntersect(layoutPair[0], layoutPair[1], mtv, {
|
||||
// Assert `labelPair` is `[break_min, break_max]`.
|
||||
// `axis.inverse: true` means a smaller scale value corresponds to a bigger value in axis.extent.
|
||||
// The axisRotation indicates mtv direction of OBB intersecting.
|
||||
direction: -(axisInverse ? axisRotation + Math.PI : axisRotation),
|
||||
touchThreshold: 0,
|
||||
// If need to resovle intersection align axis by moving labels according to MTV,
|
||||
// the direction must not be opposite, otherwise cause misleading.
|
||||
bidirectional: false
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
// Rotate axis back to (1, 0) direction, to be a standard axis.
|
||||
var axisStTrans = matrixUtil.create();
|
||||
matrixUtil.rotate(axisStTrans, axisStTrans, -axisRotation);
|
||||
var labelPairStTrans = map(layoutPair, function (layout) {
|
||||
return layout.transform ? matrixUtil.mul(matrixUtil.create(), axisStTrans, layout.transform) : axisStTrans;
|
||||
});
|
||||
function isParallelToAxis(whIdx) {
|
||||
// Assert label[0] and label[1] has the same rotation, so only use [0].
|
||||
var localRect = layoutPair[0].localRect;
|
||||
var labelVec0 = new Point(localRect[WH[whIdx]] * labelPairStTrans[0][0], localRect[WH[whIdx]] * labelPairStTrans[0][1]);
|
||||
return Math.abs(labelVec0.y) < 1e-5;
|
||||
}
|
||||
// If overlapping, move pair[0] pair[1] apart a little. We need to calculate a ratio k to
|
||||
// distribute mtv to pair[0] and pair[1]. This is to place the text gap as close as possible
|
||||
// to the center of the break ticks, otherwise it might looks weird or misleading.
|
||||
// - When labels' width/height are not parallel to axis (usually by rotation),
|
||||
// we can simply treat the k as `0.5`.
|
||||
var k = 0.5;
|
||||
// - When labels' width/height are parallel to axis, the width/height need to be considered,
|
||||
// since they may differ significantly. In this case we keep textAlign as 'center' rather
|
||||
// than 'left'/'right', due to considerations of space utilization for wide break.gap.
|
||||
// A sample case: break on xAxis(no inverse) is [200, 300000].
|
||||
// We calculate k based on the formula below:
|
||||
// Rotated axis and labels to the direction of (1, 0).
|
||||
// uval = ( (pair[0].insidePt - mtv*k) + (pair[1].insidePt + mtv*(1-k)) ) / 2 - brkCenter
|
||||
// 0 <= k <= 1
|
||||
// |uval| should be as small as possible.
|
||||
// Derived as follows:
|
||||
// qval = (pair[0].insidePt + pair[1].insidePt + mtv) / 2 - brkCenter
|
||||
// k = (qval - uval) / mtv
|
||||
// min(qval, qval-mtv) <= uval <= max(qval, qval-mtv)
|
||||
if (isParallelToAxis(0) || isParallelToAxis(1)) {
|
||||
var rectSt = map(layoutPair, function (layout, idx) {
|
||||
var rect = layout.localRect.clone();
|
||||
rect.applyTransform(labelPairStTrans[idx]);
|
||||
return rect;
|
||||
});
|
||||
var brkCenterSt = new Point();
|
||||
brkCenterSt.copy(layoutPair[0].label).add(layoutPair[1].label).scale(0.5);
|
||||
brkCenterSt.transform(axisStTrans);
|
||||
var mtvSt = mtv.clone().transform(axisStTrans);
|
||||
var insidePtSum = rectSt[0].x + rectSt[1].x + (mtvSt.x >= 0 ? rectSt[0].width : rectSt[1].width);
|
||||
var qval = (insidePtSum + mtvSt.x) / 2 - brkCenterSt.x;
|
||||
var uvalMin = Math.min(qval, qval - mtvSt.x);
|
||||
var uvalMax = Math.max(qval, qval - mtvSt.x);
|
||||
var uval = uvalMax < 0 ? uvalMax : uvalMin > 0 ? uvalMin : 0;
|
||||
k = (qval - uval) / mtvSt.x;
|
||||
}
|
||||
var delta0 = new Point();
|
||||
var delta1 = new Point();
|
||||
Point.scale(delta0, mtv, -k);
|
||||
Point.scale(delta1, mtv, 1 - k);
|
||||
labelLayoutApplyTranslation(layoutPair[0], delta0);
|
||||
labelLayoutApplyTranslation(layoutPair[1], delta1);
|
||||
}
|
||||
function updateModelAxisBreak(model, payload) {
|
||||
var result = {
|
||||
breaks: []
|
||||
};
|
||||
each(payload.breaks, function (inputBrk) {
|
||||
if (!inputBrk) {
|
||||
return;
|
||||
}
|
||||
var breakOption = find(model.get('breaks', true), function (brkOption) {
|
||||
return getScaleBreakHelper().identifyAxisBreak(brkOption, inputBrk);
|
||||
});
|
||||
if (!breakOption) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warn("Can not find axis break by start: " + inputBrk.start + ", end: " + inputBrk.end);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var actionType = payload.type;
|
||||
var old = {
|
||||
isExpanded: !!breakOption.isExpanded
|
||||
};
|
||||
breakOption.isExpanded = actionType === AXIS_BREAK_EXPAND_ACTION_TYPE ? true : actionType === AXIS_BREAK_COLLAPSE_ACTION_TYPE ? false : actionType === AXIS_BREAK_TOGGLE_ACTION_TYPE ? !breakOption.isExpanded : breakOption.isExpanded;
|
||||
result.breaks.push({
|
||||
start: breakOption.start,
|
||||
end: breakOption.end,
|
||||
isExpanded: !!breakOption.isExpanded,
|
||||
old: old
|
||||
});
|
||||
});
|
||||
return result;
|
||||
}
|
||||
export function installAxisBreakHelper() {
|
||||
registerAxisBreakHelperImpl({
|
||||
adjustBreakLabelPair: adjustBreakLabelPair,
|
||||
buildAxisBreakLine: buildAxisBreakLine,
|
||||
rectCoordBuildBreakAxis: rectCoordBuildBreakAxis,
|
||||
updateModelAxisBreak: updateModelAxisBreak
|
||||
});
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import * as zrUtil from 'zrender/lib/core/util.js';
|
||||
import * as graphic from '../../util/graphic.js';
|
||||
import { makeInner } from '../../util/model.js';
|
||||
var inner = makeInner();
|
||||
export function rectCoordAxisBuildSplitArea(axisView, axisGroup, axisModel, gridModel) {
|
||||
var axis = axisModel.axis;
|
||||
if (axis.scale.isBlank()) {
|
||||
return;
|
||||
}
|
||||
// TODO: TYPE
|
||||
var splitAreaModel = axisModel.getModel('splitArea');
|
||||
var areaStyleModel = splitAreaModel.getModel('areaStyle');
|
||||
var areaColors = areaStyleModel.get('color');
|
||||
var gridRect = gridModel.coordinateSystem.getRect();
|
||||
var ticksCoords = axis.getTicksCoords({
|
||||
tickModel: splitAreaModel,
|
||||
clamp: true,
|
||||
breakTicks: 'none',
|
||||
pruneByBreak: 'preserve_extent_bound'
|
||||
});
|
||||
if (!ticksCoords.length) {
|
||||
return;
|
||||
}
|
||||
// For Making appropriate splitArea animation, the color and anid
|
||||
// should be corresponding to previous one if possible.
|
||||
var areaColorsLen = areaColors.length;
|
||||
var lastSplitAreaColors = inner(axisView).splitAreaColors;
|
||||
var newSplitAreaColors = zrUtil.createHashMap();
|
||||
var colorIndex = 0;
|
||||
if (lastSplitAreaColors) {
|
||||
for (var i = 0; i < ticksCoords.length; i++) {
|
||||
var cIndex = lastSplitAreaColors.get(ticksCoords[i].tickValue);
|
||||
if (cIndex != null) {
|
||||
colorIndex = (cIndex + (areaColorsLen - 1) * i) % areaColorsLen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var prev = axis.toGlobalCoord(ticksCoords[0].coord);
|
||||
var areaStyle = areaStyleModel.getAreaStyle();
|
||||
areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
|
||||
for (var i = 1; i < ticksCoords.length; i++) {
|
||||
var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
|
||||
var x = void 0;
|
||||
var y = void 0;
|
||||
var width = void 0;
|
||||
var height = void 0;
|
||||
if (axis.isHorizontal()) {
|
||||
x = prev;
|
||||
y = gridRect.y;
|
||||
width = tickCoord - x;
|
||||
height = gridRect.height;
|
||||
prev = x + width;
|
||||
} else {
|
||||
x = gridRect.x;
|
||||
y = prev;
|
||||
width = gridRect.width;
|
||||
height = tickCoord - y;
|
||||
prev = y + height;
|
||||
}
|
||||
var tickValue = ticksCoords[i - 1].tickValue;
|
||||
tickValue != null && newSplitAreaColors.set(tickValue, colorIndex);
|
||||
axisGroup.add(new graphic.Rect({
|
||||
anid: tickValue != null ? 'area_' + tickValue : null,
|
||||
shape: {
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height
|
||||
},
|
||||
style: zrUtil.defaults({
|
||||
fill: areaColors[colorIndex]
|
||||
}, areaStyle),
|
||||
autoBatch: true,
|
||||
silent: true
|
||||
}));
|
||||
colorIndex = (colorIndex + 1) % areaColorsLen;
|
||||
}
|
||||
inner(axisView).splitAreaColors = newSplitAreaColors;
|
||||
}
|
||||
export function rectCoordAxisHandleRemove(axisView) {
|
||||
inner(axisView).splitAreaColors = null;
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { installScaleBreakHelper } from '../../scale/breakImpl.js';
|
||||
import { registerAction } from './axisAction.js';
|
||||
import { installAxisBreakHelper } from './axisBreakHelperImpl.js';
|
||||
export function installAxisBreak(registers) {
|
||||
registerAction(registers);
|
||||
installScaleBreakHelper();
|
||||
installAxisBreakHelper();
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var actionInfo = {
|
||||
type: 'axisAreaSelect',
|
||||
event: 'axisAreaSelected'
|
||||
// update: 'updateVisual'
|
||||
};
|
||||
export function installParallelActions(registers) {
|
||||
registers.registerAction(actionInfo, function (payload, ecModel) {
|
||||
ecModel.eachComponent({
|
||||
mainType: 'parallelAxis',
|
||||
query: payload
|
||||
}, function (parallelAxisModel) {
|
||||
parallelAxisModel.axis.model.setActiveIntervals(payload.intervals);
|
||||
});
|
||||
});
|
||||
/**
|
||||
* @payload
|
||||
*/
|
||||
registers.registerAction('parallelAxisExpand', function (payload, ecModel) {
|
||||
ecModel.eachComponent({
|
||||
mainType: 'parallel',
|
||||
query: payload
|
||||
}, function (parallelModel) {
|
||||
parallelModel.setAxisExpand(payload);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user