You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/03/19 06:43:01 UTC
[incubator-echarts] branch typescript updated: ts: bug squash
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch typescript
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
The following commit(s) were added to refs/heads/typescript by this push:
new 0e7adc3 ts: bug squash
0e7adc3 is described below
commit 0e7adc32ed58b77298f0794977d22f61aa4c5798
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Mar 19 14:42:23 2020 +0800
ts: bug squash
---
src/chart/gauge/GaugeView.ts | 4 ++--
src/chart/graph/GraphView.ts | 2 +-
src/chart/helper/LargeLineDraw.ts | 9 ++++-----
src/chart/helper/LargeSymbolDraw.ts | 10 ++++------
src/chart/helper/Line.ts | 4 ++--
src/chart/helper/Symbol.ts | 4 +---
src/chart/pie/PieView.ts | 10 +++-------
src/chart/radar/RadarView.ts | 2 +-
src/component/legend/ScrollableLegendView.ts | 5 ++++-
src/coord/polar/AngleAxis.ts | 5 ++++-
src/preprocessor/helper/compatStyle.ts | 2 +-
test/radar4.html | 2 +-
12 files changed, 28 insertions(+), 31 deletions(-)
diff --git a/src/chart/gauge/GaugeView.ts b/src/chart/gauge/GaugeView.ts
index a57f99c..ebbc9cb 100644
--- a/src/chart/gauge/GaugeView.ts
+++ b/src/chart/gauge/GaugeView.ts
@@ -50,10 +50,10 @@ function parsePosition(seriesModel: GaugeSeriesModel, api: ExtensionAPI): PosInf
}
function formatLabel(value: number, labelFormatter: string | ((value: number) => string)): string {
- let label = value + '';
+ let label = value == null ? '' : (value + '');
if (labelFormatter) {
if (typeof labelFormatter === 'string') {
- label = labelFormatter.replace('{value}', value != null ? value + '' : '');
+ label = labelFormatter.replace('{value}', label);
}
else if (typeof labelFormatter === 'function') {
label = labelFormatter(value);
diff --git a/src/chart/graph/GraphView.ts b/src/chart/graph/GraphView.ts
index 42a5302..33aaed5 100644
--- a/src/chart/graph/GraphView.ts
+++ b/src/chart/graph/GraphView.ts
@@ -217,7 +217,7 @@ class GraphView extends ChartView {
api.dispatchAction({
type: 'focusNodeAdjacency',
seriesId: seriesModel.id,
- dataIndex: el.dataIndex
+ dataIndex: graphic.getECData(el).dataIndex
});
});
el.on('mouseout', (el as any)[UNFOCUS_ADJACENCY] = function () {
diff --git a/src/chart/helper/LargeLineDraw.ts b/src/chart/helper/LargeLineDraw.ts
index fa46af4..91803a1 100644
--- a/src/chart/helper/LargeLineDraw.ts
+++ b/src/chart/helper/LargeLineDraw.ts
@@ -55,8 +55,6 @@ type LargeLinesData = List<Model<LargeLinesCommonOption> & {
class LargeLinesPath extends graphic.Path {
shape: LargeLinesPathShape
- seriesIndex: number
- dataIndex: number
__startIndex: number
constructor(opts?: LargeLinesPathProps) {
@@ -262,15 +260,16 @@ class LargeLineDraw {
lineEl.setStyle('fill');
if (!isIncremental) {
+ let ecData = graphic.getECData(lineEl);
// Enable tooltip
// PENDING May have performance issue when path is extremely large
- lineEl.seriesIndex = hostModel.seriesIndex;
+ ecData.seriesIndex = hostModel.seriesIndex;
lineEl.on('mousemove', function (e) {
- lineEl.dataIndex = null;
+ ecData.dataIndex = null;
var dataIndex = lineEl.findDataIndex(e.offsetX, e.offsetY);
if (dataIndex > 0) {
// Provide dataIndex for tooltip
- lineEl.dataIndex = dataIndex + lineEl.__startIndex;
+ ecData.dataIndex = dataIndex + lineEl.__startIndex;
}
});
}
diff --git a/src/chart/helper/LargeSymbolDraw.ts b/src/chart/helper/LargeSymbolDraw.ts
index f48034f..caa6493 100644
--- a/src/chart/helper/LargeSymbolDraw.ts
+++ b/src/chart/helper/LargeSymbolDraw.ts
@@ -57,9 +57,6 @@ class LargeSymbolPath extends graphic.Path<LargeSymbolPathProps> {
startIndex: number
endIndex: number
- dataIndex: number
- seriesIndex: number
-
constructor(opts?: LargeSymbolPathProps) {
super(opts, null, new LargeSymbolPathShape());
}
@@ -296,15 +293,16 @@ class LargeSymbolDraw {
}
if (!isIncremental) {
+ let ecData = graphic.getECData(symbolEl);
// Enable tooltip
// PENDING May have performance issue when path is extremely large
- symbolEl.seriesIndex = (hostModel as SeriesModel).seriesIndex;
+ ecData.seriesIndex = (hostModel as SeriesModel).seriesIndex;
symbolEl.on('mousemove', function (e) {
- symbolEl.dataIndex = null;
+ ecData.dataIndex = null;
var dataIndex = symbolEl.findDataIndex(e.offsetX, e.offsetY);
if (dataIndex >= 0) {
// Provide dataIndex for tooltip
- symbolEl.dataIndex = dataIndex + (symbolEl.startIndex || 0);
+ ecData.dataIndex = dataIndex + (symbolEl.startIndex || 0);
}
});
}
diff --git a/src/chart/helper/Line.ts b/src/chart/helper/Line.ts
index 0be21a7..01793b9 100644
--- a/src/chart/helper/Line.ts
+++ b/src/chart/helper/Line.ts
@@ -262,7 +262,7 @@ class Line extends graphic.Group {
// values have to be set on `normalStyle`.
if (normalText != null || emphasisText != null) {
graphic.setTextStyle(label.style, labelModel, {
- text: normalText + ''
+ text: normalText as string
}, {
autoColor: defaultLabelColor
});
@@ -282,7 +282,7 @@ class Line extends graphic.Group {
if (emphasisText != null) {
// Only these properties supported in this emphasis style here.
label.hoverStyle = {
- text: emphasisText + '',
+ text: emphasisText as string,
textFill: hoverLabelModel.getTextColor(true),
// For merging hover style to normal style, do not use
// `hoverLabelModel.getFont()` here.
diff --git a/src/chart/helper/Symbol.ts b/src/chart/helper/Symbol.ts
index d51da2a..f6aa009 100644
--- a/src/chart/helper/Symbol.ts
+++ b/src/chart/helper/Symbol.ts
@@ -42,8 +42,6 @@ type ECSymbol = ReturnType<typeof createSymbol> & {
class Symbol extends graphic.Group {
- dataIndex: number
-
private _seriesModel: SeriesModel
private _symbolType: string
@@ -329,7 +327,7 @@ class Symbol extends graphic.Group {
scale: [0, 0]
},
this._seriesModel,
- this.dataIndex,
+ graphic.getECData(this).dataIndex,
cb
);
}
diff --git a/src/chart/pie/PieView.ts b/src/chart/pie/PieView.ts
index 0970a66..000e91f 100644
--- a/src/chart/pie/PieView.ts
+++ b/src/chart/pie/PieView.ts
@@ -24,7 +24,7 @@ import * as graphic from '../../util/graphic';
import ChartView from '../../view/Chart';
import GlobalModel from '../../model/Global';
import ExtensionAPI from '../../ExtensionAPI';
-import { Payload, DisplayState } from '../../util/types';
+import { Payload, DisplayState, ECElement } from '../../util/types';
import List from '../../data/List';
import PieSeriesModel, {PieDataItemOption} from './PieSeries';
import { Dictionary } from 'zrender/src/core/types';
@@ -39,7 +39,7 @@ function updateDataSelected(
api: ExtensionAPI
): void {
var data = seriesModel.getData();
- var dataIndex = this.dataIndex;
+ var dataIndex = graphic.getECData(this).dataIndex;
var name = data.getName(dataIndex);
var selectedOffset = seriesModel.get('selectedOffset');
@@ -96,10 +96,6 @@ interface PieceElementExtension extends Displayable {
*/
class PiePiece extends graphic.Group {
- // FIXME:TS add a type in `util/graphic.ts` for `highDownOnUpdate`.
- highDownOnUpdate: any;
- dataIndex: number;
-
constructor(data: List, idx: number) {
super();
@@ -197,7 +193,7 @@ class PiePiece extends graphic.Group {
var withAnimation = !firstCreate && animationTypeUpdate === 'transition';
this._updateLabel(data, idx, withAnimation);
- this.highDownOnUpdate = (itemModel.get('hoverAnimation') && seriesModel.isAnimationEnabled())
+ (this as ECElement).highDownOnUpdate = (itemModel.get('hoverAnimation') && seriesModel.isAnimationEnabled())
? function (fromState: DisplayState, toState: DisplayState): void {
if (toState === 'emphasis') {
labelLine.ignore = labelLine.hoverIgnore;
diff --git a/src/chart/radar/RadarView.ts b/src/chart/radar/RadarView.ts
index 63a8a29..fa37df3 100644
--- a/src/chart/radar/RadarView.ts
+++ b/src/chart/radar/RadarView.ts
@@ -228,7 +228,7 @@ class RadarView extends ChartView {
labelFetcher: data.hostModel,
labelDataIndex: idx,
labelDimIndex: symbolPath.__dimIdx,
- defaultText: defaultText + '',
+ defaultText: defaultText as string,
autoColor: color,
isRectText: true
}
diff --git a/src/component/legend/ScrollableLegendView.ts b/src/component/legend/ScrollableLegendView.ts
index 1a8e06d..8b1c4d9 100644
--- a/src/component/legend/ScrollableLegendView.ts
+++ b/src/component/legend/ScrollableLegendView.ts
@@ -136,6 +136,8 @@ class ScrollableLegendView extends LegendView {
controllerGroup.add(new graphic.Text({
name: 'pageText',
style: {
+ // Placeholder to calculate a proper layout.
+ text: 'xx/xx',
textFill: pageTextStyleModel.getTextColor(),
font: pageTextStyleModel.getFont(),
textVerticalAlign: 'middle',
@@ -386,7 +388,8 @@ class ScrollableLegendView extends LegendView {
pageText && pageFormatter && pageText.setStyle(
'text',
zrUtil.isString(pageFormatter)
- ? pageFormatter.replace('{current}', current + '').replace('{total}', total + '')
+ ? pageFormatter.replace('{current}', current == null ? '' : current + '')
+ .replace('{total}', total == null ? '' : total + '')
: pageFormatter({current: current, total: total})
);
}
diff --git a/src/coord/polar/AngleAxis.ts b/src/coord/polar/AngleAxis.ts
index 8444a9f..002b116 100644
--- a/src/coord/polar/AngleAxis.ts
+++ b/src/coord/polar/AngleAxis.ts
@@ -77,7 +77,10 @@ class AngleAxis extends Axis {
// Not precise, just use height as text width
// and each distance from axis line yet.
var rect = textContain.getBoundingRect(
- tickValue + '', labelModel.getFont(), 'center', 'top'
+ tickValue == null ? '' : tickValue + '',
+ labelModel.getFont(),
+ 'center',
+ 'top'
);
var maxH = Math.max(rect.height, 7);
diff --git a/src/preprocessor/helper/compatStyle.ts b/src/preprocessor/helper/compatStyle.ts
index dde1e32..bbc20bb 100644
--- a/src/preprocessor/helper/compatStyle.ts
+++ b/src/preprocessor/helper/compatStyle.ts
@@ -292,7 +292,7 @@ export default function (option: any, isTheme?: boolean) {
each(toArr(option.radar), function (radarOpt) {
compatTextStyle(radarOpt, 'name');
// Use axisName instead of name because component has name property
- if (radarOpt.name && !radarOpt.axisName) {
+ if (radarOpt.name && radarOpt.axisName == null) {
radarOpt.axisName = radarOpt.name;
delete radarOpt.name;
if (__DEV__) {
diff --git a/test/radar4.html b/test/radar4.html
index eeab7d5..8875c5a 100644
--- a/test/radar4.html
+++ b/test/radar4.html
@@ -52,7 +52,7 @@ under the License.
x : 'left',
data:['图一','图二','图三']
},
- polar : [
+ radar : [
{
indicator : [
{ text : '指标一' },
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org