@visactor/vrender-components 0.14.3-alpha.1 → 0.14.3-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/axis/base.d.ts +0 -4
- package/cjs/axis/base.js +5 -3
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/circle.d.ts +1 -5
- package/cjs/axis/circle.js +0 -6
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/line.d.ts +0 -5
- package/cjs/axis/line.js +3 -10
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/overlap/auto-rotate.d.ts +1 -9
- package/cjs/axis/overlap/auto-rotate.js +30 -41
- package/cjs/axis/overlap/auto-rotate.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/label/base.js +102 -16
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/type.d.ts +4 -0
- package/cjs/label/type.js.map +1 -1
- package/cjs/util/labelSmartInvert.d.ts +2 -1
- package/cjs/util/labelSmartInvert.js +2 -2
- package/cjs/util/labelSmartInvert.js.map +1 -1
- package/dist/index.js +172 -95
- package/dist/index.min.js +1 -1
- package/es/axis/base.d.ts +0 -4
- package/es/axis/base.js +5 -3
- package/es/axis/base.js.map +1 -1
- package/es/axis/circle.d.ts +1 -5
- package/es/axis/circle.js +0 -6
- package/es/axis/circle.js.map +1 -1
- package/es/axis/line.d.ts +0 -5
- package/es/axis/line.js +3 -11
- package/es/axis/line.js.map +1 -1
- package/es/axis/overlap/auto-rotate.d.ts +1 -9
- package/es/axis/overlap/auto-rotate.js +28 -38
- package/es/axis/overlap/auto-rotate.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/label/base.js +101 -17
- package/es/label/base.js.map +1 -1
- package/es/label/type.d.ts +4 -0
- package/es/label/type.js.map +1 -1
- package/es/util/labelSmartInvert.d.ts +2 -1
- package/es/util/labelSmartInvert.js +1 -1
- package/es/util/labelSmartInvert.js.map +1 -1
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.labelSmartInvert = void 0;
|
|
5
|
+
}), exports.contrastAccessibilityChecker = exports.labelSmartInvert = void 0;
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), defaultAlternativeColors = [ "#ffffff", "#000000" ];
|
|
8
8
|
|
|
@@ -41,5 +41,5 @@ function formatColorToHex(originColor) {
|
|
|
41
41
|
return "#" + vutils_1.ColorUtil.rgbToHex(r, g, b);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
exports.labelSmartInvert = labelSmartInvert;
|
|
44
|
+
exports.labelSmartInvert = labelSmartInvert, exports.contrastAccessibilityChecker = contrastAccessibilityChecker;
|
|
45
45
|
//# sourceMappingURL=labelSmartInvert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["util/labelSmartInvert.ts"],"names":[],"mappings":";;;AACA,6CAA6C;AAE7C,MAAM,wBAAwB,GAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAQlE,SAAgB,gBAAgB,CAC9B,qBAAyC,EACzC,qBAAyC,EACzC,QAA6B,EAC7B,uBAAgC,EAChC,iBAAqC;IAErC,MAAM,eAAe,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IAChE,MAAM,eAAe,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IAChE,IAAI,CAAC,4BAA4B,CAAC,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,uBAAuB,CAAC,EAAE;QACtG,OAAO,sBAAsB,CAC3B,eAAe,EACf,eAAe,EACf,QAAQ,EACR,uBAAuB,EACvB,iBAAiB,CAClB,CAAC;KACH;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAnBD,4CAm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K,EAAE,GAAG,CAAC,CAAC;KAC5C;IACD,IAAI,KAAK,IAAI,OAAO,EAAE;QACpB,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC;KACnB;SAAM;QACL,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC;KAC5C;IACD,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC;IAC/C,OAAO,CAAC,CAAC;AACX,CAAC;AAQD,SAAS,gBAAgB,CAAC,WAA+B;IACvD,IAAK,WAAsB,aAAtB,WAAW,uBAAX,WAAW,CAAa,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC1C,OAAO,WAAW,CAAC;KACpB;IACD,MAAM,CAAC,GAAG,IAAI,kBAAS,CAAC,KAAK,CAAC,WAAqB,CAAC,CAAC;IACrD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC;IAC5B,OAAO,GAAG,GAAG,kBAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC","file":"labelSmartInvert.js","sourcesContent":["import type { IColor } from '@visactor/vrender';\nimport { ColorUtil } from '@visactor/vutils';\n\nconst defaultAlternativeColors: string[] = ['#ffffff', '#000000'];\n\n/**\n * 标签智能反色\n * @param foregroundColorOrigin\n * @param backgroundColorOrogin\n * @returns\n */\nexport function labelSmartInvert(\n foregroundColorOrigin: IColor | undefined,\n backgroundColorOrogin: IColor | undefined,\n textType?: string | undefined,\n contrastRatiosThreshold?: number,\n alternativeColors?: string | string[]\n): IColor | undefined {\n const foregroundColor = formatColorToHex(foregroundColorOrigin);\n const backgroundColor = formatColorToHex(backgroundColorOrogin);\n if (!contrastAccessibilityChecker(foregroundColor, backgroundColor, textType, contrastRatiosThreshold)) {\n return improveContrastReverse(\n foregroundColor,\n backgroundColor,\n textType,\n contrastRatiosThreshold,\n alternativeColors\n );\n }\n return foregroundColor;\n}\n\n/**\n * 提升对比度\n * 对于对比度不足阈值的情况,推荐备选颜色色板中的颜色提升对比\n * @param foregroundColor\n * @param backgroundColor\n * @returns\n */\nfunction improveContrastReverse(\n foregroundColor: IColor | undefined,\n backgroundColor: IColor | undefined,\n textType?: IColor | undefined,\n contrastRatiosThreshold?: number,\n alternativeColors?: string | string[]\n) {\n const alternativeColorPalletes: string[] = [];\n if (alternativeColors) {\n if (alternativeColors instanceof Array) {\n alternativeColorPalletes.push(...alternativeColors);\n } else {\n alternativeColorPalletes.push(alternativeColors);\n }\n }\n alternativeColorPalletes.push(...defaultAlternativeColors);\n for (const alternativeColor of alternativeColorPalletes) {\n if (foregroundColor === alternativeColor) {\n continue;\n }\n if (contrastAccessibilityChecker(alternativeColor, backgroundColor, textType, contrastRatiosThreshold)) {\n return alternativeColor;\n }\n }\n return undefined;\n}\n\n/**\n * 颜色对比度可行性检查 https://webaim.org/articles/contrast/\n * - WCAG 2.0 AA 级要求普通文本的对比度至少为 4.5:1,大文本的对比度至少为 3:1。(目前按照此标准)\n * - WCAG 2.1 要求图形和用户界面组件(例如表单输入边框)的对比度至少为 3:1。\n * - WCAG AAA 级要求普通文本的对比度至少为 7:1,大文本的对比度至少为 4.5:1。\n * @param foregroundColor\n * @param backgroundColor\n * @returns\n */\nexport function contrastAccessibilityChecker(\n foregroundColor: IColor | undefined,\n backgroundColor: IColor | undefined,\n textType?: IColor | undefined,\n contrastRatiosThreshold?: number\n): boolean {\n //Contrast ratios can range from 1 to 21\n if (contrastRatiosThreshold) {\n if (contrastRatios(foregroundColor, backgroundColor) > contrastRatiosThreshold) {\n return true;\n }\n return false;\n } else if (textType === 'largeText') {\n if (contrastRatios(foregroundColor, backgroundColor) > 3) {\n return true;\n }\n return false;\n }\n if (contrastRatios(foregroundColor, backgroundColor) > 4.5) {\n return true;\n }\n return false;\n}\n\n/**\n * 计算颜色对比度 https://webaim.org/articles/contrast/\n * Contrast ratios can range from 1 to 21 (commonly written 1:1 to 21:1).\n * (L1 + 0.05) / (L2 + 0.05), whereby:\n * L1 is the relative luminance of the lighter of the colors, and\n * L2 is the relative luminance of the darker of the colors.\n * @param foregroundColor\n * @param backgroundColor\n * @returns\n */\nfunction contrastRatios(foregroundColor: IColor | undefined, backgroundColor: IColor | undefined): number {\n const foregroundColorLuminance = getColorLuminance(foregroundColor as string);\n const backgroundColorLuminance = getColorLuminance(backgroundColor as string);\n const L1 = foregroundColorLuminance > backgroundColorLuminance ? foregroundColorLuminance : backgroundColorLuminance;\n const L2 = foregroundColorLuminance > backgroundColorLuminance ? backgroundColorLuminance : foregroundColorLuminance;\n const contrastRatios = (L1 + 0.05) / (L2 + 0.05);\n return contrastRatios;\n}\n\n/**\n * 计算相对亮度 https://webaim.org/articles/contrast/\n * the relative brightness of any point in a colorspace, normalized to 0 for darkest black and 1 for lightest white\n * Note 1: For the sRGB colorspace, the relative luminance of a color is defined as\n * L = 0.2126 * R + 0.7152 * G + 0.0722 * B where R, G and B are defined as:\n * if RsRGB <= 0.03928 then R = RsRGB/12.92 else R = ((RsRGB+0.055)/1.055) ^ 2.4\n * if GsRGB <= 0.03928 then G = GsRGB/12.92 else G = ((GsRGB+0.055)/1.055) ^ 2.4\n * if BsRGB <= 0.03928 then B = BsRGB/12.92 else B = ((BsRGB+0.055)/1.055) ^ 2.4\n * and RsRGB, GsRGB, and BsRGB are defined as:\n * RsRGB = R8bit/255\n * GsRGB = G8bit/255\n * BsRGB = B8bit/255\n * @param color\n * @returns\n */\nfunction getColorLuminance(color: string): number {\n const rgb8bit = ColorUtil.hexToRgb(color);\n const RsRGB = rgb8bit[0] / 255;\n const GsRGB = rgb8bit[1] / 255;\n const BsRGB = rgb8bit[2] / 255;\n let R;\n let G;\n let B;\n if (RsRGB <= 0.03928) {\n R = RsRGB / 12.92;\n } else {\n R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);\n }\n if (GsRGB <= 0.03928) {\n G = GsRGB / 12.92;\n } else {\n G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);\n }\n if (BsRGB <= 0.03928) {\n B = BsRGB / 12.92;\n } else {\n B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);\n }\n const L = 0.2126 * R + 0.7152 * G + 0.0722 * B;\n return L;\n}\n\n/**\n * 规范化color格式为hex\n * 当color为颜色名称或rgb时,对其进行规范化处理\n * @param originColor\n * @returns\n */\nfunction formatColorToHex(originColor: IColor | undefined) {\n if ((originColor as string)?.includes('#')) {\n return originColor;\n }\n const c = new ColorUtil.Color(originColor as string);\n const { r, g, b } = c.color;\n return '#' + ColorUtil.rgbToHex(r, g, b);\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1974,8 +1974,16 @@
|
|
|
1974
1974
|
return listener;
|
|
1975
1975
|
}
|
|
1976
1976
|
_smartInvert(labels) {
|
|
1977
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1977
1978
|
const option = (this.attribute.smartInvert || {});
|
|
1978
1979
|
const { textType, contrastRatiosThreshold, alternativeColors } = option;
|
|
1980
|
+
(_a = option.fillStrategy) !== null && _a !== void 0 ? _a : 'invertSeries';
|
|
1981
|
+
(_b = option.strokeStrategy) !== null && _b !== void 0 ? _b : 'series';
|
|
1982
|
+
const brightColor = (_c = option.brightColor) !== null && _c !== void 0 ? _c : '#ffffff';
|
|
1983
|
+
const darkColor = (_d = option.darkColor) !== null && _d !== void 0 ? _d : '#000000';
|
|
1984
|
+
if (option.fillStrategy === 'null' && option.strokeStrategy === 'null') {
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1979
1987
|
for (let i = 0; i < labels.length; i++) {
|
|
1980
1988
|
const label = labels[i];
|
|
1981
1989
|
if (!label) {
|
|
@@ -1991,25 +1999,104 @@
|
|
|
1991
1999
|
isInside = false;
|
|
1992
2000
|
}
|
|
1993
2001
|
}
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2002
|
+
const backgroundColor = baseMark.attribute.fill;
|
|
2003
|
+
const foregroundColor = label.attribute.fill;
|
|
2004
|
+
const seriesColor = backgroundColor;
|
|
2005
|
+
const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors);
|
|
2006
|
+
const simialrColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
|
|
2007
|
+
const fillStrategy = (_e = option.fillStrategy) !== null && _e !== void 0 ? _e : 'invertSeries';
|
|
2008
|
+
const strokeStrategy = (_f = option.strokeStrategy) !== null && _f !== void 0 ? _f : 'series';
|
|
2009
|
+
if (isInside) {
|
|
2010
|
+
switch (fillStrategy) {
|
|
2011
|
+
case 'null':
|
|
2012
|
+
break;
|
|
2013
|
+
case 'series':
|
|
2014
|
+
label.setAttributes({
|
|
2015
|
+
fill: seriesColor
|
|
2016
|
+
});
|
|
2017
|
+
break;
|
|
2018
|
+
case 'invertSeries':
|
|
2019
|
+
label.setAttributes({
|
|
2020
|
+
fill: invertColor
|
|
2021
|
+
});
|
|
2022
|
+
break;
|
|
2023
|
+
case 'similarSeries':
|
|
2024
|
+
label.setAttributes({
|
|
2025
|
+
fill: simialrColor
|
|
2026
|
+
});
|
|
2027
|
+
break;
|
|
2028
|
+
}
|
|
2029
|
+
if (label.attribute.lineWidth === 0) {
|
|
2030
|
+
continue;
|
|
2031
|
+
}
|
|
2032
|
+
switch (strokeStrategy) {
|
|
2033
|
+
case 'null':
|
|
2034
|
+
break;
|
|
2035
|
+
case 'series':
|
|
2036
|
+
label.setAttributes({
|
|
2037
|
+
stroke: seriesColor
|
|
2038
|
+
});
|
|
2039
|
+
break;
|
|
2040
|
+
case 'invertSeries':
|
|
2041
|
+
label.setAttributes({
|
|
2042
|
+
stroke: invertColor
|
|
2043
|
+
});
|
|
2044
|
+
break;
|
|
2045
|
+
case 'similarSeries':
|
|
2046
|
+
label.setAttributes({
|
|
2047
|
+
stroke: simialrColor
|
|
2048
|
+
});
|
|
2049
|
+
break;
|
|
2050
|
+
}
|
|
2005
2051
|
}
|
|
2006
|
-
else
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2052
|
+
else {
|
|
2053
|
+
if (label.attribute.lineWidth === 0) {
|
|
2054
|
+
continue;
|
|
2055
|
+
}
|
|
2056
|
+
if (label.attribute.stroke) {
|
|
2057
|
+
label.setAttributes({
|
|
2058
|
+
fill: labelSmartInvert(label.attribute.fill, label.attribute.stroke, textType, contrastRatiosThreshold, alternativeColors)
|
|
2059
|
+
});
|
|
2060
|
+
continue;
|
|
2061
|
+
}
|
|
2062
|
+
switch (fillStrategy) {
|
|
2063
|
+
case 'null':
|
|
2064
|
+
break;
|
|
2065
|
+
case 'series':
|
|
2066
|
+
label.setAttributes({
|
|
2067
|
+
fill: seriesColor
|
|
2068
|
+
});
|
|
2069
|
+
break;
|
|
2070
|
+
case 'invertSeries':
|
|
2071
|
+
label.setAttributes({
|
|
2072
|
+
fill: invertColor
|
|
2073
|
+
});
|
|
2074
|
+
break;
|
|
2075
|
+
case 'similarSeries':
|
|
2076
|
+
label.setAttributes({
|
|
2077
|
+
fill: simialrColor
|
|
2078
|
+
});
|
|
2079
|
+
break;
|
|
2080
|
+
}
|
|
2081
|
+
switch (strokeStrategy) {
|
|
2082
|
+
case 'null':
|
|
2083
|
+
break;
|
|
2084
|
+
case 'series':
|
|
2085
|
+
label.setAttributes({
|
|
2086
|
+
stroke: seriesColor
|
|
2087
|
+
});
|
|
2088
|
+
break;
|
|
2089
|
+
case 'invertSeries':
|
|
2090
|
+
label.setAttributes({
|
|
2091
|
+
stroke: invertColor
|
|
2092
|
+
});
|
|
2093
|
+
break;
|
|
2094
|
+
case 'similarSeries':
|
|
2095
|
+
label.setAttributes({
|
|
2096
|
+
stroke: simialrColor
|
|
2097
|
+
});
|
|
2098
|
+
break;
|
|
2099
|
+
}
|
|
2013
2100
|
}
|
|
2014
2101
|
}
|
|
2015
2102
|
}
|
|
@@ -3841,8 +3928,10 @@
|
|
|
3841
3928
|
textStyle = vutils.isFunction(textStyle)
|
|
3842
3929
|
? vutils.merge({}, DEFAULT_AXIS_THEME.label.style, textStyle(tickDatum, index, tickData, layer))
|
|
3843
3930
|
: textStyle;
|
|
3844
|
-
|
|
3845
|
-
|
|
3931
|
+
textStyle = vutils.merge({
|
|
3932
|
+
textAlign: this.getTextAlign(vector),
|
|
3933
|
+
textBaseline: this.getTextBaseline(vector, inside)
|
|
3934
|
+
}, textStyle);
|
|
3846
3935
|
if (vutils.isFunction(textStyle.text)) {
|
|
3847
3936
|
textStyle.text = textStyle.text({
|
|
3848
3937
|
label: tickDatum.label,
|
|
@@ -4008,70 +4097,73 @@
|
|
|
4008
4097
|
item.rotatedBounds = bounds;
|
|
4009
4098
|
});
|
|
4010
4099
|
}
|
|
4011
|
-
function clampAngle(angle = 0) {
|
|
4012
|
-
if (angle < 0) {
|
|
4013
|
-
while (angle < 0) {
|
|
4014
|
-
angle += Math.PI * 2;
|
|
4015
|
-
}
|
|
4016
|
-
}
|
|
4017
|
-
if (angle > 0) {
|
|
4018
|
-
while (angle >= Math.PI * 2) {
|
|
4019
|
-
angle -= Math.PI * 2;
|
|
4020
|
-
}
|
|
4021
|
-
}
|
|
4022
|
-
return angle;
|
|
4023
|
-
}
|
|
4024
4100
|
function rotateYAxis(orient, items) {
|
|
4101
|
+
let align = ['right', 'right', 'center', 'left', 'center', 'left', 'center', 'right', 'right'];
|
|
4102
|
+
let baseline = ['middle', 'middle', 'top', 'top', 'middle', 'middle', 'bottom', 'bottom', 'middle'];
|
|
4103
|
+
if (orient === 'right') {
|
|
4104
|
+
align = ['left', 'right', 'right', 'right', 'left', 'left', 'left', 'left', 'right'];
|
|
4105
|
+
baseline = ['middle', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
|
|
4106
|
+
}
|
|
4025
4107
|
items.forEach((item, i) => {
|
|
4026
|
-
|
|
4108
|
+
let angle = item.attribute.angle || 0;
|
|
4109
|
+
if (angle < 0) {
|
|
4110
|
+
while (angle < 0) {
|
|
4111
|
+
angle += Math.PI * 2;
|
|
4112
|
+
}
|
|
4113
|
+
}
|
|
4114
|
+
if (angle > 0) {
|
|
4115
|
+
while (angle >= Math.PI * 2) {
|
|
4116
|
+
angle -= Math.PI * 2;
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
const step = angle / (Math.PI * 0.5);
|
|
4120
|
+
let index;
|
|
4121
|
+
if (step === Math.floor(step)) {
|
|
4122
|
+
index = Math.floor(step) * 2;
|
|
4123
|
+
}
|
|
4124
|
+
else {
|
|
4125
|
+
index = Math.floor(step) * 2 + 1;
|
|
4126
|
+
}
|
|
4127
|
+
item.setAttributes({
|
|
4128
|
+
textAlign: align[index],
|
|
4129
|
+
textBaseline: baseline[index],
|
|
4130
|
+
angle: angle
|
|
4131
|
+
});
|
|
4027
4132
|
});
|
|
4028
4133
|
}
|
|
4029
4134
|
function rotateXAxis(orient, items) {
|
|
4030
|
-
items.forEach(item => {
|
|
4031
|
-
item.setAttributes(Object.assign(Object.assign({}, getXAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
|
|
4032
|
-
});
|
|
4033
|
-
}
|
|
4034
|
-
function getXAxisLabelAlign(orient, angle = 0) {
|
|
4035
4135
|
let align = ['center', 'left', 'left', 'left', 'center', 'right', 'right', 'right', 'left'];
|
|
4036
4136
|
let baseline = ['top', 'top', 'middle', 'bottom', 'bottom', 'bottom', 'middle', 'top', 'top'];
|
|
4037
4137
|
if (orient === 'top') {
|
|
4038
4138
|
align = ['center', 'right', 'right', 'right', 'center', 'left', 'left', 'left', 'right'];
|
|
4039
4139
|
baseline = ['bottom', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
|
|
4040
4140
|
}
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
}
|
|
4068
|
-
else {
|
|
4069
|
-
index = Math.floor(step) * 2 + 1;
|
|
4070
|
-
}
|
|
4071
|
-
return {
|
|
4072
|
-
textAlign: align[index],
|
|
4073
|
-
textBaseline: baseline[index]
|
|
4074
|
-
};
|
|
4141
|
+
items.forEach(item => {
|
|
4142
|
+
let angle = item.attribute.angle || 0;
|
|
4143
|
+
if (angle < 0) {
|
|
4144
|
+
while (angle < 0) {
|
|
4145
|
+
angle += Math.PI * 2;
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
if (angle > 0) {
|
|
4149
|
+
while (angle >= Math.PI * 2) {
|
|
4150
|
+
angle -= Math.PI * 2;
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4153
|
+
const step = angle / (Math.PI * 0.5);
|
|
4154
|
+
let index;
|
|
4155
|
+
if (step === Math.floor(step)) {
|
|
4156
|
+
index = Math.floor(step) * 2;
|
|
4157
|
+
}
|
|
4158
|
+
else {
|
|
4159
|
+
index = Math.floor(step) * 2 + 1;
|
|
4160
|
+
}
|
|
4161
|
+
item.setAttributes({
|
|
4162
|
+
textAlign: align[index],
|
|
4163
|
+
textBaseline: baseline[index],
|
|
4164
|
+
angle
|
|
4165
|
+
});
|
|
4166
|
+
});
|
|
4075
4167
|
}
|
|
4076
4168
|
|
|
4077
4169
|
function autoLimit(labels, config) {
|
|
@@ -4478,23 +4570,14 @@
|
|
|
4478
4570
|
}
|
|
4479
4571
|
return base;
|
|
4480
4572
|
}
|
|
4481
|
-
|
|
4573
|
+
beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4482
4574
|
const orient = this.attribute.orient;
|
|
4483
|
-
if (
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
return getYAxisLabelAlign(orient, angle);
|
|
4489
|
-
}
|
|
4575
|
+
if (orient === 'left' || orient === 'right') {
|
|
4576
|
+
rotateYAxis(orient, labelShapes);
|
|
4577
|
+
}
|
|
4578
|
+
else if (orient === 'bottom' || orient === 'top') {
|
|
4579
|
+
rotateXAxis(orient, labelShapes);
|
|
4490
4580
|
}
|
|
4491
|
-
return {
|
|
4492
|
-
textAlign: this.getTextAlign(vector),
|
|
4493
|
-
textBaseline: this.getTextBaseline(vector, inside)
|
|
4494
|
-
};
|
|
4495
|
-
}
|
|
4496
|
-
beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4497
|
-
return;
|
|
4498
4581
|
}
|
|
4499
4582
|
handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4500
4583
|
if (vutils.isEmpty(labelShapes)) {
|
|
@@ -4842,12 +4925,6 @@
|
|
|
4842
4925
|
afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4843
4926
|
return;
|
|
4844
4927
|
}
|
|
4845
|
-
getLabelAlign(vector, inside, angle) {
|
|
4846
|
-
return {
|
|
4847
|
-
textAlign: this.getTextAlign(vector),
|
|
4848
|
-
textBaseline: this.getTextBaseline(vector)
|
|
4849
|
-
};
|
|
4850
|
-
}
|
|
4851
4928
|
}
|
|
4852
4929
|
CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME;
|
|
4853
4930
|
|
|
@@ -10043,7 +10120,7 @@
|
|
|
10043
10120
|
}
|
|
10044
10121
|
Tooltip.defaultAttributes = defaultAttributes;
|
|
10045
10122
|
|
|
10046
|
-
const version = "0.14.3-alpha.
|
|
10123
|
+
const version = "0.14.3-alpha.3";
|
|
10047
10124
|
|
|
10048
10125
|
exports.AbstractComponent = AbstractComponent;
|
|
10049
10126
|
exports.ArcInfo = ArcInfo;
|