echarts 3.7.1 → 3.7.2
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/dist/echarts-en.js +77756 -0
- package/dist/echarts-en.min.js +38 -0
- package/dist/echarts.common-en.js +50169 -0
- package/dist/echarts.common-en.min.js +30 -0
- package/dist/echarts.common.js +1408 -1186
- package/dist/echarts.common.min.js +14 -14
- package/dist/echarts.js +1572 -1278
- package/dist/echarts.min.js +22 -22
- package/dist/echarts.simple-en.js +34988 -0
- package/dist/echarts.simple-en.min.js +27 -0
- package/dist/echarts.simple.js +1152 -994
- package/dist/echarts.simple.min.js +11 -11
- package/index.blank.js +4 -0
- package/lib/chart/bar/BaseBarSeries.js +3 -3
- package/lib/chart/candlestick/candlestickLayout.js +26 -1
- package/lib/chart/graph/forceHelper.js +5 -0
- package/lib/chart/graph/forceLayout.js +0 -1
- package/lib/chart/helper/whiskerBoxCommon.js +6 -1
- package/lib/chart/line/LineView.js +14 -2
- package/lib/chart/lines/LinesView.js +22 -7
- package/lib/chart/pie/PieSeries.js +3 -1
- package/lib/chart/pie/PieView.js +1 -1
- package/lib/chart/treemap/TreemapView.js +5 -28
- package/lib/component/axis/AxisBuilder.js +249 -178
- package/lib/component/axis/CartesianAxisView.js +15 -3
- package/lib/component/axis/ParallelAxisView.js +1 -1
- package/lib/component/axis/RadiusAxisView.js +1 -1
- package/lib/component/axis/SingleAxisView.js +8 -2
- package/lib/component/helper/RoamController.js +12 -11
- package/lib/component/marker/MarkAreaView.js +1 -1
- package/lib/component/radar/RadarView.js +1 -1
- package/lib/component/toolbox/feature/Brush.js +3 -8
- package/lib/component/toolbox/feature/DataView.js +3 -3
- package/lib/component/toolbox/feature/DataZoom.js +3 -4
- package/lib/component/toolbox/feature/MagicType.js +3 -6
- package/lib/component/toolbox/feature/Restore.js +2 -1
- package/lib/component/toolbox/feature/SaveAsImage.js +23 -9
- package/lib/component/visualMap/ContinuousModel.js +2 -2
- package/lib/component/visualMap/ContinuousView.js +3 -3
- package/lib/component/visualMap/PiecewiseModel.js +0 -1
- package/lib/component/visualMap/VisualMapModel.js +17 -11
- package/lib/coord/calendar/Calendar.js +64 -20
- package/lib/echarts.js +5 -4
- package/lib/lang/cn.js +4 -0
- package/lib/lang/default.js +42 -0
- package/lib/lang/en.js +42 -0
- package/lib/lang.js +42 -0
- package/lib/langEN.js +42 -0
- package/lib/preprocessor/helper/compatStyle.js +24 -23
- package/lib/scale/Time.js +4 -4
- package/lib/util/graphic.js +5 -5
- package/lib/util/number.js +42 -21
- package/lib/visual/VisualMapping.js +3 -3
- package/package.json +3 -3
- package/rollup.config.js +49 -0
- package/src/chart/bar/BaseBarSeries.js +3 -3
- package/src/chart/candlestick/candlestickLayout.js +26 -1
- package/src/chart/graph/forceHelper.js +5 -0
- package/src/chart/graph/forceLayout.js +0 -1
- package/src/chart/helper/whiskerBoxCommon.js +6 -2
- package/src/chart/line/LineView.js +14 -2
- package/src/chart/lines/LinesView.js +22 -7
- package/src/chart/pie/PieSeries.js +3 -1
- package/src/chart/pie/PieView.js +1 -1
- package/src/chart/treemap/TreemapView.js +5 -28
- package/src/component/axis/AxisBuilder.js +249 -178
- package/src/component/axis/CartesianAxisView.js +15 -3
- package/src/component/axis/ParallelAxisView.js +1 -1
- package/src/component/axis/RadiusAxisView.js +1 -1
- package/src/component/axis/SingleAxisView.js +8 -2
- package/src/component/helper/RoamController.js +12 -11
- package/src/component/marker/MarkAreaView.js +1 -1
- package/src/component/radar/RadarView.js +1 -1
- package/src/component/toolbox/feature/Brush.js +3 -8
- package/src/component/toolbox/feature/DataView.js +3 -3
- package/src/component/toolbox/feature/DataZoom.js +3 -4
- package/src/component/toolbox/feature/MagicType.js +3 -6
- package/src/component/toolbox/feature/Restore.js +2 -1
- package/src/component/toolbox/feature/SaveAsImage.js +23 -10
- package/src/component/visualMap/ContinuousModel.js +2 -2
- package/src/component/visualMap/ContinuousView.js +3 -3
- package/src/component/visualMap/PiecewiseModel.js +0 -1
- package/src/component/visualMap/VisualMapModel.js +17 -11
- package/src/coord/calendar/Calendar.js +64 -20
- package/src/echarts.js +5 -4
- package/src/lang.js +43 -0
- package/src/langEN.js +43 -0
- package/src/preprocessor/helper/compatStyle.js +24 -23
- package/src/scale/Time.js +4 -4
- package/src/util/graphic.js +5 -5
- package/src/util/number.js +42 -21
- package/src/visual/VisualMapping.js +3 -3
- package/webpack.config.js +21 -7
- package/.npmignore +0 -10
package/dist/echarts.simple.js
CHANGED
|
@@ -116,10 +116,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
116
116
|
|
|
117
117
|
var zrender = __webpack_require__(87);
|
|
118
118
|
var zrUtil = __webpack_require__(4);
|
|
119
|
-
var colorTool = __webpack_require__(
|
|
120
|
-
var Eventful = __webpack_require__(
|
|
119
|
+
var colorTool = __webpack_require__(33);
|
|
120
|
+
var Eventful = __webpack_require__(27);
|
|
121
121
|
var timsort = __webpack_require__(91);
|
|
122
122
|
|
|
123
|
+
|
|
123
124
|
var each = zrUtil.each;
|
|
124
125
|
var parseClassType = ComponentModel.parseClassType;
|
|
125
126
|
|
|
@@ -145,6 +146,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
145
146
|
var OPTION_UPDATED = '__optionUpdated';
|
|
146
147
|
var ACTION_REG = /^[a-zA-Z0-9_]+$/;
|
|
147
148
|
|
|
149
|
+
|
|
148
150
|
function createRegisterEventWithLowercaseName(method) {
|
|
149
151
|
return function (eventName, handler, context) {
|
|
150
152
|
// Event name is all lowercase
|
|
@@ -1594,9 +1596,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
1594
1596
|
/**
|
|
1595
1597
|
* @type {number}
|
|
1596
1598
|
*/
|
|
1597
|
-
version: '3.7.
|
|
1599
|
+
version: '3.7.2',
|
|
1598
1600
|
dependencies: {
|
|
1599
|
-
zrender: '3.6.
|
|
1601
|
+
zrender: '3.6.2'
|
|
1600
1602
|
}
|
|
1601
1603
|
};
|
|
1602
1604
|
|
|
@@ -2028,7 +2030,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
2028
2030
|
update: 'downplay'
|
|
2029
2031
|
}, zrUtil.noop);
|
|
2030
2032
|
|
|
2031
|
-
|
|
2032
2033
|
// --------
|
|
2033
2034
|
// Exports
|
|
2034
2035
|
// --------
|
|
@@ -2045,7 +2046,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
2045
2046
|
echarts.throttle = throttle.throttle;
|
|
2046
2047
|
echarts.matrix = __webpack_require__(11);
|
|
2047
2048
|
echarts.vector = __webpack_require__(10);
|
|
2048
|
-
echarts.color = __webpack_require__(
|
|
2049
|
+
echarts.color = __webpack_require__(33);
|
|
2049
2050
|
|
|
2050
2051
|
echarts.util = {};
|
|
2051
2052
|
each([
|
|
@@ -4741,11 +4742,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
4741
4742
|
var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/; // jshint ignore:line
|
|
4742
4743
|
|
|
4743
4744
|
/**
|
|
4745
|
+
* Consider DST, it is incorrect to provide a method `getTimezoneOffset`
|
|
4746
|
+
* without time specified. So this method is removed.
|
|
4747
|
+
*
|
|
4744
4748
|
* @return {number} in minutes
|
|
4745
4749
|
*/
|
|
4746
|
-
number.getTimezoneOffset = function () {
|
|
4747
|
-
|
|
4748
|
-
};
|
|
4750
|
+
// number.getTimezoneOffset = function () {
|
|
4751
|
+
// return (new Date()).getTimezoneOffset();
|
|
4752
|
+
// };
|
|
4749
4753
|
|
|
4750
4754
|
/**
|
|
4751
4755
|
* @param {string|Date|number} value These values can be accepted:
|
|
@@ -4779,24 +4783,42 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
4779
4783
|
return new Date(NaN);
|
|
4780
4784
|
}
|
|
4781
4785
|
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4786
|
+
// Use local time when no timezone offset specifed.
|
|
4787
|
+
if (!match[8]) {
|
|
4788
|
+
// match[n] can only be string or undefined.
|
|
4789
|
+
// But take care of '12' + 1 => '121'.
|
|
4790
|
+
return new Date(
|
|
4791
|
+
+match[1],
|
|
4792
|
+
+(match[2] || 1) - 1,
|
|
4793
|
+
+match[3] || 1,
|
|
4794
|
+
+match[4] || 0,
|
|
4795
|
+
+(match[5] || 0),
|
|
4796
|
+
+match[6] || 0,
|
|
4797
|
+
+match[7] || 0
|
|
4798
|
+
);
|
|
4799
|
+
}
|
|
4800
|
+
// Timezoneoffset of Javascript Date has considered DST (Daylight Saving Time,
|
|
4801
|
+
// https://tc39.github.io/ecma262/#sec-daylight-saving-time-adjustment).
|
|
4802
|
+
// For example, system timezone is set as "Time Zone: America/Toronto",
|
|
4803
|
+
// then these code will get different result:
|
|
4804
|
+
// `new Date(1478411999999).getTimezoneOffset(); // get 240`
|
|
4805
|
+
// `new Date(1478412000000).getTimezoneOffset(); // get 300`
|
|
4806
|
+
// So we should not use `new Date`, but use `Date.UTC`.
|
|
4807
|
+
else {
|
|
4808
|
+
var hour = +match[4] || 0;
|
|
4809
|
+
if (match[8].toUpperCase() !== 'Z') {
|
|
4810
|
+
hour -= match[8].slice(0, 3);
|
|
4811
|
+
}
|
|
4812
|
+
return new Date(Date.UTC(
|
|
4813
|
+
+match[1],
|
|
4814
|
+
+(match[2] || 1) - 1,
|
|
4815
|
+
+match[3] || 1,
|
|
4816
|
+
hour,
|
|
4817
|
+
+(match[5] || 0),
|
|
4818
|
+
+match[6] || 0,
|
|
4819
|
+
+match[7] || 0
|
|
4820
|
+
));
|
|
4821
|
+
}
|
|
4800
4822
|
}
|
|
4801
4823
|
else if (value == null) {
|
|
4802
4824
|
return new Date(NaN);
|
|
@@ -7224,10 +7246,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
7224
7246
|
|
|
7225
7247
|
var pathTool = __webpack_require__(21);
|
|
7226
7248
|
var Path = __webpack_require__(22);
|
|
7227
|
-
var colorTool = __webpack_require__(
|
|
7249
|
+
var colorTool = __webpack_require__(33);
|
|
7228
7250
|
var matrix = __webpack_require__(11);
|
|
7229
7251
|
var vector = __webpack_require__(10);
|
|
7230
|
-
var Transformable = __webpack_require__(
|
|
7252
|
+
var Transformable = __webpack_require__(28);
|
|
7231
7253
|
var BoundingRect = __webpack_require__(9);
|
|
7232
7254
|
|
|
7233
7255
|
var round = Math.round;
|
|
@@ -7769,7 +7791,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
7769
7791
|
* for textFill, textStroke, textBackgroundColor, and textBorderColor.
|
|
7770
7792
|
* If autoColor specified, it is used as default textFill.
|
|
7771
7793
|
* useInsideStyle:
|
|
7772
|
-
* `true`: Use inside style (textFill, textStroke,
|
|
7794
|
+
* `true`: Use inside style (textFill, textStroke, textStrokeWidth)
|
|
7773
7795
|
* if `textFill` is not specified.
|
|
7774
7796
|
* `false`: Do not use inside style.
|
|
7775
7797
|
* `null/undefined`: use inside style if `isRectText` is true and
|
|
@@ -7882,7 +7904,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
7882
7904
|
|| globalTextStyle.color;
|
|
7883
7905
|
textStyle.textStroke = getAutoColor(textStyleModel.getShallow('textBorderColor'), opt)
|
|
7884
7906
|
|| globalTextStyle.textBorderColor;
|
|
7885
|
-
textStyle.
|
|
7907
|
+
textStyle.textStrokeWidth = zrUtil.retrieve2(
|
|
7886
7908
|
textStyleModel.getShallow('textBorderWidth'),
|
|
7887
7909
|
globalTextStyle.textBorderWidth
|
|
7888
7910
|
);
|
|
@@ -7966,13 +7988,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
7966
7988
|
insideRollback = {
|
|
7967
7989
|
textFill: null,
|
|
7968
7990
|
textStroke: textStyle.textStroke,
|
|
7969
|
-
|
|
7991
|
+
textStrokeWidth: textStyle.textStrokeWidth
|
|
7970
7992
|
};
|
|
7971
7993
|
textStyle.textFill = '#fff';
|
|
7972
7994
|
// Consider text with #fff overflow its container.
|
|
7973
7995
|
if (textStyle.textStroke == null) {
|
|
7974
7996
|
textStyle.textStroke = opt.autoColor;
|
|
7975
|
-
textStyle.
|
|
7997
|
+
textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2);
|
|
7976
7998
|
}
|
|
7977
7999
|
}
|
|
7978
8000
|
|
|
@@ -7984,7 +8006,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
7984
8006
|
if (insideRollback) {
|
|
7985
8007
|
style.textFill = insideRollback.textFill;
|
|
7986
8008
|
style.textStroke = insideRollback.textStroke;
|
|
7987
|
-
style.
|
|
8009
|
+
style.textStrokeWidth = insideRollback.textStrokeWidth;
|
|
7988
8010
|
}
|
|
7989
8011
|
}
|
|
7990
8012
|
|
|
@@ -9059,8 +9081,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9059
9081
|
|
|
9060
9082
|
var Style = __webpack_require__(24);
|
|
9061
9083
|
|
|
9062
|
-
var Element = __webpack_require__(
|
|
9063
|
-
var RectText = __webpack_require__(
|
|
9084
|
+
var Element = __webpack_require__(25);
|
|
9085
|
+
var RectText = __webpack_require__(36);
|
|
9064
9086
|
// var Stateful = require('./mixin/Stateful');
|
|
9065
9087
|
|
|
9066
9088
|
/**
|
|
@@ -9319,15 +9341,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9319
9341
|
|
|
9320
9342
|
/***/ }),
|
|
9321
9343
|
/* 24 */
|
|
9322
|
-
/***/ (function(module, exports
|
|
9344
|
+
/***/ (function(module, exports) {
|
|
9323
9345
|
|
|
9324
9346
|
/**
|
|
9325
9347
|
* @module zrender/graphic/Style
|
|
9326
9348
|
*/
|
|
9327
9349
|
|
|
9328
9350
|
|
|
9329
|
-
var textHelper = __webpack_require__(25);
|
|
9330
|
-
|
|
9331
9351
|
var STYLE_COMMON_PROPS = [
|
|
9332
9352
|
['shadowBlur', 0], ['shadowOffsetX', 0], ['shadowOffsetY', 0], ['shadowColor', '#000'],
|
|
9333
9353
|
['lineCap', 'butt'], ['lineJoin', 'miter'], ['miterLimit', 10]
|
|
@@ -9517,11 +9537,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9517
9537
|
/**
|
|
9518
9538
|
* textStroke may be set as some color as a default
|
|
9519
9539
|
* value in upper applicaion, where the default value
|
|
9520
|
-
* of
|
|
9540
|
+
* of textStrokeWidth should be 0 to make sure that
|
|
9521
9541
|
* user can choose to do not use text stroke.
|
|
9522
9542
|
* @type {number}
|
|
9523
9543
|
*/
|
|
9524
|
-
|
|
9544
|
+
textStrokeWidth: 0,
|
|
9525
9545
|
|
|
9526
9546
|
/**
|
|
9527
9547
|
* @type {number}
|
|
@@ -9801,597 +9821,16 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9801
9821
|
/* 25 */
|
|
9802
9822
|
/***/ (function(module, exports, __webpack_require__) {
|
|
9803
9823
|
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
var textContain = __webpack_require__(8);
|
|
9807
|
-
var util = __webpack_require__(4);
|
|
9808
|
-
var roundRectHelper = __webpack_require__(26);
|
|
9809
|
-
var imageHelper = __webpack_require__(12);
|
|
9810
|
-
|
|
9811
|
-
var retrieve3 = util.retrieve3;
|
|
9812
|
-
var retrieve2 = util.retrieve2;
|
|
9813
|
-
|
|
9814
|
-
// TODO: Have not support 'start', 'end' yet.
|
|
9815
|
-
var VALID_TEXT_ALIGN = {left: 1, right: 1, center: 1};
|
|
9816
|
-
var VALID_TEXT_VERTICAL_ALIGN = {top: 1, bottom: 1, middle: 1};
|
|
9817
|
-
|
|
9818
|
-
var helper = {};
|
|
9819
|
-
|
|
9820
|
-
/**
|
|
9821
|
-
* @param {module:zrender/graphic/Style} style
|
|
9822
|
-
* @return {module:zrender/graphic/Style} The input style.
|
|
9823
|
-
*/
|
|
9824
|
-
helper.normalizeTextStyle = function (style) {
|
|
9825
|
-
normalizeStyle(style);
|
|
9826
|
-
util.each(style.rich, normalizeStyle);
|
|
9827
|
-
return style;
|
|
9828
|
-
};
|
|
9829
|
-
|
|
9830
|
-
function normalizeStyle(style) {
|
|
9831
|
-
if (style) {
|
|
9832
|
-
|
|
9833
|
-
style.font = textContain.makeFont(style);
|
|
9834
|
-
|
|
9835
|
-
var textAlign = style.textAlign;
|
|
9836
|
-
textAlign === 'middle' && (textAlign = 'center');
|
|
9837
|
-
style.textAlign = (
|
|
9838
|
-
textAlign == null || VALID_TEXT_ALIGN[textAlign]
|
|
9839
|
-
) ? textAlign : 'left';
|
|
9840
|
-
|
|
9841
|
-
// Compatible with textBaseline.
|
|
9842
|
-
var textVerticalAlign = style.textVerticalAlign || style.textBaseline;
|
|
9843
|
-
textVerticalAlign === 'center' && (textVerticalAlign = 'middle');
|
|
9844
|
-
style.textVerticalAlign = (
|
|
9845
|
-
textVerticalAlign == null || VALID_TEXT_VERTICAL_ALIGN[textVerticalAlign]
|
|
9846
|
-
) ? textVerticalAlign : 'top';
|
|
9847
|
-
|
|
9848
|
-
var textPadding = style.textPadding;
|
|
9849
|
-
if (textPadding) {
|
|
9850
|
-
style.textPadding = util.normalizeCssArray(style.textPadding);
|
|
9851
|
-
}
|
|
9852
|
-
}
|
|
9853
|
-
}
|
|
9854
|
-
|
|
9855
|
-
/**
|
|
9856
|
-
* @param {CanvasRenderingContext2D} ctx
|
|
9857
|
-
* @param {string} text
|
|
9858
|
-
* @param {module:zrender/graphic/Style} style
|
|
9859
|
-
* @param {Object|boolean} [rect] {x, y, width, height}
|
|
9860
|
-
* If set false, rect text is not used.
|
|
9861
|
-
*/
|
|
9862
|
-
helper.renderText = function (hostEl, ctx, text, style, rect) {
|
|
9863
|
-
style.rich
|
|
9864
|
-
? renderRichText(hostEl, ctx, text, style, rect)
|
|
9865
|
-
: renderPlainText(hostEl, ctx, text, style, rect);
|
|
9866
|
-
};
|
|
9867
|
-
|
|
9868
|
-
function renderPlainText(hostEl, ctx, text, style, rect) {
|
|
9869
|
-
var font = setCtx(ctx, 'font', style.font || textContain.DEFAULT_FONT);
|
|
9870
|
-
|
|
9871
|
-
var textPadding = style.textPadding;
|
|
9872
|
-
|
|
9873
|
-
var contentBlock = hostEl.__textCotentBlock;
|
|
9874
|
-
if (!contentBlock || hostEl.__dirty) {
|
|
9875
|
-
contentBlock = hostEl.__textCotentBlock = textContain.parsePlainText(
|
|
9876
|
-
text, font, textPadding, style.truncate
|
|
9877
|
-
);
|
|
9878
|
-
}
|
|
9879
|
-
|
|
9880
|
-
var outerHeight = contentBlock.outerHeight;
|
|
9881
|
-
|
|
9882
|
-
var textLines = contentBlock.lines;
|
|
9883
|
-
var lineHeight = contentBlock.lineHeight;
|
|
9884
|
-
|
|
9885
|
-
var boxPos = getBoxPosition(outerHeight, style, rect);
|
|
9886
|
-
var baseX = boxPos.baseX;
|
|
9887
|
-
var baseY = boxPos.baseY;
|
|
9888
|
-
var textAlign = boxPos.textAlign;
|
|
9889
|
-
var textVerticalAlign = boxPos.textVerticalAlign;
|
|
9890
|
-
|
|
9891
|
-
// Origin of textRotation should be the base point of text drawing.
|
|
9892
|
-
applyTextRotation(ctx, style, rect, baseX, baseY);
|
|
9893
|
-
|
|
9894
|
-
var boxY = textContain.adjustTextY(baseY, outerHeight, textVerticalAlign);
|
|
9895
|
-
var textX = baseX;
|
|
9896
|
-
var textY = boxY;
|
|
9897
|
-
|
|
9898
|
-
var needDrawBg = needDrawBackground(style);
|
|
9899
|
-
if (needDrawBg || textPadding) {
|
|
9900
|
-
// Consider performance, do not call getTextWidth util necessary.
|
|
9901
|
-
var textWidth = textContain.getWidth(text, font);
|
|
9902
|
-
var outerWidth = textWidth;
|
|
9903
|
-
textPadding && (outerWidth += textPadding[1] + textPadding[3]);
|
|
9904
|
-
var boxX = textContain.adjustTextX(baseX, outerWidth, textAlign);
|
|
9905
|
-
|
|
9906
|
-
needDrawBg && drawBackground(hostEl, ctx, style, boxX, boxY, outerWidth, outerHeight);
|
|
9907
|
-
|
|
9908
|
-
if (textPadding) {
|
|
9909
|
-
textX = getTextXForPadding(baseX, textAlign, textPadding);
|
|
9910
|
-
textY += textPadding[0];
|
|
9911
|
-
}
|
|
9912
|
-
}
|
|
9913
|
-
|
|
9914
|
-
setCtx(ctx, 'textAlign', textAlign || 'left');
|
|
9915
|
-
// Force baseline to be "middle". Otherwise, if using "top", the
|
|
9916
|
-
// text will offset downward a little bit in font "Microsoft YaHei".
|
|
9917
|
-
setCtx(ctx, 'textBaseline', 'middle');
|
|
9918
|
-
|
|
9919
|
-
// Always set shadowBlur and shadowOffset to avoid leak from displayable.
|
|
9920
|
-
setCtx(ctx, 'shadowBlur', style.textShadowBlur || 0);
|
|
9921
|
-
setCtx(ctx, 'shadowColor', style.textShadowColor || 'transparent');
|
|
9922
|
-
setCtx(ctx, 'shadowOffsetX', style.textShadowOffsetX || 0);
|
|
9923
|
-
setCtx(ctx, 'shadowOffsetY', style.textShadowOffsetY || 0);
|
|
9924
|
-
|
|
9925
|
-
// `textBaseline` is set as 'middle'.
|
|
9926
|
-
textY += lineHeight / 2;
|
|
9927
|
-
|
|
9928
|
-
var textLineWidth = style.textLineWidth;
|
|
9929
|
-
var textStroke = getStroke(style.textStroke, textLineWidth);
|
|
9930
|
-
var textFill = getFill(style.textFill);
|
|
9931
|
-
|
|
9932
|
-
if (textStroke) {
|
|
9933
|
-
setCtx(ctx, 'lineWidth', textLineWidth);
|
|
9934
|
-
setCtx(ctx, 'strokeStyle', textStroke);
|
|
9935
|
-
}
|
|
9936
|
-
if (textFill) {
|
|
9937
|
-
setCtx(ctx, 'fillStyle', textFill);
|
|
9938
|
-
}
|
|
9939
|
-
|
|
9940
|
-
for (var i = 0; i < textLines.length; i++) {
|
|
9941
|
-
// Fill after stroke so the outline will not cover the main part.
|
|
9942
|
-
textStroke && ctx.strokeText(textLines[i], textX, textY);
|
|
9943
|
-
textFill && ctx.fillText(textLines[i], textX, textY);
|
|
9944
|
-
textY += lineHeight;
|
|
9945
|
-
}
|
|
9946
|
-
}
|
|
9947
|
-
|
|
9948
|
-
function renderRichText(hostEl, ctx, text, style, rect) {
|
|
9949
|
-
var contentBlock = hostEl.__textCotentBlock;
|
|
9950
|
-
|
|
9951
|
-
if (!contentBlock || hostEl.__dirty) {
|
|
9952
|
-
contentBlock = hostEl.__textCotentBlock = textContain.parseRichText(text, style);
|
|
9953
|
-
}
|
|
9954
|
-
|
|
9955
|
-
drawRichText(hostEl, ctx, contentBlock, style, rect);
|
|
9956
|
-
}
|
|
9957
|
-
|
|
9958
|
-
function drawRichText(hostEl, ctx, contentBlock, style, rect) {
|
|
9959
|
-
var contentWidth = contentBlock.width;
|
|
9960
|
-
var outerWidth = contentBlock.outerWidth;
|
|
9961
|
-
var outerHeight = contentBlock.outerHeight;
|
|
9962
|
-
var textPadding = style.textPadding;
|
|
9963
|
-
|
|
9964
|
-
var boxPos = getBoxPosition(outerHeight, style, rect);
|
|
9965
|
-
var baseX = boxPos.baseX;
|
|
9966
|
-
var baseY = boxPos.baseY;
|
|
9967
|
-
var textAlign = boxPos.textAlign;
|
|
9968
|
-
var textVerticalAlign = boxPos.textVerticalAlign;
|
|
9969
|
-
|
|
9970
|
-
// Origin of textRotation should be the base point of text drawing.
|
|
9971
|
-
applyTextRotation(ctx, style, rect, baseX, baseY);
|
|
9972
|
-
|
|
9973
|
-
var boxX = textContain.adjustTextX(baseX, outerWidth, textAlign);
|
|
9974
|
-
var boxY = textContain.adjustTextY(baseY, outerHeight, textVerticalAlign);
|
|
9975
|
-
var xLeft = boxX;
|
|
9976
|
-
var lineTop = boxY;
|
|
9977
|
-
if (textPadding) {
|
|
9978
|
-
xLeft += textPadding[3];
|
|
9979
|
-
lineTop += textPadding[0];
|
|
9980
|
-
}
|
|
9981
|
-
var xRight = xLeft + contentWidth;
|
|
9982
|
-
|
|
9983
|
-
needDrawBackground(style) && drawBackground(
|
|
9984
|
-
hostEl, ctx, style, boxX, boxY, outerWidth, outerHeight
|
|
9985
|
-
);
|
|
9986
|
-
|
|
9987
|
-
for (var i = 0; i < contentBlock.lines.length; i++) {
|
|
9988
|
-
var line = contentBlock.lines[i];
|
|
9989
|
-
var tokens = line.tokens;
|
|
9990
|
-
var tokenCount = tokens.length;
|
|
9991
|
-
var lineHeight = line.lineHeight;
|
|
9992
|
-
var usedWidth = line.width;
|
|
9993
|
-
|
|
9994
|
-
var leftIndex = 0;
|
|
9995
|
-
var lineXLeft = xLeft;
|
|
9996
|
-
var lineXRight = xRight;
|
|
9997
|
-
var rightIndex = tokenCount - 1;
|
|
9998
|
-
var token;
|
|
9999
|
-
|
|
10000
|
-
while (
|
|
10001
|
-
leftIndex < tokenCount
|
|
10002
|
-
&& (token = tokens[leftIndex], !token.textAlign || token.textAlign === 'left')
|
|
10003
|
-
) {
|
|
10004
|
-
placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXLeft, 'left');
|
|
10005
|
-
usedWidth -= token.width;
|
|
10006
|
-
lineXLeft += token.width;
|
|
10007
|
-
leftIndex++;
|
|
10008
|
-
}
|
|
10009
|
-
|
|
10010
|
-
while (
|
|
10011
|
-
rightIndex >= 0
|
|
10012
|
-
&& (token = tokens[rightIndex], token.textAlign === 'right')
|
|
10013
|
-
) {
|
|
10014
|
-
placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXRight, 'right');
|
|
10015
|
-
usedWidth -= token.width;
|
|
10016
|
-
lineXRight -= token.width;
|
|
10017
|
-
rightIndex--;
|
|
10018
|
-
}
|
|
10019
|
-
|
|
10020
|
-
// The other tokens are placed as textAlign 'center' if there is enough space.
|
|
10021
|
-
lineXLeft += (contentWidth - (lineXLeft - xLeft) - (xRight - lineXRight) - usedWidth) / 2;
|
|
10022
|
-
while (leftIndex <= rightIndex) {
|
|
10023
|
-
token = tokens[leftIndex];
|
|
10024
|
-
// Consider width specified by user, use 'center' rather than 'left'.
|
|
10025
|
-
placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXLeft + token.width / 2, 'center');
|
|
10026
|
-
lineXLeft += token.width;
|
|
10027
|
-
leftIndex++;
|
|
10028
|
-
}
|
|
10029
|
-
|
|
10030
|
-
lineTop += lineHeight;
|
|
10031
|
-
}
|
|
10032
|
-
}
|
|
10033
|
-
|
|
10034
|
-
function applyTextRotation(ctx, style, rect, x, y) {
|
|
10035
|
-
// textRotation only apply in RectText.
|
|
10036
|
-
if (rect && style.textRotation) {
|
|
10037
|
-
var origin = style.textOrigin;
|
|
10038
|
-
if (origin === 'center') {
|
|
10039
|
-
x = rect.width / 2 + rect.x;
|
|
10040
|
-
y = rect.height / 2 + rect.y;
|
|
10041
|
-
}
|
|
10042
|
-
else if (origin) {
|
|
10043
|
-
x = origin[0] + rect.x;
|
|
10044
|
-
y = origin[1] + rect.y;
|
|
10045
|
-
}
|
|
10046
|
-
|
|
10047
|
-
ctx.translate(x, y);
|
|
10048
|
-
// Positive: anticlockwise
|
|
10049
|
-
ctx.rotate(-style.textRotation);
|
|
10050
|
-
ctx.translate(-x, -y);
|
|
10051
|
-
}
|
|
10052
|
-
}
|
|
10053
|
-
|
|
10054
|
-
function placeToken(hostEl, ctx, token, style, lineHeight, lineTop, x, textAlign) {
|
|
10055
|
-
var tokenStyle = style.rich[token.styleName] || {};
|
|
10056
|
-
|
|
10057
|
-
// 'ctx.textBaseline' is always set as 'middle', for sake of
|
|
10058
|
-
// the bias of "Microsoft YaHei".
|
|
10059
|
-
var textVerticalAlign = token.textVerticalAlign;
|
|
10060
|
-
var y = lineTop + lineHeight / 2;
|
|
10061
|
-
if (textVerticalAlign === 'top') {
|
|
10062
|
-
y = lineTop + token.height / 2;
|
|
10063
|
-
}
|
|
10064
|
-
else if (textVerticalAlign === 'bottom') {
|
|
10065
|
-
y = lineTop + lineHeight - token.height / 2;
|
|
10066
|
-
}
|
|
10067
|
-
|
|
10068
|
-
!token.isLineHolder && needDrawBackground(tokenStyle) && drawBackground(
|
|
10069
|
-
hostEl,
|
|
10070
|
-
ctx,
|
|
10071
|
-
tokenStyle,
|
|
10072
|
-
textAlign === 'right'
|
|
10073
|
-
? x - token.width
|
|
10074
|
-
: textAlign === 'center'
|
|
10075
|
-
? x - token.width / 2
|
|
10076
|
-
: x,
|
|
10077
|
-
y - token.height / 2,
|
|
10078
|
-
token.width,
|
|
10079
|
-
token.height
|
|
10080
|
-
);
|
|
10081
|
-
|
|
10082
|
-
var textPadding = token.textPadding;
|
|
10083
|
-
if (textPadding) {
|
|
10084
|
-
x = getTextXForPadding(x, textAlign, textPadding);
|
|
10085
|
-
y -= token.height / 2 - textPadding[2] - token.textHeight / 2;
|
|
10086
|
-
}
|
|
10087
|
-
|
|
10088
|
-
setCtx(ctx, 'shadowBlur', retrieve3(tokenStyle.textShadowBlur, style.textShadowBlur, 0));
|
|
10089
|
-
setCtx(ctx, 'shadowColor', tokenStyle.textShadowColor || style.textShadowColor || 'transparent');
|
|
10090
|
-
setCtx(ctx, 'shadowOffsetX', retrieve3(tokenStyle.textShadowOffsetX, style.textShadowOffsetX, 0));
|
|
10091
|
-
setCtx(ctx, 'shadowOffsetY', retrieve3(tokenStyle.textShadowOffsetY, style.textShadowOffsetY, 0));
|
|
10092
|
-
|
|
10093
|
-
setCtx(ctx, 'textAlign', textAlign);
|
|
10094
|
-
// Force baseline to be "middle". Otherwise, if using "top", the
|
|
10095
|
-
// text will offset downward a little bit in font "Microsoft YaHei".
|
|
10096
|
-
setCtx(ctx, 'textBaseline', 'middle');
|
|
10097
|
-
|
|
10098
|
-
setCtx(ctx, 'font', token.font || textContain.DEFAULT_FONT);
|
|
10099
|
-
|
|
10100
|
-
var textStroke = getStroke(tokenStyle.textStroke || style.textStroke, textLineWidth);
|
|
10101
|
-
var textFill = getFill(tokenStyle.textFill || style.textFill);
|
|
10102
|
-
var textLineWidth = retrieve2(tokenStyle.textLineWidth, style.textLineWidth);
|
|
10103
|
-
|
|
10104
|
-
// Fill after stroke so the outline will not cover the main part.
|
|
10105
|
-
if (textStroke) {
|
|
10106
|
-
setCtx(ctx, 'lineWidth', textLineWidth);
|
|
10107
|
-
setCtx(ctx, 'strokeStyle', textStroke);
|
|
10108
|
-
ctx.strokeText(token.text, x, y);
|
|
10109
|
-
}
|
|
10110
|
-
if (textFill) {
|
|
10111
|
-
setCtx(ctx, 'fillStyle', textFill);
|
|
10112
|
-
ctx.fillText(token.text, x, y);
|
|
10113
|
-
}
|
|
10114
|
-
}
|
|
10115
|
-
|
|
10116
|
-
function needDrawBackground(style) {
|
|
10117
|
-
return style.textBackgroundColor
|
|
10118
|
-
|| (style.textBorderWidth && style.textBorderColor);
|
|
10119
|
-
}
|
|
10120
|
-
|
|
10121
|
-
// style: {textBackgroundColor, textBorderWidth, textBorderColor, textBorderRadius}
|
|
10122
|
-
// shape: {x, y, width, height}
|
|
10123
|
-
function drawBackground(hostEl, ctx, style, x, y, width, height) {
|
|
10124
|
-
var textBackgroundColor = style.textBackgroundColor;
|
|
10125
|
-
var textBorderWidth = style.textBorderWidth;
|
|
10126
|
-
var textBorderColor = style.textBorderColor;
|
|
10127
|
-
var isPlainBg = util.isString(textBackgroundColor);
|
|
10128
|
-
|
|
10129
|
-
setCtx(ctx, 'shadowBlur', style.textBoxShadowBlur || 0);
|
|
10130
|
-
setCtx(ctx, 'shadowColor', style.textBoxShadowColor || 'transparent');
|
|
10131
|
-
setCtx(ctx, 'shadowOffsetX', style.textBoxShadowOffsetX || 0);
|
|
10132
|
-
setCtx(ctx, 'shadowOffsetY', style.textBoxShadowOffsetY || 0);
|
|
10133
|
-
|
|
10134
|
-
if (isPlainBg || (textBorderWidth && textBorderColor)) {
|
|
10135
|
-
ctx.beginPath();
|
|
10136
|
-
var textBorderRadius = style.textBorderRadius;
|
|
10137
|
-
if (!textBorderRadius) {
|
|
10138
|
-
ctx.rect(x, y, width, height);
|
|
10139
|
-
}
|
|
10140
|
-
else {
|
|
10141
|
-
roundRectHelper.buildPath(ctx, {
|
|
10142
|
-
x: x, y: y, width: width, height: height, r: textBorderRadius
|
|
10143
|
-
});
|
|
10144
|
-
}
|
|
10145
|
-
ctx.closePath();
|
|
10146
|
-
}
|
|
10147
|
-
|
|
10148
|
-
if (isPlainBg) {
|
|
10149
|
-
setCtx(ctx, 'fillStyle', textBackgroundColor);
|
|
10150
|
-
ctx.fill();
|
|
10151
|
-
}
|
|
10152
|
-
else if (util.isObject(textBackgroundColor)) {
|
|
10153
|
-
var image = textBackgroundColor.image;
|
|
10154
|
-
|
|
10155
|
-
image = imageHelper.createOrUpdateImage(
|
|
10156
|
-
image, null, hostEl, onBgImageLoaded, textBackgroundColor
|
|
10157
|
-
);
|
|
10158
|
-
if (image && imageHelper.isImageReady(image)) {
|
|
10159
|
-
ctx.drawImage(image, x, y, width, height);
|
|
10160
|
-
}
|
|
10161
|
-
}
|
|
10162
|
-
|
|
10163
|
-
if (textBorderWidth && textBorderColor) {
|
|
10164
|
-
setCtx(ctx, 'lineWidth', textBorderWidth);
|
|
10165
|
-
setCtx(ctx, 'strokeStyle', textBorderColor);
|
|
10166
|
-
ctx.stroke();
|
|
10167
|
-
}
|
|
10168
|
-
}
|
|
10169
|
-
|
|
10170
|
-
function onBgImageLoaded(image, textBackgroundColor) {
|
|
10171
|
-
// Replace image, so that `contain/text.js#parseRichText`
|
|
10172
|
-
// will get correct result in next tick.
|
|
10173
|
-
textBackgroundColor.image = image;
|
|
10174
|
-
}
|
|
10175
|
-
|
|
10176
|
-
function getBoxPosition(blockHeiht, style, rect) {
|
|
10177
|
-
var baseX = style.x || 0;
|
|
10178
|
-
var baseY = style.y || 0;
|
|
10179
|
-
var textAlign = style.textAlign;
|
|
10180
|
-
var textVerticalAlign = style.textVerticalAlign;
|
|
10181
|
-
|
|
10182
|
-
// Text position represented by coord
|
|
10183
|
-
if (rect) {
|
|
10184
|
-
var textPosition = style.textPosition;
|
|
10185
|
-
if (textPosition instanceof Array) {
|
|
10186
|
-
// Percent
|
|
10187
|
-
baseX = rect.x + parsePercent(textPosition[0], rect.width);
|
|
10188
|
-
baseY = rect.y + parsePercent(textPosition[1], rect.height);
|
|
10189
|
-
}
|
|
10190
|
-
else {
|
|
10191
|
-
var res = textContain.adjustTextPositionOnRect(
|
|
10192
|
-
textPosition, rect, style.textDistance
|
|
10193
|
-
);
|
|
10194
|
-
baseX = res.x;
|
|
10195
|
-
baseY = res.y;
|
|
10196
|
-
// Default align and baseline when has textPosition
|
|
10197
|
-
textAlign = textAlign || res.textAlign;
|
|
10198
|
-
textVerticalAlign = textVerticalAlign || res.textVerticalAlign;
|
|
10199
|
-
}
|
|
10200
|
-
|
|
10201
|
-
// textOffset is only support in RectText, otherwise
|
|
10202
|
-
// we have to adjust boundingRect for textOffset.
|
|
10203
|
-
var textOffset = style.textOffset;
|
|
10204
|
-
if (textOffset) {
|
|
10205
|
-
baseX += textOffset[0];
|
|
10206
|
-
baseY += textOffset[1];
|
|
10207
|
-
}
|
|
10208
|
-
}
|
|
10209
|
-
|
|
10210
|
-
return {
|
|
10211
|
-
baseX: baseX,
|
|
10212
|
-
baseY: baseY,
|
|
10213
|
-
textAlign: textAlign,
|
|
10214
|
-
textVerticalAlign: textVerticalAlign
|
|
10215
|
-
};
|
|
10216
|
-
}
|
|
10217
|
-
|
|
10218
|
-
function setCtx(ctx, prop, value) {
|
|
10219
|
-
// FIXME ??? performance try
|
|
10220
|
-
// if (ctx.__currentValues[prop] !== value) {
|
|
10221
|
-
ctx[prop] = ctx.__currentValues[prop] = value;
|
|
10222
|
-
// }
|
|
10223
|
-
return ctx[prop];
|
|
10224
|
-
}
|
|
10225
|
-
|
|
10226
|
-
/**
|
|
10227
|
-
* @param {string} [stroke] If specified, do not check style.textStroke.
|
|
10228
|
-
* @param {string} [lineWidth] If specified, do not check style.textStroke.
|
|
10229
|
-
* @param {number} style
|
|
10230
|
-
*/
|
|
10231
|
-
var getStroke = helper.getStroke = function (stroke, lineWidth) {
|
|
10232
|
-
return (stroke == null || lineWidth <= 0 || stroke === 'transparent' || stroke === 'none')
|
|
10233
|
-
? null
|
|
10234
|
-
// TODO pattern and gradient?
|
|
10235
|
-
: (stroke.image || stroke.colorStops)
|
|
10236
|
-
? '#000'
|
|
10237
|
-
: stroke;
|
|
10238
|
-
};
|
|
10239
|
-
|
|
10240
|
-
var getFill = helper.getFill = function (fill) {
|
|
10241
|
-
return (fill == null || fill === 'none')
|
|
10242
|
-
? null
|
|
10243
|
-
// TODO pattern and gradient?
|
|
10244
|
-
: (fill.image || fill.colorStops)
|
|
10245
|
-
? '#000'
|
|
10246
|
-
: fill;
|
|
10247
|
-
};
|
|
10248
|
-
|
|
10249
|
-
function parsePercent(value, maxValue) {
|
|
10250
|
-
if (typeof value === 'string') {
|
|
10251
|
-
if (value.lastIndexOf('%') >= 0) {
|
|
10252
|
-
return parseFloat(value) / 100 * maxValue;
|
|
10253
|
-
}
|
|
10254
|
-
return parseFloat(value);
|
|
10255
|
-
}
|
|
10256
|
-
return value;
|
|
10257
|
-
}
|
|
10258
|
-
|
|
10259
|
-
function getTextXForPadding(x, textAlign, textPadding) {
|
|
10260
|
-
return textAlign === 'right'
|
|
10261
|
-
? (x - textPadding[1])
|
|
10262
|
-
: textAlign === 'center'
|
|
10263
|
-
? (x + textPadding[3] / 2 - textPadding[1] / 2)
|
|
10264
|
-
: (x + textPadding[3]);
|
|
10265
|
-
}
|
|
10266
|
-
|
|
10267
|
-
/**
|
|
10268
|
-
* @param {string} text
|
|
10269
|
-
* @param {module:zrender/Style} style
|
|
10270
|
-
* @return {boolean}
|
|
10271
|
-
*/
|
|
10272
|
-
helper.needDrawText = function (text, style) {
|
|
10273
|
-
return text != null
|
|
10274
|
-
&& (text
|
|
10275
|
-
|| style.textBackgroundColor
|
|
10276
|
-
|| (style.textBorderWidth && style.textBorderColor)
|
|
10277
|
-
|| style.textPadding
|
|
10278
|
-
);
|
|
10279
|
-
};
|
|
10280
|
-
|
|
10281
|
-
module.exports = helper;
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
/***/ }),
|
|
10287
|
-
/* 26 */
|
|
10288
|
-
/***/ (function(module, exports) {
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
module.exports = {
|
|
10293
|
-
buildPath: function (ctx, shape) {
|
|
10294
|
-
var x = shape.x;
|
|
10295
|
-
var y = shape.y;
|
|
10296
|
-
var width = shape.width;
|
|
10297
|
-
var height = shape.height;
|
|
10298
|
-
var r = shape.r;
|
|
10299
|
-
var r1;
|
|
10300
|
-
var r2;
|
|
10301
|
-
var r3;
|
|
10302
|
-
var r4;
|
|
10303
|
-
|
|
10304
|
-
// Convert width and height to positive for better borderRadius
|
|
10305
|
-
if (width < 0) {
|
|
10306
|
-
x = x + width;
|
|
10307
|
-
width = -width;
|
|
10308
|
-
}
|
|
10309
|
-
if (height < 0) {
|
|
10310
|
-
y = y + height;
|
|
10311
|
-
height = -height;
|
|
10312
|
-
}
|
|
10313
|
-
|
|
10314
|
-
if (typeof r === 'number') {
|
|
10315
|
-
r1 = r2 = r3 = r4 = r;
|
|
10316
|
-
}
|
|
10317
|
-
else if (r instanceof Array) {
|
|
10318
|
-
if (r.length === 1) {
|
|
10319
|
-
r1 = r2 = r3 = r4 = r[0];
|
|
10320
|
-
}
|
|
10321
|
-
else if (r.length === 2) {
|
|
10322
|
-
r1 = r3 = r[0];
|
|
10323
|
-
r2 = r4 = r[1];
|
|
10324
|
-
}
|
|
10325
|
-
else if (r.length === 3) {
|
|
10326
|
-
r1 = r[0];
|
|
10327
|
-
r2 = r4 = r[1];
|
|
10328
|
-
r3 = r[2];
|
|
10329
|
-
}
|
|
10330
|
-
else {
|
|
10331
|
-
r1 = r[0];
|
|
10332
|
-
r2 = r[1];
|
|
10333
|
-
r3 = r[2];
|
|
10334
|
-
r4 = r[3];
|
|
10335
|
-
}
|
|
10336
|
-
}
|
|
10337
|
-
else {
|
|
10338
|
-
r1 = r2 = r3 = r4 = 0;
|
|
10339
|
-
}
|
|
10340
|
-
|
|
10341
|
-
var total;
|
|
10342
|
-
if (r1 + r2 > width) {
|
|
10343
|
-
total = r1 + r2;
|
|
10344
|
-
r1 *= width / total;
|
|
10345
|
-
r2 *= width / total;
|
|
10346
|
-
}
|
|
10347
|
-
if (r3 + r4 > width) {
|
|
10348
|
-
total = r3 + r4;
|
|
10349
|
-
r3 *= width / total;
|
|
10350
|
-
r4 *= width / total;
|
|
10351
|
-
}
|
|
10352
|
-
if (r2 + r3 > height) {
|
|
10353
|
-
total = r2 + r3;
|
|
10354
|
-
r2 *= height / total;
|
|
10355
|
-
r3 *= height / total;
|
|
10356
|
-
}
|
|
10357
|
-
if (r1 + r4 > height) {
|
|
10358
|
-
total = r1 + r4;
|
|
10359
|
-
r1 *= height / total;
|
|
10360
|
-
r4 *= height / total;
|
|
10361
|
-
}
|
|
10362
|
-
ctx.moveTo(x + r1, y);
|
|
10363
|
-
ctx.lineTo(x + width - r2, y);
|
|
10364
|
-
r2 !== 0 && ctx.quadraticCurveTo(
|
|
10365
|
-
x + width, y, x + width, y + r2
|
|
10366
|
-
);
|
|
10367
|
-
ctx.lineTo(x + width, y + height - r3);
|
|
10368
|
-
r3 !== 0 && ctx.quadraticCurveTo(
|
|
10369
|
-
x + width, y + height, x + width - r3, y + height
|
|
10370
|
-
);
|
|
10371
|
-
ctx.lineTo(x + r4, y + height);
|
|
10372
|
-
r4 !== 0 && ctx.quadraticCurveTo(
|
|
10373
|
-
x, y + height, x, y + height - r4
|
|
10374
|
-
);
|
|
10375
|
-
ctx.lineTo(x, y + r1);
|
|
10376
|
-
r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y);
|
|
10377
|
-
}
|
|
10378
|
-
};
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
/***/ }),
|
|
10382
|
-
/* 27 */
|
|
10383
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
10384
|
-
|
|
10385
9824
|
'use strict';
|
|
10386
9825
|
/**
|
|
10387
9826
|
* @module zrender/Element
|
|
10388
9827
|
*/
|
|
10389
9828
|
|
|
10390
9829
|
|
|
10391
|
-
var guid = __webpack_require__(
|
|
10392
|
-
var Eventful = __webpack_require__(
|
|
10393
|
-
var Transformable = __webpack_require__(
|
|
10394
|
-
var Animatable = __webpack_require__(
|
|
9830
|
+
var guid = __webpack_require__(26);
|
|
9831
|
+
var Eventful = __webpack_require__(27);
|
|
9832
|
+
var Transformable = __webpack_require__(28);
|
|
9833
|
+
var Animatable = __webpack_require__(29);
|
|
10395
9834
|
var zrUtil = __webpack_require__(4);
|
|
10396
9835
|
|
|
10397
9836
|
/**
|
|
@@ -10647,7 +10086,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
10647
10086
|
|
|
10648
10087
|
|
|
10649
10088
|
/***/ }),
|
|
10650
|
-
/*
|
|
10089
|
+
/* 26 */
|
|
10651
10090
|
/***/ (function(module, exports) {
|
|
10652
10091
|
|
|
10653
10092
|
/**
|
|
@@ -10666,7 +10105,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
10666
10105
|
|
|
10667
10106
|
|
|
10668
10107
|
/***/ }),
|
|
10669
|
-
/*
|
|
10108
|
+
/* 27 */
|
|
10670
10109
|
/***/ (function(module, exports) {
|
|
10671
10110
|
|
|
10672
10111
|
/**
|
|
@@ -10974,7 +10413,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
10974
10413
|
|
|
10975
10414
|
|
|
10976
10415
|
/***/ }),
|
|
10977
|
-
/*
|
|
10416
|
+
/* 28 */
|
|
10978
10417
|
/***/ (function(module, exports, __webpack_require__) {
|
|
10979
10418
|
|
|
10980
10419
|
'use strict';
|
|
@@ -11242,7 +10681,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
11242
10681
|
|
|
11243
10682
|
|
|
11244
10683
|
/***/ }),
|
|
11245
|
-
/*
|
|
10684
|
+
/* 29 */
|
|
11246
10685
|
/***/ (function(module, exports, __webpack_require__) {
|
|
11247
10686
|
|
|
11248
10687
|
'use strict';
|
|
@@ -11251,12 +10690,12 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
11251
10690
|
*/
|
|
11252
10691
|
|
|
11253
10692
|
|
|
11254
|
-
var Animator = __webpack_require__(
|
|
10693
|
+
var Animator = __webpack_require__(30);
|
|
11255
10694
|
var util = __webpack_require__(4);
|
|
11256
10695
|
var isString = util.isString;
|
|
11257
10696
|
var isFunction = util.isFunction;
|
|
11258
10697
|
var isObject = util.isObject;
|
|
11259
|
-
var log = __webpack_require__(
|
|
10698
|
+
var log = __webpack_require__(34);
|
|
11260
10699
|
|
|
11261
10700
|
/**
|
|
11262
10701
|
* @alias modue:zrender/mixin/Animatable
|
|
@@ -11521,7 +10960,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
11521
10960
|
|
|
11522
10961
|
|
|
11523
10962
|
/***/ }),
|
|
11524
|
-
/*
|
|
10963
|
+
/* 30 */
|
|
11525
10964
|
/***/ (function(module, exports, __webpack_require__) {
|
|
11526
10965
|
|
|
11527
10966
|
/**
|
|
@@ -11529,8 +10968,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
11529
10968
|
*/
|
|
11530
10969
|
|
|
11531
10970
|
|
|
11532
|
-
var Clip = __webpack_require__(
|
|
11533
|
-
var color = __webpack_require__(
|
|
10971
|
+
var Clip = __webpack_require__(31);
|
|
10972
|
+
var color = __webpack_require__(33);
|
|
11534
10973
|
var util = __webpack_require__(4);
|
|
11535
10974
|
var isArrayLike = util.isArrayLike;
|
|
11536
10975
|
|
|
@@ -12181,7 +11620,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
12181
11620
|
|
|
12182
11621
|
|
|
12183
11622
|
/***/ }),
|
|
12184
|
-
/*
|
|
11623
|
+
/* 31 */
|
|
12185
11624
|
/***/ (function(module, exports, __webpack_require__) {
|
|
12186
11625
|
|
|
12187
11626
|
/**
|
|
@@ -12200,7 +11639,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
12200
11639
|
*/
|
|
12201
11640
|
|
|
12202
11641
|
|
|
12203
|
-
var easingFuncs = __webpack_require__(
|
|
11642
|
+
var easingFuncs = __webpack_require__(32);
|
|
12204
11643
|
|
|
12205
11644
|
function Clip(options) {
|
|
12206
11645
|
|
|
@@ -12310,7 +11749,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
12310
11749
|
|
|
12311
11750
|
|
|
12312
11751
|
/***/ }),
|
|
12313
|
-
/*
|
|
11752
|
+
/* 32 */
|
|
12314
11753
|
/***/ (function(module, exports) {
|
|
12315
11754
|
|
|
12316
11755
|
/**
|
|
@@ -12661,7 +12100,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
12661
12100
|
|
|
12662
12101
|
|
|
12663
12102
|
/***/ }),
|
|
12664
|
-
/*
|
|
12103
|
+
/* 33 */
|
|
12665
12104
|
/***/ (function(module, exports, __webpack_require__) {
|
|
12666
12105
|
|
|
12667
12106
|
/**
|
|
@@ -12796,7 +12235,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
12796
12235
|
return m1;
|
|
12797
12236
|
}
|
|
12798
12237
|
|
|
12799
|
-
function
|
|
12238
|
+
function lerpNumber(a, b, p) {
|
|
12800
12239
|
return a + (b - a) * p;
|
|
12801
12240
|
}
|
|
12802
12241
|
|
|
@@ -13062,13 +12501,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
13062
12501
|
}
|
|
13063
12502
|
|
|
13064
12503
|
/**
|
|
13065
|
-
* Map value to color. Faster than
|
|
12504
|
+
* Map value to color. Faster than lerp methods because color is represented by rgba array.
|
|
13066
12505
|
* @param {number} normalizedValue A float between 0 and 1.
|
|
13067
12506
|
* @param {Array.<Array.<number>>} colors List of rgba color array
|
|
13068
12507
|
* @param {Array.<number>} [out] Mapped gba color array
|
|
13069
12508
|
* @return {Array.<number>} will be null/undefined if input illegal.
|
|
13070
12509
|
*/
|
|
13071
|
-
function
|
|
12510
|
+
function fastLerp(normalizedValue, colors, out) {
|
|
13072
12511
|
if (!(colors && colors.length)
|
|
13073
12512
|
|| !(normalizedValue >= 0 && normalizedValue <= 1)
|
|
13074
12513
|
) {
|
|
@@ -13083,13 +12522,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
13083
12522
|
var leftColor = colors[leftIndex];
|
|
13084
12523
|
var rightColor = colors[rightIndex];
|
|
13085
12524
|
var dv = value - leftIndex;
|
|
13086
|
-
out[0] = clampCssByte(
|
|
13087
|
-
out[1] = clampCssByte(
|
|
13088
|
-
out[2] = clampCssByte(
|
|
13089
|
-
out[3] = clampCssFloat(
|
|
12525
|
+
out[0] = clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv));
|
|
12526
|
+
out[1] = clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv));
|
|
12527
|
+
out[2] = clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv));
|
|
12528
|
+
out[3] = clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv));
|
|
13090
12529
|
|
|
13091
12530
|
return out;
|
|
13092
12531
|
}
|
|
12532
|
+
|
|
13093
12533
|
/**
|
|
13094
12534
|
* @param {number} normalizedValue A float between 0 and 1.
|
|
13095
12535
|
* @param {Array.<string>} colors Color list.
|
|
@@ -13098,7 +12538,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
13098
12538
|
* return {color: ..., leftIndex: ..., rightIndex: ..., value: ...},
|
|
13099
12539
|
* @memberOf module:zrender/util/color
|
|
13100
12540
|
*/
|
|
13101
|
-
function
|
|
12541
|
+
function lerp(normalizedValue, colors, fullOutput) {
|
|
13102
12542
|
if (!(colors && colors.length)
|
|
13103
12543
|
|| !(normalizedValue >= 0 && normalizedValue <= 1)
|
|
13104
12544
|
) {
|
|
@@ -13114,10 +12554,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
13114
12554
|
|
|
13115
12555
|
var color = stringify(
|
|
13116
12556
|
[
|
|
13117
|
-
clampCssByte(
|
|
13118
|
-
clampCssByte(
|
|
13119
|
-
clampCssByte(
|
|
13120
|
-
clampCssFloat(
|
|
12557
|
+
clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)),
|
|
12558
|
+
clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)),
|
|
12559
|
+
clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)),
|
|
12560
|
+
clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv))
|
|
13121
12561
|
],
|
|
13122
12562
|
'rgba'
|
|
13123
12563
|
);
|
|
@@ -13188,8 +12628,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
13188
12628
|
parse: parse,
|
|
13189
12629
|
lift: lift,
|
|
13190
12630
|
toHex: toHex,
|
|
13191
|
-
|
|
13192
|
-
|
|
12631
|
+
fastLerp: fastLerp,
|
|
12632
|
+
fastMapToColor: fastLerp, // Deprecated
|
|
12633
|
+
lerp: lerp,
|
|
12634
|
+
mapToColor: lerp, // Deprecated
|
|
13193
12635
|
modifyHSL: modifyHSL,
|
|
13194
12636
|
modifyAlpha: modifyAlpha,
|
|
13195
12637
|
stringify: stringify
|
|
@@ -13198,145 +12640,727 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
13198
12640
|
|
|
13199
12641
|
|
|
13200
12642
|
|
|
13201
|
-
/***/ }),
|
|
13202
|
-
/*
|
|
13203
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
12643
|
+
/***/ }),
|
|
12644
|
+
/* 34 */
|
|
12645
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
12646
|
+
|
|
12647
|
+
|
|
12648
|
+
var config = __webpack_require__(35);
|
|
12649
|
+
|
|
12650
|
+
/**
|
|
12651
|
+
* @exports zrender/tool/log
|
|
12652
|
+
* @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
|
|
12653
|
+
*/
|
|
12654
|
+
module.exports = function() {
|
|
12655
|
+
if (config.debugMode === 0) {
|
|
12656
|
+
return;
|
|
12657
|
+
}
|
|
12658
|
+
else if (config.debugMode == 1) {
|
|
12659
|
+
for (var k in arguments) {
|
|
12660
|
+
throw new Error(arguments[k]);
|
|
12661
|
+
}
|
|
12662
|
+
}
|
|
12663
|
+
else if (config.debugMode > 1) {
|
|
12664
|
+
for (var k in arguments) {
|
|
12665
|
+
console.log(arguments[k]);
|
|
12666
|
+
}
|
|
12667
|
+
}
|
|
12668
|
+
};
|
|
12669
|
+
|
|
12670
|
+
/* for debug
|
|
12671
|
+
return function(mes) {
|
|
12672
|
+
document.getElementById('wrong-message').innerHTML =
|
|
12673
|
+
mes + ' ' + (new Date() - 0)
|
|
12674
|
+
+ '<br/>'
|
|
12675
|
+
+ document.getElementById('wrong-message').innerHTML;
|
|
12676
|
+
};
|
|
12677
|
+
*/
|
|
12678
|
+
|
|
12679
|
+
|
|
12680
|
+
|
|
12681
|
+
/***/ }),
|
|
12682
|
+
/* 35 */
|
|
12683
|
+
/***/ (function(module, exports) {
|
|
12684
|
+
|
|
12685
|
+
|
|
12686
|
+
var dpr = 1;
|
|
12687
|
+
// If in browser environment
|
|
12688
|
+
if (typeof window !== 'undefined') {
|
|
12689
|
+
dpr = Math.max(window.devicePixelRatio || 1, 1);
|
|
12690
|
+
}
|
|
12691
|
+
/**
|
|
12692
|
+
* config默认配置项
|
|
12693
|
+
* @exports zrender/config
|
|
12694
|
+
* @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
|
|
12695
|
+
*/
|
|
12696
|
+
var config = {
|
|
12697
|
+
/**
|
|
12698
|
+
* debug日志选项:catchBrushException为true下有效
|
|
12699
|
+
* 0 : 不生成debug数据,发布用
|
|
12700
|
+
* 1 : 异常抛出,调试用
|
|
12701
|
+
* 2 : 控制台输出,调试用
|
|
12702
|
+
*/
|
|
12703
|
+
debugMode: 0,
|
|
12704
|
+
|
|
12705
|
+
// retina 屏幕优化
|
|
12706
|
+
devicePixelRatio: dpr
|
|
12707
|
+
};
|
|
12708
|
+
module.exports = config;
|
|
12709
|
+
|
|
12710
|
+
|
|
12711
|
+
|
|
12712
|
+
|
|
12713
|
+
/***/ }),
|
|
12714
|
+
/* 36 */
|
|
12715
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
12716
|
+
|
|
12717
|
+
/**
|
|
12718
|
+
* Mixin for drawing text in a element bounding rect
|
|
12719
|
+
* @module zrender/mixin/RectText
|
|
12720
|
+
*/
|
|
12721
|
+
|
|
12722
|
+
|
|
12723
|
+
|
|
12724
|
+
var textHelper = __webpack_require__(37);
|
|
12725
|
+
var BoundingRect = __webpack_require__(9);
|
|
12726
|
+
|
|
12727
|
+
var tmpRect = new BoundingRect();
|
|
12728
|
+
|
|
12729
|
+
var RectText = function () {};
|
|
12730
|
+
|
|
12731
|
+
RectText.prototype = {
|
|
12732
|
+
|
|
12733
|
+
constructor: RectText,
|
|
12734
|
+
|
|
12735
|
+
/**
|
|
12736
|
+
* Draw text in a rect with specified position.
|
|
12737
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
12738
|
+
* @param {Object} rect Displayable rect
|
|
12739
|
+
*/
|
|
12740
|
+
drawRectText: function (ctx, rect) {
|
|
12741
|
+
var style = this.style;
|
|
12742
|
+
|
|
12743
|
+
rect = style.textRect || rect;
|
|
12744
|
+
|
|
12745
|
+
// Optimize, avoid normalize every time.
|
|
12746
|
+
this.__dirty && textHelper.normalizeTextStyle(style, true);
|
|
12747
|
+
|
|
12748
|
+
var text = style.text;
|
|
12749
|
+
|
|
12750
|
+
// Convert to string
|
|
12751
|
+
text != null && (text += '');
|
|
12752
|
+
|
|
12753
|
+
if (!textHelper.needDrawText(text, style)) {
|
|
12754
|
+
return;
|
|
12755
|
+
}
|
|
12756
|
+
|
|
12757
|
+
// FIXME
|
|
12758
|
+
ctx.save();
|
|
12759
|
+
|
|
12760
|
+
// Transform rect to view space
|
|
12761
|
+
var transform = this.transform;
|
|
12762
|
+
if (!style.transformText) {
|
|
12763
|
+
if (transform) {
|
|
12764
|
+
tmpRect.copy(rect);
|
|
12765
|
+
tmpRect.applyTransform(transform);
|
|
12766
|
+
rect = tmpRect;
|
|
12767
|
+
}
|
|
12768
|
+
}
|
|
12769
|
+
else {
|
|
12770
|
+
this.setTransform(ctx);
|
|
12771
|
+
}
|
|
12772
|
+
|
|
12773
|
+
// transformText and textRotation can not be used at the same time.
|
|
12774
|
+
textHelper.renderText(this, ctx, text, style, rect);
|
|
12775
|
+
|
|
12776
|
+
ctx.restore();
|
|
12777
|
+
}
|
|
12778
|
+
};
|
|
12779
|
+
|
|
12780
|
+
module.exports = RectText;
|
|
12781
|
+
|
|
12782
|
+
|
|
12783
|
+
/***/ }),
|
|
12784
|
+
/* 37 */
|
|
12785
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
12786
|
+
|
|
12787
|
+
|
|
12788
|
+
|
|
12789
|
+
var textContain = __webpack_require__(8);
|
|
12790
|
+
var util = __webpack_require__(4);
|
|
12791
|
+
var roundRectHelper = __webpack_require__(38);
|
|
12792
|
+
var imageHelper = __webpack_require__(12);
|
|
12793
|
+
|
|
12794
|
+
var retrieve3 = util.retrieve3;
|
|
12795
|
+
var retrieve2 = util.retrieve2;
|
|
12796
|
+
|
|
12797
|
+
// TODO: Have not support 'start', 'end' yet.
|
|
12798
|
+
var VALID_TEXT_ALIGN = {left: 1, right: 1, center: 1};
|
|
12799
|
+
var VALID_TEXT_VERTICAL_ALIGN = {top: 1, bottom: 1, middle: 1};
|
|
12800
|
+
|
|
12801
|
+
var helper = {};
|
|
12802
|
+
|
|
12803
|
+
/**
|
|
12804
|
+
* @param {module:zrender/graphic/Style} style
|
|
12805
|
+
* @return {module:zrender/graphic/Style} The input style.
|
|
12806
|
+
*/
|
|
12807
|
+
helper.normalizeTextStyle = function (style) {
|
|
12808
|
+
normalizeStyle(style);
|
|
12809
|
+
util.each(style.rich, normalizeStyle);
|
|
12810
|
+
return style;
|
|
12811
|
+
};
|
|
12812
|
+
|
|
12813
|
+
function normalizeStyle(style) {
|
|
12814
|
+
if (style) {
|
|
12815
|
+
|
|
12816
|
+
style.font = textContain.makeFont(style);
|
|
12817
|
+
|
|
12818
|
+
var textAlign = style.textAlign;
|
|
12819
|
+
textAlign === 'middle' && (textAlign = 'center');
|
|
12820
|
+
style.textAlign = (
|
|
12821
|
+
textAlign == null || VALID_TEXT_ALIGN[textAlign]
|
|
12822
|
+
) ? textAlign : 'left';
|
|
12823
|
+
|
|
12824
|
+
// Compatible with textBaseline.
|
|
12825
|
+
var textVerticalAlign = style.textVerticalAlign || style.textBaseline;
|
|
12826
|
+
textVerticalAlign === 'center' && (textVerticalAlign = 'middle');
|
|
12827
|
+
style.textVerticalAlign = (
|
|
12828
|
+
textVerticalAlign == null || VALID_TEXT_VERTICAL_ALIGN[textVerticalAlign]
|
|
12829
|
+
) ? textVerticalAlign : 'top';
|
|
12830
|
+
|
|
12831
|
+
var textPadding = style.textPadding;
|
|
12832
|
+
if (textPadding) {
|
|
12833
|
+
style.textPadding = util.normalizeCssArray(style.textPadding);
|
|
12834
|
+
}
|
|
12835
|
+
}
|
|
12836
|
+
}
|
|
12837
|
+
|
|
12838
|
+
/**
|
|
12839
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
12840
|
+
* @param {string} text
|
|
12841
|
+
* @param {module:zrender/graphic/Style} style
|
|
12842
|
+
* @param {Object|boolean} [rect] {x, y, width, height}
|
|
12843
|
+
* If set false, rect text is not used.
|
|
12844
|
+
*/
|
|
12845
|
+
helper.renderText = function (hostEl, ctx, text, style, rect) {
|
|
12846
|
+
style.rich
|
|
12847
|
+
? renderRichText(hostEl, ctx, text, style, rect)
|
|
12848
|
+
: renderPlainText(hostEl, ctx, text, style, rect);
|
|
12849
|
+
};
|
|
12850
|
+
|
|
12851
|
+
function renderPlainText(hostEl, ctx, text, style, rect) {
|
|
12852
|
+
var font = setCtx(ctx, 'font', style.font || textContain.DEFAULT_FONT);
|
|
12853
|
+
|
|
12854
|
+
var textPadding = style.textPadding;
|
|
12855
|
+
|
|
12856
|
+
var contentBlock = hostEl.__textCotentBlock;
|
|
12857
|
+
if (!contentBlock || hostEl.__dirty) {
|
|
12858
|
+
contentBlock = hostEl.__textCotentBlock = textContain.parsePlainText(
|
|
12859
|
+
text, font, textPadding, style.truncate
|
|
12860
|
+
);
|
|
12861
|
+
}
|
|
12862
|
+
|
|
12863
|
+
var outerHeight = contentBlock.outerHeight;
|
|
12864
|
+
|
|
12865
|
+
var textLines = contentBlock.lines;
|
|
12866
|
+
var lineHeight = contentBlock.lineHeight;
|
|
12867
|
+
|
|
12868
|
+
var boxPos = getBoxPosition(outerHeight, style, rect);
|
|
12869
|
+
var baseX = boxPos.baseX;
|
|
12870
|
+
var baseY = boxPos.baseY;
|
|
12871
|
+
var textAlign = boxPos.textAlign;
|
|
12872
|
+
var textVerticalAlign = boxPos.textVerticalAlign;
|
|
12873
|
+
|
|
12874
|
+
// Origin of textRotation should be the base point of text drawing.
|
|
12875
|
+
applyTextRotation(ctx, style, rect, baseX, baseY);
|
|
12876
|
+
|
|
12877
|
+
var boxY = textContain.adjustTextY(baseY, outerHeight, textVerticalAlign);
|
|
12878
|
+
var textX = baseX;
|
|
12879
|
+
var textY = boxY;
|
|
12880
|
+
|
|
12881
|
+
var needDrawBg = needDrawBackground(style);
|
|
12882
|
+
if (needDrawBg || textPadding) {
|
|
12883
|
+
// Consider performance, do not call getTextWidth util necessary.
|
|
12884
|
+
var textWidth = textContain.getWidth(text, font);
|
|
12885
|
+
var outerWidth = textWidth;
|
|
12886
|
+
textPadding && (outerWidth += textPadding[1] + textPadding[3]);
|
|
12887
|
+
var boxX = textContain.adjustTextX(baseX, outerWidth, textAlign);
|
|
12888
|
+
|
|
12889
|
+
needDrawBg && drawBackground(hostEl, ctx, style, boxX, boxY, outerWidth, outerHeight);
|
|
12890
|
+
|
|
12891
|
+
if (textPadding) {
|
|
12892
|
+
textX = getTextXForPadding(baseX, textAlign, textPadding);
|
|
12893
|
+
textY += textPadding[0];
|
|
12894
|
+
}
|
|
12895
|
+
}
|
|
12896
|
+
|
|
12897
|
+
setCtx(ctx, 'textAlign', textAlign || 'left');
|
|
12898
|
+
// Force baseline to be "middle". Otherwise, if using "top", the
|
|
12899
|
+
// text will offset downward a little bit in font "Microsoft YaHei".
|
|
12900
|
+
setCtx(ctx, 'textBaseline', 'middle');
|
|
12901
|
+
|
|
12902
|
+
// Always set shadowBlur and shadowOffset to avoid leak from displayable.
|
|
12903
|
+
setCtx(ctx, 'shadowBlur', style.textShadowBlur || 0);
|
|
12904
|
+
setCtx(ctx, 'shadowColor', style.textShadowColor || 'transparent');
|
|
12905
|
+
setCtx(ctx, 'shadowOffsetX', style.textShadowOffsetX || 0);
|
|
12906
|
+
setCtx(ctx, 'shadowOffsetY', style.textShadowOffsetY || 0);
|
|
12907
|
+
|
|
12908
|
+
// `textBaseline` is set as 'middle'.
|
|
12909
|
+
textY += lineHeight / 2;
|
|
12910
|
+
|
|
12911
|
+
var textStrokeWidth = style.textStrokeWidth;
|
|
12912
|
+
var textStroke = getStroke(style.textStroke, textStrokeWidth);
|
|
12913
|
+
var textFill = getFill(style.textFill);
|
|
12914
|
+
|
|
12915
|
+
if (textStroke) {
|
|
12916
|
+
setCtx(ctx, 'lineWidth', textStrokeWidth);
|
|
12917
|
+
setCtx(ctx, 'strokeStyle', textStroke);
|
|
12918
|
+
}
|
|
12919
|
+
if (textFill) {
|
|
12920
|
+
setCtx(ctx, 'fillStyle', textFill);
|
|
12921
|
+
}
|
|
12922
|
+
|
|
12923
|
+
for (var i = 0; i < textLines.length; i++) {
|
|
12924
|
+
// Fill after stroke so the outline will not cover the main part.
|
|
12925
|
+
textStroke && ctx.strokeText(textLines[i], textX, textY);
|
|
12926
|
+
textFill && ctx.fillText(textLines[i], textX, textY);
|
|
12927
|
+
textY += lineHeight;
|
|
12928
|
+
}
|
|
12929
|
+
}
|
|
12930
|
+
|
|
12931
|
+
function renderRichText(hostEl, ctx, text, style, rect) {
|
|
12932
|
+
var contentBlock = hostEl.__textCotentBlock;
|
|
12933
|
+
|
|
12934
|
+
if (!contentBlock || hostEl.__dirty) {
|
|
12935
|
+
contentBlock = hostEl.__textCotentBlock = textContain.parseRichText(text, style);
|
|
12936
|
+
}
|
|
12937
|
+
|
|
12938
|
+
drawRichText(hostEl, ctx, contentBlock, style, rect);
|
|
12939
|
+
}
|
|
12940
|
+
|
|
12941
|
+
function drawRichText(hostEl, ctx, contentBlock, style, rect) {
|
|
12942
|
+
var contentWidth = contentBlock.width;
|
|
12943
|
+
var outerWidth = contentBlock.outerWidth;
|
|
12944
|
+
var outerHeight = contentBlock.outerHeight;
|
|
12945
|
+
var textPadding = style.textPadding;
|
|
12946
|
+
|
|
12947
|
+
var boxPos = getBoxPosition(outerHeight, style, rect);
|
|
12948
|
+
var baseX = boxPos.baseX;
|
|
12949
|
+
var baseY = boxPos.baseY;
|
|
12950
|
+
var textAlign = boxPos.textAlign;
|
|
12951
|
+
var textVerticalAlign = boxPos.textVerticalAlign;
|
|
12952
|
+
|
|
12953
|
+
// Origin of textRotation should be the base point of text drawing.
|
|
12954
|
+
applyTextRotation(ctx, style, rect, baseX, baseY);
|
|
12955
|
+
|
|
12956
|
+
var boxX = textContain.adjustTextX(baseX, outerWidth, textAlign);
|
|
12957
|
+
var boxY = textContain.adjustTextY(baseY, outerHeight, textVerticalAlign);
|
|
12958
|
+
var xLeft = boxX;
|
|
12959
|
+
var lineTop = boxY;
|
|
12960
|
+
if (textPadding) {
|
|
12961
|
+
xLeft += textPadding[3];
|
|
12962
|
+
lineTop += textPadding[0];
|
|
12963
|
+
}
|
|
12964
|
+
var xRight = xLeft + contentWidth;
|
|
12965
|
+
|
|
12966
|
+
needDrawBackground(style) && drawBackground(
|
|
12967
|
+
hostEl, ctx, style, boxX, boxY, outerWidth, outerHeight
|
|
12968
|
+
);
|
|
12969
|
+
|
|
12970
|
+
for (var i = 0; i < contentBlock.lines.length; i++) {
|
|
12971
|
+
var line = contentBlock.lines[i];
|
|
12972
|
+
var tokens = line.tokens;
|
|
12973
|
+
var tokenCount = tokens.length;
|
|
12974
|
+
var lineHeight = line.lineHeight;
|
|
12975
|
+
var usedWidth = line.width;
|
|
12976
|
+
|
|
12977
|
+
var leftIndex = 0;
|
|
12978
|
+
var lineXLeft = xLeft;
|
|
12979
|
+
var lineXRight = xRight;
|
|
12980
|
+
var rightIndex = tokenCount - 1;
|
|
12981
|
+
var token;
|
|
12982
|
+
|
|
12983
|
+
while (
|
|
12984
|
+
leftIndex < tokenCount
|
|
12985
|
+
&& (token = tokens[leftIndex], !token.textAlign || token.textAlign === 'left')
|
|
12986
|
+
) {
|
|
12987
|
+
placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXLeft, 'left');
|
|
12988
|
+
usedWidth -= token.width;
|
|
12989
|
+
lineXLeft += token.width;
|
|
12990
|
+
leftIndex++;
|
|
12991
|
+
}
|
|
12992
|
+
|
|
12993
|
+
while (
|
|
12994
|
+
rightIndex >= 0
|
|
12995
|
+
&& (token = tokens[rightIndex], token.textAlign === 'right')
|
|
12996
|
+
) {
|
|
12997
|
+
placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXRight, 'right');
|
|
12998
|
+
usedWidth -= token.width;
|
|
12999
|
+
lineXRight -= token.width;
|
|
13000
|
+
rightIndex--;
|
|
13001
|
+
}
|
|
13002
|
+
|
|
13003
|
+
// The other tokens are placed as textAlign 'center' if there is enough space.
|
|
13004
|
+
lineXLeft += (contentWidth - (lineXLeft - xLeft) - (xRight - lineXRight) - usedWidth) / 2;
|
|
13005
|
+
while (leftIndex <= rightIndex) {
|
|
13006
|
+
token = tokens[leftIndex];
|
|
13007
|
+
// Consider width specified by user, use 'center' rather than 'left'.
|
|
13008
|
+
placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXLeft + token.width / 2, 'center');
|
|
13009
|
+
lineXLeft += token.width;
|
|
13010
|
+
leftIndex++;
|
|
13011
|
+
}
|
|
13012
|
+
|
|
13013
|
+
lineTop += lineHeight;
|
|
13014
|
+
}
|
|
13015
|
+
}
|
|
13016
|
+
|
|
13017
|
+
function applyTextRotation(ctx, style, rect, x, y) {
|
|
13018
|
+
// textRotation only apply in RectText.
|
|
13019
|
+
if (rect && style.textRotation) {
|
|
13020
|
+
var origin = style.textOrigin;
|
|
13021
|
+
if (origin === 'center') {
|
|
13022
|
+
x = rect.width / 2 + rect.x;
|
|
13023
|
+
y = rect.height / 2 + rect.y;
|
|
13024
|
+
}
|
|
13025
|
+
else if (origin) {
|
|
13026
|
+
x = origin[0] + rect.x;
|
|
13027
|
+
y = origin[1] + rect.y;
|
|
13028
|
+
}
|
|
13029
|
+
|
|
13030
|
+
ctx.translate(x, y);
|
|
13031
|
+
// Positive: anticlockwise
|
|
13032
|
+
ctx.rotate(-style.textRotation);
|
|
13033
|
+
ctx.translate(-x, -y);
|
|
13034
|
+
}
|
|
13035
|
+
}
|
|
13036
|
+
|
|
13037
|
+
function placeToken(hostEl, ctx, token, style, lineHeight, lineTop, x, textAlign) {
|
|
13038
|
+
var tokenStyle = style.rich[token.styleName] || {};
|
|
13039
|
+
|
|
13040
|
+
// 'ctx.textBaseline' is always set as 'middle', for sake of
|
|
13041
|
+
// the bias of "Microsoft YaHei".
|
|
13042
|
+
var textVerticalAlign = token.textVerticalAlign;
|
|
13043
|
+
var y = lineTop + lineHeight / 2;
|
|
13044
|
+
if (textVerticalAlign === 'top') {
|
|
13045
|
+
y = lineTop + token.height / 2;
|
|
13046
|
+
}
|
|
13047
|
+
else if (textVerticalAlign === 'bottom') {
|
|
13048
|
+
y = lineTop + lineHeight - token.height / 2;
|
|
13049
|
+
}
|
|
13050
|
+
|
|
13051
|
+
!token.isLineHolder && needDrawBackground(tokenStyle) && drawBackground(
|
|
13052
|
+
hostEl,
|
|
13053
|
+
ctx,
|
|
13054
|
+
tokenStyle,
|
|
13055
|
+
textAlign === 'right'
|
|
13056
|
+
? x - token.width
|
|
13057
|
+
: textAlign === 'center'
|
|
13058
|
+
? x - token.width / 2
|
|
13059
|
+
: x,
|
|
13060
|
+
y - token.height / 2,
|
|
13061
|
+
token.width,
|
|
13062
|
+
token.height
|
|
13063
|
+
);
|
|
13064
|
+
|
|
13065
|
+
var textPadding = token.textPadding;
|
|
13066
|
+
if (textPadding) {
|
|
13067
|
+
x = getTextXForPadding(x, textAlign, textPadding);
|
|
13068
|
+
y -= token.height / 2 - textPadding[2] - token.textHeight / 2;
|
|
13069
|
+
}
|
|
13070
|
+
|
|
13071
|
+
setCtx(ctx, 'shadowBlur', retrieve3(tokenStyle.textShadowBlur, style.textShadowBlur, 0));
|
|
13072
|
+
setCtx(ctx, 'shadowColor', tokenStyle.textShadowColor || style.textShadowColor || 'transparent');
|
|
13073
|
+
setCtx(ctx, 'shadowOffsetX', retrieve3(tokenStyle.textShadowOffsetX, style.textShadowOffsetX, 0));
|
|
13074
|
+
setCtx(ctx, 'shadowOffsetY', retrieve3(tokenStyle.textShadowOffsetY, style.textShadowOffsetY, 0));
|
|
13075
|
+
|
|
13076
|
+
setCtx(ctx, 'textAlign', textAlign);
|
|
13077
|
+
// Force baseline to be "middle". Otherwise, if using "top", the
|
|
13078
|
+
// text will offset downward a little bit in font "Microsoft YaHei".
|
|
13079
|
+
setCtx(ctx, 'textBaseline', 'middle');
|
|
13080
|
+
|
|
13081
|
+
setCtx(ctx, 'font', token.font || textContain.DEFAULT_FONT);
|
|
13082
|
+
|
|
13083
|
+
var textStroke = getStroke(tokenStyle.textStroke || style.textStroke, textStrokeWidth);
|
|
13084
|
+
var textFill = getFill(tokenStyle.textFill || style.textFill);
|
|
13085
|
+
var textStrokeWidth = retrieve2(tokenStyle.textStrokeWidth, style.textStrokeWidth);
|
|
13086
|
+
|
|
13087
|
+
// Fill after stroke so the outline will not cover the main part.
|
|
13088
|
+
if (textStroke) {
|
|
13089
|
+
setCtx(ctx, 'lineWidth', textStrokeWidth);
|
|
13090
|
+
setCtx(ctx, 'strokeStyle', textStroke);
|
|
13091
|
+
ctx.strokeText(token.text, x, y);
|
|
13092
|
+
}
|
|
13093
|
+
if (textFill) {
|
|
13094
|
+
setCtx(ctx, 'fillStyle', textFill);
|
|
13095
|
+
ctx.fillText(token.text, x, y);
|
|
13096
|
+
}
|
|
13097
|
+
}
|
|
13098
|
+
|
|
13099
|
+
function needDrawBackground(style) {
|
|
13100
|
+
return style.textBackgroundColor
|
|
13101
|
+
|| (style.textBorderWidth && style.textBorderColor);
|
|
13102
|
+
}
|
|
13103
|
+
|
|
13104
|
+
// style: {textBackgroundColor, textBorderWidth, textBorderColor, textBorderRadius}
|
|
13105
|
+
// shape: {x, y, width, height}
|
|
13106
|
+
function drawBackground(hostEl, ctx, style, x, y, width, height) {
|
|
13107
|
+
var textBackgroundColor = style.textBackgroundColor;
|
|
13108
|
+
var textBorderWidth = style.textBorderWidth;
|
|
13109
|
+
var textBorderColor = style.textBorderColor;
|
|
13110
|
+
var isPlainBg = util.isString(textBackgroundColor);
|
|
13111
|
+
|
|
13112
|
+
setCtx(ctx, 'shadowBlur', style.textBoxShadowBlur || 0);
|
|
13113
|
+
setCtx(ctx, 'shadowColor', style.textBoxShadowColor || 'transparent');
|
|
13114
|
+
setCtx(ctx, 'shadowOffsetX', style.textBoxShadowOffsetX || 0);
|
|
13115
|
+
setCtx(ctx, 'shadowOffsetY', style.textBoxShadowOffsetY || 0);
|
|
13116
|
+
|
|
13117
|
+
if (isPlainBg || (textBorderWidth && textBorderColor)) {
|
|
13118
|
+
ctx.beginPath();
|
|
13119
|
+
var textBorderRadius = style.textBorderRadius;
|
|
13120
|
+
if (!textBorderRadius) {
|
|
13121
|
+
ctx.rect(x, y, width, height);
|
|
13122
|
+
}
|
|
13123
|
+
else {
|
|
13124
|
+
roundRectHelper.buildPath(ctx, {
|
|
13125
|
+
x: x, y: y, width: width, height: height, r: textBorderRadius
|
|
13126
|
+
});
|
|
13127
|
+
}
|
|
13128
|
+
ctx.closePath();
|
|
13129
|
+
}
|
|
13130
|
+
|
|
13131
|
+
if (isPlainBg) {
|
|
13132
|
+
setCtx(ctx, 'fillStyle', textBackgroundColor);
|
|
13133
|
+
ctx.fill();
|
|
13134
|
+
}
|
|
13135
|
+
else if (util.isObject(textBackgroundColor)) {
|
|
13136
|
+
var image = textBackgroundColor.image;
|
|
13137
|
+
|
|
13138
|
+
image = imageHelper.createOrUpdateImage(
|
|
13139
|
+
image, null, hostEl, onBgImageLoaded, textBackgroundColor
|
|
13140
|
+
);
|
|
13141
|
+
if (image && imageHelper.isImageReady(image)) {
|
|
13142
|
+
ctx.drawImage(image, x, y, width, height);
|
|
13143
|
+
}
|
|
13144
|
+
}
|
|
13145
|
+
|
|
13146
|
+
if (textBorderWidth && textBorderColor) {
|
|
13147
|
+
setCtx(ctx, 'lineWidth', textBorderWidth);
|
|
13148
|
+
setCtx(ctx, 'strokeStyle', textBorderColor);
|
|
13149
|
+
ctx.stroke();
|
|
13150
|
+
}
|
|
13151
|
+
}
|
|
13152
|
+
|
|
13153
|
+
function onBgImageLoaded(image, textBackgroundColor) {
|
|
13154
|
+
// Replace image, so that `contain/text.js#parseRichText`
|
|
13155
|
+
// will get correct result in next tick.
|
|
13156
|
+
textBackgroundColor.image = image;
|
|
13157
|
+
}
|
|
13204
13158
|
|
|
13205
|
-
|
|
13206
|
-
var
|
|
13159
|
+
function getBoxPosition(blockHeiht, style, rect) {
|
|
13160
|
+
var baseX = style.x || 0;
|
|
13161
|
+
var baseY = style.y || 0;
|
|
13162
|
+
var textAlign = style.textAlign;
|
|
13163
|
+
var textVerticalAlign = style.textVerticalAlign;
|
|
13207
13164
|
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13165
|
+
// Text position represented by coord
|
|
13166
|
+
if (rect) {
|
|
13167
|
+
var textPosition = style.textPosition;
|
|
13168
|
+
if (textPosition instanceof Array) {
|
|
13169
|
+
// Percent
|
|
13170
|
+
baseX = rect.x + parsePercent(textPosition[0], rect.width);
|
|
13171
|
+
baseY = rect.y + parsePercent(textPosition[1], rect.height);
|
|
13215
13172
|
}
|
|
13216
|
-
else
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13173
|
+
else {
|
|
13174
|
+
var res = textContain.adjustTextPositionOnRect(
|
|
13175
|
+
textPosition, rect, style.textDistance
|
|
13176
|
+
);
|
|
13177
|
+
baseX = res.x;
|
|
13178
|
+
baseY = res.y;
|
|
13179
|
+
// Default align and baseline when has textPosition
|
|
13180
|
+
textAlign = textAlign || res.textAlign;
|
|
13181
|
+
textVerticalAlign = textVerticalAlign || res.textVerticalAlign;
|
|
13220
13182
|
}
|
|
13221
|
-
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
|
|
13183
|
+
|
|
13184
|
+
// textOffset is only support in RectText, otherwise
|
|
13185
|
+
// we have to adjust boundingRect for textOffset.
|
|
13186
|
+
var textOffset = style.textOffset;
|
|
13187
|
+
if (textOffset) {
|
|
13188
|
+
baseX += textOffset[0];
|
|
13189
|
+
baseY += textOffset[1];
|
|
13225
13190
|
}
|
|
13226
|
-
}
|
|
13191
|
+
}
|
|
13227
13192
|
|
|
13228
|
-
|
|
13229
|
-
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13233
|
-
+ document.getElementById('wrong-message').innerHTML;
|
|
13193
|
+
return {
|
|
13194
|
+
baseX: baseX,
|
|
13195
|
+
baseY: baseY,
|
|
13196
|
+
textAlign: textAlign,
|
|
13197
|
+
textVerticalAlign: textVerticalAlign
|
|
13234
13198
|
};
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
|
|
13238
|
-
|
|
13239
|
-
/***/ }),
|
|
13240
|
-
/* 37 */
|
|
13241
|
-
/***/ (function(module, exports) {
|
|
13199
|
+
}
|
|
13242
13200
|
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13201
|
+
function setCtx(ctx, prop, value) {
|
|
13202
|
+
// FIXME ??? performance try
|
|
13203
|
+
// if (ctx.__currentValues[prop] !== value) {
|
|
13204
|
+
// ctx[prop] = ctx.__currentValues[prop] = value;
|
|
13205
|
+
ctx[prop] = value;
|
|
13206
|
+
// }
|
|
13207
|
+
return ctx[prop];
|
|
13248
13208
|
}
|
|
13209
|
+
|
|
13249
13210
|
/**
|
|
13250
|
-
*
|
|
13251
|
-
* @
|
|
13252
|
-
* @
|
|
13211
|
+
* @param {string} [stroke] If specified, do not check style.textStroke.
|
|
13212
|
+
* @param {string} [lineWidth] If specified, do not check style.textStroke.
|
|
13213
|
+
* @param {number} style
|
|
13253
13214
|
*/
|
|
13254
|
-
var
|
|
13255
|
-
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
debugMode: 0,
|
|
13262
|
-
|
|
13263
|
-
// retina 屏幕优化
|
|
13264
|
-
devicePixelRatio: dpr
|
|
13215
|
+
var getStroke = helper.getStroke = function (stroke, lineWidth) {
|
|
13216
|
+
return (stroke == null || lineWidth <= 0 || stroke === 'transparent' || stroke === 'none')
|
|
13217
|
+
? null
|
|
13218
|
+
// TODO pattern and gradient?
|
|
13219
|
+
: (stroke.image || stroke.colorStops)
|
|
13220
|
+
? '#000'
|
|
13221
|
+
: stroke;
|
|
13265
13222
|
};
|
|
13266
|
-
module.exports = config;
|
|
13267
|
-
|
|
13268
|
-
|
|
13269
|
-
|
|
13270
|
-
|
|
13271
|
-
/***/ }),
|
|
13272
|
-
/* 38 */
|
|
13273
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
13274
|
-
|
|
13275
|
-
/**
|
|
13276
|
-
* Mixin for drawing text in a element bounding rect
|
|
13277
|
-
* @module zrender/mixin/RectText
|
|
13278
|
-
*/
|
|
13279
|
-
|
|
13280
13223
|
|
|
13224
|
+
var getFill = helper.getFill = function (fill) {
|
|
13225
|
+
return (fill == null || fill === 'none')
|
|
13226
|
+
? null
|
|
13227
|
+
// TODO pattern and gradient?
|
|
13228
|
+
: (fill.image || fill.colorStops)
|
|
13229
|
+
? '#000'
|
|
13230
|
+
: fill;
|
|
13231
|
+
};
|
|
13281
13232
|
|
|
13282
|
-
|
|
13283
|
-
|
|
13233
|
+
function parsePercent(value, maxValue) {
|
|
13234
|
+
if (typeof value === 'string') {
|
|
13235
|
+
if (value.lastIndexOf('%') >= 0) {
|
|
13236
|
+
return parseFloat(value) / 100 * maxValue;
|
|
13237
|
+
}
|
|
13238
|
+
return parseFloat(value);
|
|
13239
|
+
}
|
|
13240
|
+
return value;
|
|
13241
|
+
}
|
|
13284
13242
|
|
|
13285
|
-
|
|
13243
|
+
function getTextXForPadding(x, textAlign, textPadding) {
|
|
13244
|
+
return textAlign === 'right'
|
|
13245
|
+
? (x - textPadding[1])
|
|
13246
|
+
: textAlign === 'center'
|
|
13247
|
+
? (x + textPadding[3] / 2 - textPadding[1] / 2)
|
|
13248
|
+
: (x + textPadding[3]);
|
|
13249
|
+
}
|
|
13286
13250
|
|
|
13287
|
-
|
|
13251
|
+
/**
|
|
13252
|
+
* @param {string} text
|
|
13253
|
+
* @param {module:zrender/Style} style
|
|
13254
|
+
* @return {boolean}
|
|
13255
|
+
*/
|
|
13256
|
+
helper.needDrawText = function (text, style) {
|
|
13257
|
+
return text != null
|
|
13258
|
+
&& (text
|
|
13259
|
+
|| style.textBackgroundColor
|
|
13260
|
+
|| (style.textBorderWidth && style.textBorderColor)
|
|
13261
|
+
|| style.textPadding
|
|
13262
|
+
);
|
|
13263
|
+
};
|
|
13288
13264
|
|
|
13289
|
-
|
|
13265
|
+
module.exports = helper;
|
|
13290
13266
|
|
|
13291
|
-
constructor: RectText,
|
|
13292
13267
|
|
|
13293
|
-
/**
|
|
13294
|
-
* Draw text in a rect with specified position.
|
|
13295
|
-
* @param {CanvasRenderingContext2D} ctx
|
|
13296
|
-
* @param {Object} rect Displayable rect
|
|
13297
|
-
*/
|
|
13298
|
-
drawRectText: function (ctx, rect) {
|
|
13299
|
-
var style = this.style;
|
|
13300
13268
|
|
|
13301
|
-
rect = style.textRect || rect;
|
|
13302
13269
|
|
|
13303
|
-
|
|
13304
|
-
|
|
13270
|
+
/***/ }),
|
|
13271
|
+
/* 38 */
|
|
13272
|
+
/***/ (function(module, exports) {
|
|
13305
13273
|
|
|
13306
|
-
|
|
13274
|
+
|
|
13307
13275
|
|
|
13308
|
-
|
|
13309
|
-
|
|
13276
|
+
module.exports = {
|
|
13277
|
+
buildPath: function (ctx, shape) {
|
|
13278
|
+
var x = shape.x;
|
|
13279
|
+
var y = shape.y;
|
|
13280
|
+
var width = shape.width;
|
|
13281
|
+
var height = shape.height;
|
|
13282
|
+
var r = shape.r;
|
|
13283
|
+
var r1;
|
|
13284
|
+
var r2;
|
|
13285
|
+
var r3;
|
|
13286
|
+
var r4;
|
|
13310
13287
|
|
|
13311
|
-
|
|
13312
|
-
|
|
13288
|
+
// Convert width and height to positive for better borderRadius
|
|
13289
|
+
if (width < 0) {
|
|
13290
|
+
x = x + width;
|
|
13291
|
+
width = -width;
|
|
13292
|
+
}
|
|
13293
|
+
if (height < 0) {
|
|
13294
|
+
y = y + height;
|
|
13295
|
+
height = -height;
|
|
13313
13296
|
}
|
|
13314
13297
|
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13298
|
+
if (typeof r === 'number') {
|
|
13299
|
+
r1 = r2 = r3 = r4 = r;
|
|
13300
|
+
}
|
|
13301
|
+
else if (r instanceof Array) {
|
|
13302
|
+
if (r.length === 1) {
|
|
13303
|
+
r1 = r2 = r3 = r4 = r[0];
|
|
13304
|
+
}
|
|
13305
|
+
else if (r.length === 2) {
|
|
13306
|
+
r1 = r3 = r[0];
|
|
13307
|
+
r2 = r4 = r[1];
|
|
13308
|
+
}
|
|
13309
|
+
else if (r.length === 3) {
|
|
13310
|
+
r1 = r[0];
|
|
13311
|
+
r2 = r4 = r[1];
|
|
13312
|
+
r3 = r[2];
|
|
13313
|
+
}
|
|
13314
|
+
else {
|
|
13315
|
+
r1 = r[0];
|
|
13316
|
+
r2 = r[1];
|
|
13317
|
+
r3 = r[2];
|
|
13318
|
+
r4 = r[3];
|
|
13325
13319
|
}
|
|
13326
13320
|
}
|
|
13327
13321
|
else {
|
|
13328
|
-
|
|
13322
|
+
r1 = r2 = r3 = r4 = 0;
|
|
13329
13323
|
}
|
|
13330
13324
|
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13325
|
+
var total;
|
|
13326
|
+
if (r1 + r2 > width) {
|
|
13327
|
+
total = r1 + r2;
|
|
13328
|
+
r1 *= width / total;
|
|
13329
|
+
r2 *= width / total;
|
|
13330
|
+
}
|
|
13331
|
+
if (r3 + r4 > width) {
|
|
13332
|
+
total = r3 + r4;
|
|
13333
|
+
r3 *= width / total;
|
|
13334
|
+
r4 *= width / total;
|
|
13335
|
+
}
|
|
13336
|
+
if (r2 + r3 > height) {
|
|
13337
|
+
total = r2 + r3;
|
|
13338
|
+
r2 *= height / total;
|
|
13339
|
+
r3 *= height / total;
|
|
13340
|
+
}
|
|
13341
|
+
if (r1 + r4 > height) {
|
|
13342
|
+
total = r1 + r4;
|
|
13343
|
+
r1 *= height / total;
|
|
13344
|
+
r4 *= height / total;
|
|
13345
|
+
}
|
|
13346
|
+
ctx.moveTo(x + r1, y);
|
|
13347
|
+
ctx.lineTo(x + width - r2, y);
|
|
13348
|
+
r2 !== 0 && ctx.quadraticCurveTo(
|
|
13349
|
+
x + width, y, x + width, y + r2
|
|
13350
|
+
);
|
|
13351
|
+
ctx.lineTo(x + width, y + height - r3);
|
|
13352
|
+
r3 !== 0 && ctx.quadraticCurveTo(
|
|
13353
|
+
x + width, y + height, x + width - r3, y + height
|
|
13354
|
+
);
|
|
13355
|
+
ctx.lineTo(x + r4, y + height);
|
|
13356
|
+
r4 !== 0 && ctx.quadraticCurveTo(
|
|
13357
|
+
x, y + height, x, y + height - r4
|
|
13358
|
+
);
|
|
13359
|
+
ctx.lineTo(x, y + r1);
|
|
13360
|
+
r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y);
|
|
13335
13361
|
}
|
|
13336
13362
|
};
|
|
13337
13363
|
|
|
13338
|
-
module.exports = RectText;
|
|
13339
|
-
|
|
13340
13364
|
|
|
13341
13365
|
/***/ }),
|
|
13342
13366
|
/* 39 */
|
|
@@ -13358,7 +13382,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
13358
13382
|
var vec2 = __webpack_require__(10);
|
|
13359
13383
|
var bbox = __webpack_require__(41);
|
|
13360
13384
|
var BoundingRect = __webpack_require__(9);
|
|
13361
|
-
var dpr = __webpack_require__(
|
|
13385
|
+
var dpr = __webpack_require__(35).devicePixelRatio;
|
|
13362
13386
|
|
|
13363
13387
|
var CMD = {
|
|
13364
13388
|
M: 1,
|
|
@@ -15723,7 +15747,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
15723
15747
|
|
|
15724
15748
|
|
|
15725
15749
|
var zrUtil = __webpack_require__(4);
|
|
15726
|
-
var Element = __webpack_require__(
|
|
15750
|
+
var Element = __webpack_require__(25);
|
|
15727
15751
|
var BoundingRect = __webpack_require__(9);
|
|
15728
15752
|
|
|
15729
15753
|
/**
|
|
@@ -16159,7 +16183,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
16159
16183
|
var Displayable = __webpack_require__(23);
|
|
16160
16184
|
var zrUtil = __webpack_require__(4);
|
|
16161
16185
|
var textContain = __webpack_require__(8);
|
|
16162
|
-
var textHelper = __webpack_require__(
|
|
16186
|
+
var textHelper = __webpack_require__(37);
|
|
16163
16187
|
|
|
16164
16188
|
/**
|
|
16165
16189
|
* @alias zrender/graphic/Text
|
|
@@ -16227,8 +16251,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
16227
16251
|
rect.x += style.x || 0;
|
|
16228
16252
|
rect.y += style.y || 0;
|
|
16229
16253
|
|
|
16230
|
-
if (textHelper.getStroke(style.textStroke, style.
|
|
16231
|
-
var w = style.
|
|
16254
|
+
if (textHelper.getStroke(style.textStroke, style.textStrokeWidth)) {
|
|
16255
|
+
var w = style.textStrokeWidth;
|
|
16232
16256
|
rect.x -= w / 2;
|
|
16233
16257
|
rect.y -= w / 2;
|
|
16234
16258
|
rect.width += w;
|
|
@@ -16775,7 +16799,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
16775
16799
|
*/
|
|
16776
16800
|
|
|
16777
16801
|
|
|
16778
|
-
var roundRectHelper = __webpack_require__(
|
|
16802
|
+
var roundRectHelper = __webpack_require__(38);
|
|
16779
16803
|
|
|
16780
16804
|
module.exports = __webpack_require__(22).extend({
|
|
16781
16805
|
|
|
@@ -19040,30 +19064,31 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
19040
19064
|
compatItemStyle(data[i]);
|
|
19041
19065
|
compatLabelTextStyle(data[i] && data[i].label);
|
|
19042
19066
|
}
|
|
19043
|
-
|
|
19044
|
-
|
|
19045
|
-
|
|
19046
|
-
|
|
19047
|
-
|
|
19048
|
-
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
|
|
19052
|
-
|
|
19053
|
-
|
|
19054
|
-
|
|
19055
|
-
|
|
19056
|
-
|
|
19057
|
-
|
|
19058
|
-
|
|
19059
|
-
|
|
19060
|
-
|
|
19061
|
-
|
|
19062
|
-
|
|
19063
|
-
|
|
19064
|
-
|
|
19065
|
-
|
|
19066
|
-
|
|
19067
|
+
}
|
|
19068
|
+
|
|
19069
|
+
// mark point data
|
|
19070
|
+
var markPoint = seriesOpt.markPoint;
|
|
19071
|
+
if (markPoint && markPoint.data) {
|
|
19072
|
+
var mpData = markPoint.data;
|
|
19073
|
+
for (var i = 0; i < mpData.length; i++) {
|
|
19074
|
+
compatItemStyle(mpData[i]);
|
|
19075
|
+
compatLabelTextStyle(mpData[i] && mpData[i].label);
|
|
19076
|
+
}
|
|
19077
|
+
}
|
|
19078
|
+
// mark line data
|
|
19079
|
+
var markLine = seriesOpt.markLine;
|
|
19080
|
+
if (markLine && markLine.data) {
|
|
19081
|
+
var mlData = markLine.data;
|
|
19082
|
+
for (var i = 0; i < mlData.length; i++) {
|
|
19083
|
+
if (zrUtil.isArray(mlData[i])) {
|
|
19084
|
+
compatItemStyle(mlData[i][0]);
|
|
19085
|
+
compatLabelTextStyle(mlData[i][0] && mlData[i][0].label);
|
|
19086
|
+
compatItemStyle(mlData[i][1]);
|
|
19087
|
+
compatLabelTextStyle(mlData[i][1] && mlData[i][1].label);
|
|
19088
|
+
}
|
|
19089
|
+
else {
|
|
19090
|
+
compatItemStyle(mlData[i]);
|
|
19091
|
+
compatLabelTextStyle(mlData[i] && mlData[i].label);
|
|
19067
19092
|
}
|
|
19068
19093
|
}
|
|
19069
19094
|
}
|
|
@@ -19856,7 +19881,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
19856
19881
|
*/
|
|
19857
19882
|
// Global defines
|
|
19858
19883
|
|
|
19859
|
-
var guid = __webpack_require__(
|
|
19884
|
+
var guid = __webpack_require__(26);
|
|
19860
19885
|
var env = __webpack_require__(2);
|
|
19861
19886
|
var zrUtil = __webpack_require__(4);
|
|
19862
19887
|
|
|
@@ -19878,7 +19903,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
19878
19903
|
/**
|
|
19879
19904
|
* @type {string}
|
|
19880
19905
|
*/
|
|
19881
|
-
zrender.version = '3.6.
|
|
19906
|
+
zrender.version = '3.6.2';
|
|
19882
19907
|
|
|
19883
19908
|
/**
|
|
19884
19909
|
* Initializing a zrender instance
|
|
@@ -20301,9 +20326,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
20301
20326
|
|
|
20302
20327
|
|
|
20303
20328
|
var util = __webpack_require__(4);
|
|
20329
|
+
var vec2 = __webpack_require__(10);
|
|
20304
20330
|
var Draggable = __webpack_require__(89);
|
|
20305
20331
|
|
|
20306
|
-
var Eventful = __webpack_require__(
|
|
20332
|
+
var Eventful = __webpack_require__(27);
|
|
20307
20333
|
|
|
20308
20334
|
var SILENT = 'silent';
|
|
20309
20335
|
|
|
@@ -20323,7 +20349,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
20323
20349
|
pinchY: event.pinchY,
|
|
20324
20350
|
pinchScale: event.pinchScale,
|
|
20325
20351
|
wheelDelta: event.zrDelta,
|
|
20326
|
-
zrByTouch: event.zrByTouch
|
|
20352
|
+
zrByTouch: event.zrByTouch,
|
|
20353
|
+
which: event.which
|
|
20327
20354
|
};
|
|
20328
20355
|
}
|
|
20329
20356
|
|
|
@@ -20578,17 +20605,27 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
20578
20605
|
var hoveredTarget = hovered.target;
|
|
20579
20606
|
|
|
20580
20607
|
if (name === 'mousedown') {
|
|
20581
|
-
this.
|
|
20608
|
+
this._downEl = hoveredTarget;
|
|
20609
|
+
this._downPoint = [event.zrX, event.zrY];
|
|
20582
20610
|
// In case click triggered before mouseup
|
|
20583
|
-
this.
|
|
20611
|
+
this._upEl = hoveredTarget;
|
|
20584
20612
|
}
|
|
20585
20613
|
else if (name === 'mosueup') {
|
|
20586
|
-
this.
|
|
20614
|
+
this._upEl = hoveredTarget;
|
|
20587
20615
|
}
|
|
20588
20616
|
else if (name === 'click') {
|
|
20589
|
-
if (this.
|
|
20617
|
+
if (this._downEl !== this._upEl
|
|
20618
|
+
// Original click event is triggered on the whole canvas element,
|
|
20619
|
+
// including the case that `mousedown` - `mousemove` - `mouseup`,
|
|
20620
|
+
// which should be filtered, otherwise it will bring trouble to
|
|
20621
|
+
// pan and zoom.
|
|
20622
|
+
|| !this._downPoint
|
|
20623
|
+
// Arbitrary value
|
|
20624
|
+
|| vec2.dist(this._downPoint, [event.zrX, event.zrY]) > 4
|
|
20625
|
+
) {
|
|
20590
20626
|
return;
|
|
20591
20627
|
}
|
|
20628
|
+
this._downPoint = null;
|
|
20592
20629
|
}
|
|
20593
20630
|
|
|
20594
20631
|
this.dispatchToElement(hovered, name, event);
|
|
@@ -21676,7 +21713,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
21676
21713
|
|
|
21677
21714
|
var requestAnimationFrame = __webpack_require__(94);
|
|
21678
21715
|
|
|
21679
|
-
var Animator = __webpack_require__(
|
|
21716
|
+
var Animator = __webpack_require__(30);
|
|
21680
21717
|
/**
|
|
21681
21718
|
* @typedef {Object} IZRenderStage
|
|
21682
21719
|
* @property {Function} update
|
|
@@ -21927,11 +21964,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
21927
21964
|
*/
|
|
21928
21965
|
|
|
21929
21966
|
|
|
21930
|
-
var Eventful = __webpack_require__(
|
|
21967
|
+
var Eventful = __webpack_require__(27);
|
|
21931
21968
|
var env = __webpack_require__(2);
|
|
21932
21969
|
|
|
21933
21970
|
var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener;
|
|
21934
21971
|
|
|
21972
|
+
var MOUSE_EVENT_REG = /^(?:mouse|pointer|contextmenu|drag|drop)|click/;
|
|
21973
|
+
|
|
21935
21974
|
function getBoundingClientRect(el) {
|
|
21936
21975
|
// BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect
|
|
21937
21976
|
return el.getBoundingClientRect ? el.getBoundingClientRect() : {left: 0, top: 0};
|
|
@@ -22012,6 +22051,15 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
22012
22051
|
touch && clientToLocal(el, touch, e, calculate);
|
|
22013
22052
|
}
|
|
22014
22053
|
|
|
22054
|
+
// Add which for click: 1 === left; 2 === middle; 3 === right; otherwise: 0;
|
|
22055
|
+
// See jQuery: https://github.com/jquery/jquery/blob/master/src/event.js
|
|
22056
|
+
// If e.which has been defined, if may be readonly,
|
|
22057
|
+
// see: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
|
|
22058
|
+
var button = e.button;
|
|
22059
|
+
if (e.which == null && button !== undefined && MOUSE_EVENT_REG.test(e.type)) {
|
|
22060
|
+
e.which = (button & 1 ? 1 : (button & 2 ? 3 : (button & 4 ? 2 : 0)));
|
|
22061
|
+
}
|
|
22062
|
+
|
|
22015
22063
|
return e;
|
|
22016
22064
|
}
|
|
22017
22065
|
|
|
@@ -22053,11 +22101,17 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
22053
22101
|
e.cancelBubble = true;
|
|
22054
22102
|
};
|
|
22055
22103
|
|
|
22104
|
+
function notLeftMouse(e) {
|
|
22105
|
+
// If e.which is undefined, considered as left mouse event.
|
|
22106
|
+
return e.which > 1;
|
|
22107
|
+
}
|
|
22108
|
+
|
|
22056
22109
|
module.exports = {
|
|
22057
22110
|
clientToLocal: clientToLocal,
|
|
22058
22111
|
normalizeEvent: normalizeEvent,
|
|
22059
22112
|
addEventListener: addEventListener,
|
|
22060
22113
|
removeEventListener: removeEventListener,
|
|
22114
|
+
notLeftMouse: notLeftMouse,
|
|
22061
22115
|
|
|
22062
22116
|
stop: stop,
|
|
22063
22117
|
// 做向上兼容
|
|
@@ -22093,7 +22147,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
22093
22147
|
|
|
22094
22148
|
var eventTool = __webpack_require__(93);
|
|
22095
22149
|
var zrUtil = __webpack_require__(4);
|
|
22096
|
-
var Eventful = __webpack_require__(
|
|
22150
|
+
var Eventful = __webpack_require__(27);
|
|
22097
22151
|
var env = __webpack_require__(2);
|
|
22098
22152
|
var GestureMgr = __webpack_require__(96);
|
|
22099
22153
|
|
|
@@ -22609,9 +22663,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
22609
22663
|
*/
|
|
22610
22664
|
|
|
22611
22665
|
|
|
22612
|
-
var config = __webpack_require__(
|
|
22666
|
+
var config = __webpack_require__(35);
|
|
22613
22667
|
var util = __webpack_require__(4);
|
|
22614
|
-
var log = __webpack_require__(
|
|
22668
|
+
var log = __webpack_require__(34);
|
|
22615
22669
|
var BoundingRect = __webpack_require__(9);
|
|
22616
22670
|
var timsort = __webpack_require__(91);
|
|
22617
22671
|
|
|
@@ -22722,6 +22776,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
22722
22776
|
* @param {Object} opts
|
|
22723
22777
|
*/
|
|
22724
22778
|
var Painter = function (root, storage, opts) {
|
|
22779
|
+
|
|
22780
|
+
this.type = 'canvas';
|
|
22781
|
+
|
|
22725
22782
|
// In node environment using node-canvas
|
|
22726
22783
|
var singleCanvas = !root.nodeName // In node ?
|
|
22727
22784
|
|| root.nodeName.toUpperCase() === 'CANVAS';
|
|
@@ -22827,6 +22884,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
22827
22884
|
|
|
22828
22885
|
constructor: Painter,
|
|
22829
22886
|
|
|
22887
|
+
getType: function () {
|
|
22888
|
+
return 'canvas';
|
|
22889
|
+
},
|
|
22890
|
+
|
|
22830
22891
|
/**
|
|
22831
22892
|
* If painter use a single canvas
|
|
22832
22893
|
* @return {boolean}
|
|
@@ -23734,7 +23795,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
23734
23795
|
|
|
23735
23796
|
|
|
23736
23797
|
var util = __webpack_require__(4);
|
|
23737
|
-
var config = __webpack_require__(
|
|
23798
|
+
var config = __webpack_require__(35);
|
|
23738
23799
|
var Style = __webpack_require__(24);
|
|
23739
23800
|
var Pattern = __webpack_require__(49);
|
|
23740
23801
|
|
|
@@ -26655,7 +26716,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
26655
26716
|
// If there are no data and extent are [Infinity, -Infinity]
|
|
26656
26717
|
if (extent[1] === -Infinity && extent[0] === Infinity) {
|
|
26657
26718
|
var d = new Date();
|
|
26658
|
-
extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
26719
|
+
extent[1] = +new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
26659
26720
|
extent[0] = extent[1] - ONE_DAY;
|
|
26660
26721
|
}
|
|
26661
26722
|
|
|
@@ -26676,8 +26737,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
26676
26737
|
* @override
|
|
26677
26738
|
*/
|
|
26678
26739
|
niceTicks: function (approxTickNum, minInterval, maxInterval) {
|
|
26679
|
-
var timezoneOffset = this.getSetting('useUTC')
|
|
26680
|
-
? 0 : numberUtil.getTimezoneOffset() * 60 * 1000;
|
|
26681
26740
|
approxTickNum = approxTickNum || 10;
|
|
26682
26741
|
|
|
26683
26742
|
var extent = this._extent;
|
|
@@ -26707,9 +26766,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
26707
26766
|
interval *= yearStep;
|
|
26708
26767
|
}
|
|
26709
26768
|
|
|
26769
|
+
var timezoneOffset = this.getSetting('useUTC')
|
|
26770
|
+
? 0 : (new Date(+extent[0] || +extent[1])).getTimezoneOffset() * 60 * 1000;
|
|
26710
26771
|
var niceExtent = [
|
|
26711
26772
|
Math.round(mathCeil((extent[0] - timezoneOffset) / interval) * interval + timezoneOffset),
|
|
26712
|
-
Math.round(mathFloor((extent[1] - timezoneOffset)/ interval) * interval + timezoneOffset)
|
|
26773
|
+
Math.round(mathFloor((extent[1] - timezoneOffset) / interval) * interval + timezoneOffset)
|
|
26713
26774
|
];
|
|
26714
26775
|
|
|
26715
26776
|
scaleHelper.fixExtent(niceExtent, extent);
|
|
@@ -28257,8 +28318,20 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
28257
28318
|
function getStackedOnPoints(coordSys, data) {
|
|
28258
28319
|
var baseAxis = coordSys.getBaseAxis();
|
|
28259
28320
|
var valueAxis = coordSys.getOtherAxis(baseAxis);
|
|
28260
|
-
|
|
28261
|
-
|
|
28321
|
+
|
|
28322
|
+
var valueStart = 0;
|
|
28323
|
+
if (!baseAxis.onZero) {
|
|
28324
|
+
var extent = valueAxis.scale.getExtent();
|
|
28325
|
+
if (extent[0] > 0) {
|
|
28326
|
+
// Both positive
|
|
28327
|
+
valueStart = extent[0];
|
|
28328
|
+
}
|
|
28329
|
+
else if (extent[1] < 0) {
|
|
28330
|
+
// Both negative
|
|
28331
|
+
valueStart = extent[1];
|
|
28332
|
+
}
|
|
28333
|
+
// If is one positive, and one negative, onZero shall be true
|
|
28334
|
+
}
|
|
28262
28335
|
|
|
28263
28336
|
var valueDim = valueAxis.dim;
|
|
28264
28337
|
|
|
@@ -31425,7 +31498,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
31425
31498
|
var getInterval = AxisBuilder.getInterval;
|
|
31426
31499
|
|
|
31427
31500
|
var axisBuilderAttrs = [
|
|
31428
|
-
'axisLine', '
|
|
31501
|
+
'axisLine', 'axisTickLabel', 'axisName'
|
|
31429
31502
|
];
|
|
31430
31503
|
var selfBuilderAttrs = [
|
|
31431
31504
|
'splitArea', 'splitLine'
|
|
@@ -31513,13 +31586,19 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
31513
31586
|
);
|
|
31514
31587
|
var ticks = axis.scale.getTicks();
|
|
31515
31588
|
|
|
31589
|
+
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
|
|
31590
|
+
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
|
|
31591
|
+
|
|
31516
31592
|
var p1 = [];
|
|
31517
31593
|
var p2 = [];
|
|
31518
31594
|
// Simple optimization
|
|
31519
31595
|
// Batching the lines if color are the same
|
|
31520
31596
|
var lineStyle = lineStyleModel.getLineStyle();
|
|
31521
31597
|
for (var i = 0; i < ticksCoords.length; i++) {
|
|
31522
|
-
if (ifIgnoreOnTick(
|
|
31598
|
+
if (ifIgnoreOnTick(
|
|
31599
|
+
axis, i, lineInterval, ticksCoords.length,
|
|
31600
|
+
showMinLabel, showMaxLabel
|
|
31601
|
+
)) {
|
|
31523
31602
|
continue;
|
|
31524
31603
|
}
|
|
31525
31604
|
|
|
@@ -31590,8 +31669,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
31590
31669
|
var areaStyle = areaStyleModel.getAreaStyle();
|
|
31591
31670
|
areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
|
|
31592
31671
|
|
|
31672
|
+
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
|
|
31673
|
+
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
|
|
31674
|
+
|
|
31593
31675
|
for (var i = 1; i < ticksCoords.length; i++) {
|
|
31594
|
-
if (ifIgnoreOnTick(
|
|
31676
|
+
if (ifIgnoreOnTick(
|
|
31677
|
+
axis, i, areaInterval, ticksCoords.length,
|
|
31678
|
+
showMinLabel, showMaxLabel
|
|
31679
|
+
)) {
|
|
31595
31680
|
continue;
|
|
31596
31681
|
}
|
|
31597
31682
|
|
|
@@ -31700,7 +31785,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
31700
31785
|
* @param {Object} opt Standard axis parameters.
|
|
31701
31786
|
* @param {Array.<number>} opt.position [x, y]
|
|
31702
31787
|
* @param {number} opt.rotation by radian
|
|
31703
|
-
* @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'.
|
|
31788
|
+
* @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle' or 'center'.
|
|
31704
31789
|
* @param {number} [opt.tickDirection=1] 1 or -1
|
|
31705
31790
|
* @param {number} [opt.labelDirection=1] 1 or -1
|
|
31706
31791
|
* @param {number} [opt.labelOffset=0] Usefull when onZero.
|
|
@@ -31822,173 +31907,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
31822
31907
|
/**
|
|
31823
31908
|
* @private
|
|
31824
31909
|
*/
|
|
31825
|
-
|
|
31910
|
+
axisTickLabel: function () {
|
|
31826
31911
|
var axisModel = this.axisModel;
|
|
31827
|
-
var axis = axisModel.axis;
|
|
31828
|
-
|
|
31829
|
-
if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
|
|
31830
|
-
return;
|
|
31831
|
-
}
|
|
31832
|
-
|
|
31833
|
-
var tickModel = axisModel.getModel('axisTick');
|
|
31834
|
-
var opt = this.opt;
|
|
31835
|
-
|
|
31836
|
-
var lineStyleModel = tickModel.getModel('lineStyle');
|
|
31837
|
-
var tickLen = tickModel.get('length');
|
|
31838
|
-
|
|
31839
|
-
var tickInterval = getInterval(tickModel, opt.labelInterval);
|
|
31840
|
-
var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
|
|
31841
|
-
var ticks = axis.scale.getTicks();
|
|
31842
|
-
|
|
31843
|
-
var pt1 = [];
|
|
31844
|
-
var pt2 = [];
|
|
31845
|
-
var matrix = this._transform;
|
|
31846
|
-
|
|
31847
|
-
for (var i = 0; i < ticksCoords.length; i++) {
|
|
31848
|
-
// Only ordinal scale support tick interval
|
|
31849
|
-
if (ifIgnoreOnTick(axis, i, tickInterval)) {
|
|
31850
|
-
continue;
|
|
31851
|
-
}
|
|
31852
|
-
|
|
31853
|
-
var tickCoord = ticksCoords[i];
|
|
31854
|
-
|
|
31855
|
-
pt1[0] = tickCoord;
|
|
31856
|
-
pt1[1] = 0;
|
|
31857
|
-
pt2[0] = tickCoord;
|
|
31858
|
-
pt2[1] = opt.tickDirection * tickLen;
|
|
31859
|
-
|
|
31860
|
-
if (matrix) {
|
|
31861
|
-
v2ApplyTransform(pt1, pt1, matrix);
|
|
31862
|
-
v2ApplyTransform(pt2, pt2, matrix);
|
|
31863
|
-
}
|
|
31864
|
-
// Tick line, Not use group transform to have better line draw
|
|
31865
|
-
this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
|
|
31866
|
-
|
|
31867
|
-
// Id for animation
|
|
31868
|
-
anid: 'tick_' + ticks[i],
|
|
31869
|
-
|
|
31870
|
-
shape: {
|
|
31871
|
-
x1: pt1[0],
|
|
31872
|
-
y1: pt1[1],
|
|
31873
|
-
x2: pt2[0],
|
|
31874
|
-
y2: pt2[1]
|
|
31875
|
-
},
|
|
31876
|
-
style: zrUtil.defaults(
|
|
31877
|
-
lineStyleModel.getLineStyle(),
|
|
31878
|
-
{
|
|
31879
|
-
stroke: axisModel.get('axisLine.lineStyle.color')
|
|
31880
|
-
}
|
|
31881
|
-
),
|
|
31882
|
-
z2: 2,
|
|
31883
|
-
silent: true
|
|
31884
|
-
})));
|
|
31885
|
-
}
|
|
31886
|
-
},
|
|
31887
|
-
|
|
31888
|
-
/**
|
|
31889
|
-
* @param {module:echarts/coord/cartesian/AxisModel} axisModel
|
|
31890
|
-
* @param {module:echarts/coord/cartesian/GridModel} gridModel
|
|
31891
|
-
* @private
|
|
31892
|
-
*/
|
|
31893
|
-
axisLabel: function () {
|
|
31894
31912
|
var opt = this.opt;
|
|
31895
|
-
var axisModel = this.axisModel;
|
|
31896
|
-
var axis = axisModel.axis;
|
|
31897
|
-
var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
|
|
31898
|
-
|
|
31899
|
-
if (!show || axis.scale.isBlank()) {
|
|
31900
|
-
return;
|
|
31901
|
-
}
|
|
31902
|
-
|
|
31903
|
-
var labelModel = axisModel.getModel('axisLabel');
|
|
31904
|
-
var labelMargin = labelModel.get('margin');
|
|
31905
|
-
var ticks = axis.scale.getTicks();
|
|
31906
|
-
var labels = axisModel.getFormattedLabels();
|
|
31907
|
-
|
|
31908
|
-
// Special label rotate.
|
|
31909
|
-
var labelRotation = (
|
|
31910
|
-
retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
|
|
31911
|
-
) * PI / 180;
|
|
31912
|
-
|
|
31913
|
-
var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
|
|
31914
|
-
var categoryData = axisModel.get('data');
|
|
31915
|
-
|
|
31916
|
-
var textEls = [];
|
|
31917
|
-
var silent = isSilent(axisModel);
|
|
31918
|
-
var triggerEvent = axisModel.get('triggerEvent');
|
|
31919
|
-
|
|
31920
|
-
zrUtil.each(ticks, function (tickVal, index) {
|
|
31921
|
-
if (ifIgnoreOnTick(axis, index, opt.labelInterval)) {
|
|
31922
|
-
return;
|
|
31923
|
-
}
|
|
31924
|
-
|
|
31925
|
-
var itemLabelModel = labelModel;
|
|
31926
|
-
if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
|
|
31927
|
-
itemLabelModel = new Model(
|
|
31928
|
-
categoryData[tickVal].textStyle, labelModel, axisModel.ecModel
|
|
31929
|
-
);
|
|
31930
|
-
}
|
|
31931
|
-
|
|
31932
|
-
var textColor = itemLabelModel.getTextColor()
|
|
31933
|
-
|| axisModel.get('axisLine.lineStyle.color');
|
|
31934
|
-
|
|
31935
|
-
var tickCoord = axis.dataToCoord(tickVal);
|
|
31936
|
-
var pos = [
|
|
31937
|
-
tickCoord,
|
|
31938
|
-
opt.labelOffset + opt.labelDirection * labelMargin
|
|
31939
|
-
];
|
|
31940
|
-
var labelStr = axis.scale.getLabel(tickVal);
|
|
31941
|
-
|
|
31942
|
-
var textEl = new graphic.Text({
|
|
31943
|
-
// Id for animation
|
|
31944
|
-
anid: 'label_' + tickVal,
|
|
31945
|
-
position: pos,
|
|
31946
|
-
rotation: labelLayout.rotation,
|
|
31947
|
-
silent: silent,
|
|
31948
|
-
z2: 10
|
|
31949
|
-
});
|
|
31950
|
-
|
|
31951
|
-
graphic.setTextStyle(textEl.style, itemLabelModel, {
|
|
31952
|
-
text: labels[index],
|
|
31953
|
-
textAlign: itemLabelModel.getShallow('align', true)
|
|
31954
|
-
|| labelLayout.textAlign,
|
|
31955
|
-
textVerticalAlign: itemLabelModel.getShallow('verticalAlign', true)
|
|
31956
|
-
|| itemLabelModel.getShallow('baseline', true)
|
|
31957
|
-
|| labelLayout.textVerticalAlign,
|
|
31958
|
-
textFill: typeof textColor === 'function'
|
|
31959
|
-
? textColor(
|
|
31960
|
-
// (1) In category axis with data zoom, tick is not the original
|
|
31961
|
-
// index of axis.data. So tick should not be exposed to user
|
|
31962
|
-
// in category axis.
|
|
31963
|
-
// (2) Compatible with previous version, which always returns labelStr.
|
|
31964
|
-
// But in interval scale labelStr is like '223,445', which maked
|
|
31965
|
-
// user repalce ','. So we modify it to return original val but remain
|
|
31966
|
-
// it as 'string' to avoid error in replacing.
|
|
31967
|
-
axis.type === 'category' ? labelStr : axis.type === 'value' ? tickVal + '' : tickVal,
|
|
31968
|
-
index
|
|
31969
|
-
)
|
|
31970
|
-
: textColor
|
|
31971
|
-
});
|
|
31972
|
-
|
|
31973
|
-
// Pack data for mouse event
|
|
31974
|
-
if (triggerEvent) {
|
|
31975
|
-
textEl.eventData = makeAxisEventDataBase(axisModel);
|
|
31976
|
-
textEl.eventData.targetType = 'axisLabel';
|
|
31977
|
-
textEl.eventData.value = labelStr;
|
|
31978
|
-
}
|
|
31979
|
-
|
|
31980
|
-
// FIXME
|
|
31981
|
-
this._dumbGroup.add(textEl);
|
|
31982
|
-
textEl.updateTransform();
|
|
31983
|
-
|
|
31984
|
-
textEls.push(textEl);
|
|
31985
|
-
this.group.add(textEl);
|
|
31986
31913
|
|
|
31987
|
-
|
|
31914
|
+
var tickEls = buildAxisTick(this, axisModel, opt);
|
|
31915
|
+
var labelEls = buildAxisLabel(this, axisModel, opt);
|
|
31988
31916
|
|
|
31989
|
-
|
|
31990
|
-
|
|
31991
|
-
fixMinMaxLabelShow(axisModel, textEls);
|
|
31917
|
+
fixMinMaxLabelShow(axisModel, labelEls, tickEls);
|
|
31992
31918
|
},
|
|
31993
31919
|
|
|
31994
31920
|
/**
|
|
@@ -32017,7 +31943,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
32017
31943
|
? extent[1] + gapSignal * gap
|
|
32018
31944
|
: (extent[0] + extent[1]) / 2, // 'middle'
|
|
32019
31945
|
// Reuse labelOffset.
|
|
32020
|
-
nameLocation
|
|
31946
|
+
isNameLocationCenter(nameLocation) ? opt.labelOffset + nameDirection * gap : 0
|
|
32021
31947
|
];
|
|
32022
31948
|
|
|
32023
31949
|
var labelLayout;
|
|
@@ -32029,7 +31955,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
32029
31955
|
|
|
32030
31956
|
var axisNameAvailableWidth;
|
|
32031
31957
|
|
|
32032
|
-
if (nameLocation
|
|
31958
|
+
if (isNameLocationCenter(nameLocation)) {
|
|
32033
31959
|
labelLayout = innerTextLayout(
|
|
32034
31960
|
opt.rotation,
|
|
32035
31961
|
nameRotation != null ? nameRotation : opt.rotation, // Adapt to axis.
|
|
@@ -32210,32 +32136,64 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
32210
32136
|
);
|
|
32211
32137
|
}
|
|
32212
32138
|
|
|
32213
|
-
function fixMinMaxLabelShow(axisModel,
|
|
32139
|
+
function fixMinMaxLabelShow(axisModel, labelEls, tickEls) {
|
|
32214
32140
|
// If min or max are user set, we need to check
|
|
32215
32141
|
// If the tick on min(max) are overlap on their neighbour tick
|
|
32216
32142
|
// If they are overlapped, we need to hide the min(max) tick label
|
|
32217
32143
|
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
|
|
32218
32144
|
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
|
|
32219
|
-
|
|
32220
|
-
|
|
32221
|
-
|
|
32222
|
-
|
|
32145
|
+
|
|
32146
|
+
// FIXME
|
|
32147
|
+
// Have not consider onBand yet, where tick els is more than label els.
|
|
32148
|
+
|
|
32149
|
+
labelEls = labelEls || [];
|
|
32150
|
+
tickEls = tickEls || [];
|
|
32151
|
+
|
|
32152
|
+
var firstLabel = labelEls[0];
|
|
32153
|
+
var nextLabel = labelEls[1];
|
|
32154
|
+
var lastLabel = labelEls[labelEls.length - 1];
|
|
32155
|
+
var prevLabel = labelEls[labelEls.length - 2];
|
|
32156
|
+
|
|
32157
|
+
var firstTick = tickEls[0];
|
|
32158
|
+
var nextTick = tickEls[1];
|
|
32159
|
+
var lastTick = tickEls[tickEls.length - 1];
|
|
32160
|
+
var prevTick = tickEls[tickEls.length - 2];
|
|
32223
32161
|
|
|
32224
32162
|
if (showMinLabel === false) {
|
|
32225
|
-
firstLabel
|
|
32163
|
+
ignoreEl(firstLabel);
|
|
32164
|
+
ignoreEl(firstTick);
|
|
32226
32165
|
}
|
|
32227
|
-
else if (
|
|
32228
|
-
|
|
32166
|
+
else if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
|
|
32167
|
+
if (showMinLabel) {
|
|
32168
|
+
ignoreEl(nextLabel);
|
|
32169
|
+
ignoreEl(nextTick);
|
|
32170
|
+
}
|
|
32171
|
+
else {
|
|
32172
|
+
ignoreEl(firstLabel);
|
|
32173
|
+
ignoreEl(firstTick);
|
|
32174
|
+
}
|
|
32229
32175
|
}
|
|
32230
32176
|
|
|
32231
32177
|
if (showMaxLabel === false) {
|
|
32232
|
-
lastLabel
|
|
32178
|
+
ignoreEl(lastLabel);
|
|
32179
|
+
ignoreEl(lastTick);
|
|
32233
32180
|
}
|
|
32234
|
-
else if (
|
|
32235
|
-
|
|
32181
|
+
else if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
|
|
32182
|
+
if (showMaxLabel) {
|
|
32183
|
+
ignoreEl(prevLabel);
|
|
32184
|
+
ignoreEl(prevTick);
|
|
32185
|
+
}
|
|
32186
|
+
else {
|
|
32187
|
+
ignoreEl(lastLabel);
|
|
32188
|
+
ignoreEl(lastTick);
|
|
32189
|
+
}
|
|
32236
32190
|
}
|
|
32237
32191
|
}
|
|
32238
32192
|
|
|
32193
|
+
function ignoreEl(el) {
|
|
32194
|
+
el && (el.ignore = true);
|
|
32195
|
+
}
|
|
32196
|
+
|
|
32239
32197
|
function isTwoLabelOverlapped(current, next, labelLayout) {
|
|
32240
32198
|
// current and next has the same rotation.
|
|
32241
32199
|
var firstRect = current && current.getBoundingRect().clone();
|
|
@@ -32256,11 +32214,28 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
32256
32214
|
return firstRect.intersect(nextRect);
|
|
32257
32215
|
}
|
|
32258
32216
|
|
|
32217
|
+
function isNameLocationCenter(nameLocation) {
|
|
32218
|
+
return nameLocation === 'middle' || nameLocation === 'center';
|
|
32219
|
+
}
|
|
32259
32220
|
|
|
32260
32221
|
/**
|
|
32261
32222
|
* @static
|
|
32262
32223
|
*/
|
|
32263
|
-
var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (
|
|
32224
|
+
var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (
|
|
32225
|
+
axis,
|
|
32226
|
+
i,
|
|
32227
|
+
interval,
|
|
32228
|
+
ticksCnt,
|
|
32229
|
+
showMinLabel,
|
|
32230
|
+
showMaxLabel
|
|
32231
|
+
) {
|
|
32232
|
+
if (i === 0 && showMinLabel || i === ticksCnt - 1 && showMaxLabel) {
|
|
32233
|
+
return false;
|
|
32234
|
+
}
|
|
32235
|
+
|
|
32236
|
+
// FIXME
|
|
32237
|
+
// Have not consider label overlap (if label is too long) yet.
|
|
32238
|
+
|
|
32264
32239
|
var rawTick;
|
|
32265
32240
|
var scale = axis.scale;
|
|
32266
32241
|
return scale.type === 'ordinal'
|
|
@@ -32285,6 +32260,187 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
32285
32260
|
return interval;
|
|
32286
32261
|
};
|
|
32287
32262
|
|
|
32263
|
+
function buildAxisTick(axisBuilder, axisModel, opt) {
|
|
32264
|
+
var axis = axisModel.axis;
|
|
32265
|
+
|
|
32266
|
+
if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
|
|
32267
|
+
return;
|
|
32268
|
+
}
|
|
32269
|
+
|
|
32270
|
+
var tickModel = axisModel.getModel('axisTick');
|
|
32271
|
+
|
|
32272
|
+
var lineStyleModel = tickModel.getModel('lineStyle');
|
|
32273
|
+
var tickLen = tickModel.get('length');
|
|
32274
|
+
|
|
32275
|
+
var tickInterval = getInterval(tickModel, opt.labelInterval);
|
|
32276
|
+
var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
|
|
32277
|
+
// FIXME
|
|
32278
|
+
// Corresponds to ticksCoords ?
|
|
32279
|
+
var ticks = axis.scale.getTicks();
|
|
32280
|
+
|
|
32281
|
+
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
|
|
32282
|
+
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
|
|
32283
|
+
|
|
32284
|
+
var pt1 = [];
|
|
32285
|
+
var pt2 = [];
|
|
32286
|
+
var matrix = axisBuilder._transform;
|
|
32287
|
+
|
|
32288
|
+
var tickEls = [];
|
|
32289
|
+
|
|
32290
|
+
var ticksCnt = ticksCoords.length;
|
|
32291
|
+
for (var i = 0; i < ticksCnt; i++) {
|
|
32292
|
+
// Only ordinal scale support tick interval
|
|
32293
|
+
if (ifIgnoreOnTick(
|
|
32294
|
+
axis, i, tickInterval, ticksCnt,
|
|
32295
|
+
showMinLabel, showMaxLabel
|
|
32296
|
+
)) {
|
|
32297
|
+
continue;
|
|
32298
|
+
}
|
|
32299
|
+
|
|
32300
|
+
var tickCoord = ticksCoords[i];
|
|
32301
|
+
|
|
32302
|
+
pt1[0] = tickCoord;
|
|
32303
|
+
pt1[1] = 0;
|
|
32304
|
+
pt2[0] = tickCoord;
|
|
32305
|
+
pt2[1] = opt.tickDirection * tickLen;
|
|
32306
|
+
|
|
32307
|
+
if (matrix) {
|
|
32308
|
+
v2ApplyTransform(pt1, pt1, matrix);
|
|
32309
|
+
v2ApplyTransform(pt2, pt2, matrix);
|
|
32310
|
+
}
|
|
32311
|
+
// Tick line, Not use group transform to have better line draw
|
|
32312
|
+
var tickEl = new graphic.Line(graphic.subPixelOptimizeLine({
|
|
32313
|
+
// Id for animation
|
|
32314
|
+
anid: 'tick_' + ticks[i],
|
|
32315
|
+
|
|
32316
|
+
shape: {
|
|
32317
|
+
x1: pt1[0],
|
|
32318
|
+
y1: pt1[1],
|
|
32319
|
+
x2: pt2[0],
|
|
32320
|
+
y2: pt2[1]
|
|
32321
|
+
},
|
|
32322
|
+
style: zrUtil.defaults(
|
|
32323
|
+
lineStyleModel.getLineStyle(),
|
|
32324
|
+
{
|
|
32325
|
+
stroke: axisModel.get('axisLine.lineStyle.color')
|
|
32326
|
+
}
|
|
32327
|
+
),
|
|
32328
|
+
z2: 2,
|
|
32329
|
+
silent: true
|
|
32330
|
+
}));
|
|
32331
|
+
axisBuilder.group.add(tickEl);
|
|
32332
|
+
tickEls.push(tickEl);
|
|
32333
|
+
}
|
|
32334
|
+
|
|
32335
|
+
return tickEls;
|
|
32336
|
+
}
|
|
32337
|
+
|
|
32338
|
+
function buildAxisLabel(axisBuilder, axisModel, opt) {
|
|
32339
|
+
var axis = axisModel.axis;
|
|
32340
|
+
var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
|
|
32341
|
+
|
|
32342
|
+
if (!show || axis.scale.isBlank()) {
|
|
32343
|
+
return;
|
|
32344
|
+
}
|
|
32345
|
+
|
|
32346
|
+
var labelModel = axisModel.getModel('axisLabel');
|
|
32347
|
+
var labelMargin = labelModel.get('margin');
|
|
32348
|
+
var ticks = axis.scale.getTicks();
|
|
32349
|
+
var labels = axisModel.getFormattedLabels();
|
|
32350
|
+
|
|
32351
|
+
// Special label rotate.
|
|
32352
|
+
var labelRotation = (
|
|
32353
|
+
retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
|
|
32354
|
+
) * PI / 180;
|
|
32355
|
+
|
|
32356
|
+
var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
|
|
32357
|
+
var categoryData = axisModel.get('data');
|
|
32358
|
+
|
|
32359
|
+
var labelEls = [];
|
|
32360
|
+
var silent = isSilent(axisModel);
|
|
32361
|
+
var triggerEvent = axisModel.get('triggerEvent');
|
|
32362
|
+
|
|
32363
|
+
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
|
|
32364
|
+
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
|
|
32365
|
+
|
|
32366
|
+
zrUtil.each(ticks, function (tickVal, index) {
|
|
32367
|
+
if (ifIgnoreOnTick(
|
|
32368
|
+
axis, index, opt.labelInterval, ticks.length,
|
|
32369
|
+
showMinLabel, showMaxLabel
|
|
32370
|
+
)) {
|
|
32371
|
+
return;
|
|
32372
|
+
}
|
|
32373
|
+
|
|
32374
|
+
var itemLabelModel = labelModel;
|
|
32375
|
+
if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
|
|
32376
|
+
itemLabelModel = new Model(
|
|
32377
|
+
categoryData[tickVal].textStyle, labelModel, axisModel.ecModel
|
|
32378
|
+
);
|
|
32379
|
+
}
|
|
32380
|
+
|
|
32381
|
+
var textColor = itemLabelModel.getTextColor()
|
|
32382
|
+
|| axisModel.get('axisLine.lineStyle.color');
|
|
32383
|
+
|
|
32384
|
+
var tickCoord = axis.dataToCoord(tickVal);
|
|
32385
|
+
var pos = [
|
|
32386
|
+
tickCoord,
|
|
32387
|
+
opt.labelOffset + opt.labelDirection * labelMargin
|
|
32388
|
+
];
|
|
32389
|
+
var labelStr = axis.scale.getLabel(tickVal);
|
|
32390
|
+
|
|
32391
|
+
var textEl = new graphic.Text({
|
|
32392
|
+
// Id for animation
|
|
32393
|
+
anid: 'label_' + tickVal,
|
|
32394
|
+
position: pos,
|
|
32395
|
+
rotation: labelLayout.rotation,
|
|
32396
|
+
silent: silent,
|
|
32397
|
+
z2: 10
|
|
32398
|
+
});
|
|
32399
|
+
|
|
32400
|
+
graphic.setTextStyle(textEl.style, itemLabelModel, {
|
|
32401
|
+
text: labels[index],
|
|
32402
|
+
textAlign: itemLabelModel.getShallow('align', true)
|
|
32403
|
+
|| labelLayout.textAlign,
|
|
32404
|
+
textVerticalAlign: itemLabelModel.getShallow('verticalAlign', true)
|
|
32405
|
+
|| itemLabelModel.getShallow('baseline', true)
|
|
32406
|
+
|| labelLayout.textVerticalAlign,
|
|
32407
|
+
textFill: typeof textColor === 'function'
|
|
32408
|
+
? textColor(
|
|
32409
|
+
// (1) In category axis with data zoom, tick is not the original
|
|
32410
|
+
// index of axis.data. So tick should not be exposed to user
|
|
32411
|
+
// in category axis.
|
|
32412
|
+
// (2) Compatible with previous version, which always returns labelStr.
|
|
32413
|
+
// But in interval scale labelStr is like '223,445', which maked
|
|
32414
|
+
// user repalce ','. So we modify it to return original val but remain
|
|
32415
|
+
// it as 'string' to avoid error in replacing.
|
|
32416
|
+
axis.type === 'category' ? labelStr : axis.type === 'value' ? tickVal + '' : tickVal,
|
|
32417
|
+
index
|
|
32418
|
+
)
|
|
32419
|
+
: textColor
|
|
32420
|
+
});
|
|
32421
|
+
|
|
32422
|
+
// Pack data for mouse event
|
|
32423
|
+
if (triggerEvent) {
|
|
32424
|
+
textEl.eventData = makeAxisEventDataBase(axisModel);
|
|
32425
|
+
textEl.eventData.targetType = 'axisLabel';
|
|
32426
|
+
textEl.eventData.value = labelStr;
|
|
32427
|
+
}
|
|
32428
|
+
|
|
32429
|
+
// FIXME
|
|
32430
|
+
axisBuilder._dumbGroup.add(textEl);
|
|
32431
|
+
textEl.updateTransform();
|
|
32432
|
+
|
|
32433
|
+
labelEls.push(textEl);
|
|
32434
|
+
axisBuilder.group.add(textEl);
|
|
32435
|
+
|
|
32436
|
+
textEl.decomposeTransform();
|
|
32437
|
+
|
|
32438
|
+
});
|
|
32439
|
+
|
|
32440
|
+
return labelEls;
|
|
32441
|
+
}
|
|
32442
|
+
|
|
32443
|
+
|
|
32288
32444
|
module.exports = AxisBuilder;
|
|
32289
32445
|
|
|
32290
32446
|
|
|
@@ -32923,10 +33079,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
32923
33079
|
// }
|
|
32924
33080
|
// },
|
|
32925
33081
|
itemStyle: {
|
|
32926
|
-
normal: {
|
|
33082
|
+
// normal: {
|
|
32927
33083
|
// color: '各异'
|
|
32928
|
-
},
|
|
32929
|
-
emphasis: {}
|
|
33084
|
+
// },
|
|
33085
|
+
// emphasis: {}
|
|
32930
33086
|
}
|
|
32931
33087
|
}
|
|
32932
33088
|
});
|
|
@@ -33751,8 +33907,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
33751
33907
|
startAngle: 90,
|
|
33752
33908
|
// 最小角度改为0
|
|
33753
33909
|
minAngle: 0,
|
|
33754
|
-
//
|
|
33910
|
+
// 选中时扇区偏移量
|
|
33755
33911
|
selectedOffset: 10,
|
|
33912
|
+
// 高亮扇区偏移量
|
|
33913
|
+
hoverOffset: 10,
|
|
33756
33914
|
|
|
33757
33915
|
// If use strategy to avoid label overlapping
|
|
33758
33916
|
avoidLabelOverlap: true,
|
|
@@ -34087,7 +34245,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
34087
34245
|
sector.stopAnimation(true);
|
|
34088
34246
|
sector.animateTo({
|
|
34089
34247
|
shape: {
|
|
34090
|
-
r: layout.r +
|
|
34248
|
+
r: layout.r + seriesModel.get('hoverOffset')
|
|
34091
34249
|
}
|
|
34092
34250
|
}, 300, 'elasticOut');
|
|
34093
34251
|
}
|