From fc4c8b37110b5181c9cd824346344780decaa29a Mon Sep 17 00:00:00 2001 From: pissang Date: Wed, 18 Mar 2020 15:20:29 +0800 Subject: [PATCH] ts: bug fixes --- package.json | 1 + src/chart/bar/PictorialBarView.ts | 2 +- src/chart/gauge/GaugeView.ts | 2 + src/chart/heatmap/HeatmapLayer.ts | 5 ++- src/chart/helper/EffectLine.ts | 4 +- src/chart/helper/EffectPolyline.ts | 2 +- src/chart/helper/LinePath.ts | 2 +- src/chart/themeRiver/ThemeRiverSeries.ts | 2 + src/component/axis/SingleAxisView.ts | 3 ++ src/component/marker/MarkPointView.ts | 1 + src/component/visualMap/PiecewiseModel.ts | 32 ++++++------- src/coord/cartesian/Cartesian2D.ts | 4 +- src/coord/cartesian/Grid.ts | 3 +- src/coord/single/AxisModel.ts | 2 +- src/util/clazz.ts | 5 ++- src/util/component.ts | 6 ++- test/line-visual.html | 55 ----------------------- test/runTest/server.js | 1 + test/runTest/util.js | 4 +- test/visualMap-layout.html | 32 +++++++++---- 20 files changed, 73 insertions(+), 95 deletions(-) diff --git a/package.json b/package.json index e5dd48732..d1b364b02 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "scripts": { "prepublish": "node build/build.js --prepublish", "build": "node build/build.js", + "build:full": "node build/build.js --clean", "watch": "node build/build.js --watch", "release": "node build/build.js --release", "help": "node build/build.js --help", diff --git a/src/chart/bar/PictorialBarView.ts b/src/chart/bar/PictorialBarView.ts index 19ceb2bf5..9d3060025 100644 --- a/src/chart/bar/PictorialBarView.ts +++ b/src/chart/bar/PictorialBarView.ts @@ -948,6 +948,6 @@ function toIntTimes(times: number) { : Math.ceil(times); } -ComponentView.registerClass(PictorialBarView); +ChartView.registerClass(PictorialBarView); export default PictorialBarView; \ No newline at end of file diff --git a/src/chart/gauge/GaugeView.ts b/src/chart/gauge/GaugeView.ts index 595213bbb..a57f99c8b 100644 --- a/src/chart/gauge/GaugeView.ts +++ b/src/chart/gauge/GaugeView.ts @@ -465,4 +465,6 @@ class GaugeView extends ChartView { } } +ChartView.registerClass(GaugeView); + export default GaugeView; diff --git a/src/chart/heatmap/HeatmapLayer.ts b/src/chart/heatmap/HeatmapLayer.ts index de2619ad5..2fcc3ecd9 100644 --- a/src/chart/heatmap/HeatmapLayer.ts +++ b/src/chart/heatmap/HeatmapLayer.ts @@ -37,7 +37,10 @@ class HeatmapLayer { private _brushCanvas: HTMLCanvasElement - private _gradientPixels: Record + private _gradientPixels: Record = { + inRange: null, + outOfRange: null + } constructor() { var canvas = zrUtil.createCanvas(); diff --git a/src/chart/helper/EffectLine.ts b/src/chart/helper/EffectLine.ts index 07a4e2a9a..835061cd7 100644 --- a/src/chart/helper/EffectLine.ts +++ b/src/chart/helper/EffectLine.ts @@ -129,7 +129,7 @@ class EffectLine extends graphic.Group { // Ignore when updating symbol.ignore = true; - this._updateAnimationPoints(symbol, points); + this.updateAnimationPoints(symbol, points); if (constantSpeed > 0) { period = this._getLineLength(symbol) / constantSpeed * 1000; @@ -176,7 +176,7 @@ class EffectLine extends graphic.Group { + vec2.dist(symbol.__cp1, symbol.__p2)); } - private _updateAnimationPoints(symbol: ECSymbolOnEffectLine, points: number[][]) { + protected updateAnimationPoints(symbol: ECSymbolOnEffectLine, points: number[][]) { symbol.__p1 = points[0]; symbol.__p2 = points[1]; symbol.__cp1 = points[2] || [ diff --git a/src/chart/helper/EffectPolyline.ts b/src/chart/helper/EffectPolyline.ts index 3bb93e8d2..ea6dbc2c0 100644 --- a/src/chart/helper/EffectPolyline.ts +++ b/src/chart/helper/EffectPolyline.ts @@ -38,7 +38,7 @@ class EffectPolyline extends EffectLine { }; // Override - updateAnimationPoints(symbol: ECSymbolOnEffectLine, points: number[][]) { + protected updateAnimationPoints(symbol: ECSymbolOnEffectLine, points: number[][]) { this._points = points; var accLenArr = [0]; var len = 0; diff --git a/src/chart/helper/LinePath.ts b/src/chart/helper/LinePath.ts index 5f07b2dcc..fd672c223 100644 --- a/src/chart/helper/LinePath.ts +++ b/src/chart/helper/LinePath.ts @@ -86,7 +86,7 @@ class ECLinePath extends graphic.Path { var shape = this.shape; var p = isStraightLine(shape) ? [shape.x2 - shape.x1, shape.y2 - shape.y1] - : bezierCurveProto.tangentAt(t); + : bezierCurveProto.tangentAt.call(this, t); return vec2.normalize(p, p); } diff --git a/src/chart/themeRiver/ThemeRiverSeries.ts b/src/chart/themeRiver/ThemeRiverSeries.ts index f6309a390..04f235aa2 100644 --- a/src/chart/themeRiver/ThemeRiverSeries.ts +++ b/src/chart/themeRiver/ThemeRiverSeries.ts @@ -340,4 +340,6 @@ class ThemeRiverSeriesModel extends SeriesModel { } } +SeriesModel.registerClass(ThemeRiverSeriesModel); + export default ThemeRiverSeriesModel; \ No newline at end of file diff --git a/src/component/axis/SingleAxisView.ts b/src/component/axis/SingleAxisView.ts index a50e87daa..026139314 100644 --- a/src/component/axis/SingleAxisView.ts +++ b/src/component/axis/SingleAxisView.ts @@ -27,6 +27,7 @@ import SingleAxisModel from '../../coord/single/AxisModel'; import GlobalModel from '../../model/Global'; import ExtensionAPI from '../../ExtensionAPI'; import { Payload } from '../../util/types'; +import ComponentView from '../../view/Component'; var axisBuilderAttrs = [ 'axisLine', 'axisTickLabel', 'axisName' @@ -158,4 +159,6 @@ const axisElementBuilders: Record diff --git a/src/component/visualMap/PiecewiseModel.ts b/src/component/visualMap/PiecewiseModel.ts index af8f21d6a..d0afc4dd7 100644 --- a/src/component/visualMap/PiecewiseModel.ts +++ b/src/component/visualMap/PiecewiseModel.ts @@ -430,7 +430,7 @@ class PiecewiseModel extends VisualMapModel { }; -type ResetMethod = (pieceList: InnerVisualPiece[]) => void; +type ResetMethod = (outPieceList: InnerVisualPiece[]) => void; /** * Key is this._mode * @type {Object} @@ -438,7 +438,7 @@ type ResetMethod = (pieceList: InnerVisualPiece[]) => void; */ var resetMethods: Dictionary & ThisType = { - splitNumber(pieceList) { + splitNumber(outPieceList) { var thisOption = this.option; var precision = Math.min(thisOption.precision, 20); var dataExtent = this.getExtent(); @@ -457,7 +457,7 @@ var resetMethods: Dictionary & ThisType = { var index = 0; if (thisOption.minOpen) { - pieceList.push({ + outPieceList.push({ index: index++, interval: [-Infinity, dataExtent[0]], close: [0, 0] @@ -471,7 +471,7 @@ var resetMethods: Dictionary & ThisType = { ) { var max = index === splitNumber - 1 ? dataExtent[1] : (curr + splitStep); - pieceList.push({ + outPieceList.push({ index: index++, interval: [curr, max], close: [1, 1] @@ -479,36 +479,36 @@ var resetMethods: Dictionary & ThisType = { } if (thisOption.maxOpen) { - pieceList.push({ + outPieceList.push({ index: index++, interval: [dataExtent[1], Infinity], close: [0, 0] }); } - reformIntervals(pieceList as Required[]); + reformIntervals(outPieceList as Required[]); - zrUtil.each(pieceList, function (piece) { + zrUtil.each(outPieceList, function (piece) { piece.text = this.formatValueText(piece.interval); }, this); }, - categories(pieceList) { + categories(outPieceList) { var thisOption = this.option; zrUtil.each(thisOption.categories, function (cate) { // FIXME category模式也使用pieceList,但在visualMapping中不是使用pieceList。 // 是否改一致。 - pieceList.push({ + outPieceList.push({ text: this.formatValueText(cate, true), value: cate }); }, this); // See "Order Rule". - normalizeReverse(thisOption, pieceList); + normalizeReverse(thisOption, outPieceList); }, - pieces(pieceList) { + pieces(outPieceList) { var thisOption = this.option; zrUtil.each(thisOption.pieces, function (pieceListItem, index) { @@ -531,7 +531,7 @@ var resetMethods: Dictionary & ThisType = { else { // `min` `max` is legacy option. // `lt` `gt` `lte` `gte` is recommanded. - var interval = item.interval = [0, 0]; + var interval = item.interval = [] as unknown as [number, number]; var close: typeof item.close = item.close = [0, 0]; var closeList = [1, 0, 1] as const; @@ -568,16 +568,16 @@ var resetMethods: Dictionary & ThisType = { item.visual = VisualMapping.retrieveVisuals(pieceListItem); - pieceList.push(item); + outPieceList.push(item); }, this); // See "Order Rule". - normalizeReverse(thisOption, pieceList); + normalizeReverse(thisOption, outPieceList); // Only pieces - reformIntervals(pieceList as Required[]); + reformIntervals(outPieceList as Required[]); - zrUtil.each(pieceList, function (piece) { + zrUtil.each(outPieceList, function (piece) { var close = piece.close; var edgeSymbols = [['<', '≤'][close[1]], ['>', '≥'][close[0]]]; piece.text = piece.text || this.formatValueText( diff --git a/src/coord/cartesian/Cartesian2D.ts b/src/coord/cartesian/Cartesian2D.ts index 4daae85ea..4b56318e7 100644 --- a/src/coord/cartesian/Cartesian2D.ts +++ b/src/coord/cartesian/Cartesian2D.ts @@ -23,9 +23,11 @@ import Cartesian from './Cartesian'; import { ScaleDataValue } from '../../util/types'; import Axis2D from './Axis2D'; import { CoordinateSystem } from '../CoordinateSystem'; -import Grid, {cartesian2DDimensions} from './Grid'; +import Grid from './Grid'; import GridModel from './GridModel'; +export const cartesian2DDimensions = ['x', 'y']; + class Cartesian2D extends Cartesian implements CoordinateSystem { readonly type = 'cartesian2d'; diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index 58844703b..80c9f6317 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -32,7 +32,7 @@ import { niceScaleExtent, estimateLabelUnionRect } from '../../coord/axisHelper'; -import Cartesian2D from './Cartesian2D'; +import Cartesian2D, {cartesian2DDimensions} from './Cartesian2D'; import Axis2D from './Axis2D'; import CoordinateSystemManager from '../../CoordinateSystem'; import {getStackedDimension} from '../../data/helper/dataStackHelper'; @@ -50,7 +50,6 @@ import List from '../../data/List'; import SeriesModel from '../../model/Series'; -export const cartesian2DDimensions = ['x', 'y']; type Cartesian2DDimensionName = 'x' | 'y'; type FinderAxisIndex = {xAxisIndex?: number, yAxisIndex?: number}; diff --git a/src/coord/single/AxisModel.ts b/src/coord/single/AxisModel.ts index 9706a7c27..984e39c40 100644 --- a/src/coord/single/AxisModel.ts +++ b/src/coord/single/AxisModel.ts @@ -105,7 +105,7 @@ ComponentModel.registerClass(SingleAxisModel); interface SingleAxisModel extends AxisModelCommonMixin, AxisModelExtendedInCreator {} -zrUtil.mixin(SingleAxisModel, {AxisModelCommonMixin}); +zrUtil.mixin(SingleAxisModel, AxisModelCommonMixin.prototype); axisModelCreator('single', SingleAxisModel, SingleAxisModel.defaultOption); diff --git a/src/util/clazz.ts b/src/util/clazz.ts index 182b58a64..157be5b92 100644 --- a/src/util/clazz.ts +++ b/src/util/clazz.ts @@ -147,7 +147,8 @@ export interface CheckableConstructor { isInstance: (ins: any) => boolean; } -var classBase = 0; +// A random offset. +var classBase = Math.round(Math.random() * 10); /** * Implements `CheckableConstructor` for `target`. @@ -163,7 +164,7 @@ var classBase = 0; * ``` */ export function enableClassCheck(target: CheckableConstructor): void { - var classAttr = ['__\0is_clz', classBase++, Math.random().toFixed(3)].join('_'); + var classAttr = ['__\0is_clz', classBase++].join('_'); target.prototype[classAttr] = true; if (__DEV__) { diff --git a/src/util/component.ts b/src/util/component.ts index 8a54d4cb3..c3dffce59 100644 --- a/src/util/component.ts +++ b/src/util/component.ts @@ -22,7 +22,9 @@ import {parseClassType, ClassManager} from './clazz'; import { ComponentOption, ComponentMainType, ComponentSubType, ComponentFullType } from './types'; import { Dictionary } from 'zrender/src/core/types'; -var base = 0; +// A random offset +var base = Math.round(Math.random() * 10); + /** * @public @@ -32,7 +34,7 @@ var base = 0; export function getUID(type: string): string { // Considering the case of crossing js context, // use Math.random to make id as unique as possible. - return [(type || ''), base++, Math.random().toFixed(5)].join('_'); + return [(type || ''), base++].join('_'); } export interface SubTypeDefaulter { diff --git a/test/line-visual.html b/test/line-visual.html index 3a701c7eb..f12624a22 100644 --- a/test/line-visual.html +++ b/test/line-visual.html @@ -70,13 +70,6 @@ under the License. require([ 'echarts' - // 'echarts/chart/line', - // 'echarts/chart/bar', - // 'echarts/component/legend', - // 'echarts/component/grid', - // 'echarts/component/tooltip', - // 'echarts/component/visualMap', - // 'echarts/component/dataZoom' ], function (echarts) { var main = document.getElementById('mainH'); @@ -179,12 +172,6 @@ under the License. require([ 'echarts' - // 'echarts/chart/line', - // 'echarts/component/legend', - // 'echarts/component/grid', - // 'echarts/component/tooltip', - // 'echarts/component/visualMap', - // 'echarts/component/dataZoom' ], function (echarts) { var main = document.getElementById('mainZ'); @@ -286,12 +273,6 @@ under the License. require([ 'echarts' - // 'echarts/chart/line', - // 'echarts/component/legend', - // 'echarts/component/grid', - // 'echarts/component/tooltip', - // 'echarts/component/visualMap', - // 'echarts/component/dataZoom' ], function (echarts) { var main = document.getElementById('mainX0'); @@ -376,12 +357,6 @@ under the License. require([ 'echarts' - // 'echarts/chart/line', - // 'echarts/component/legend', - // 'echarts/component/grid', - // 'echarts/component/tooltip', - // 'echarts/component/visualMap', - // 'echarts/component/dataZoom' ], function (echarts) { var main = document.getElementById('mainX'); @@ -462,12 +437,6 @@ under the License. require([ 'echarts' - // 'echarts/chart/line', - // 'echarts/component/legend', - // 'echarts/component/grid', - // 'echarts/component/tooltip', - // 'echarts/component/visualMap', - // 'echarts/component/dataZoom' ], function (echarts) { var main = document.getElementById('mainX2'); @@ -550,12 +519,6 @@ under the License. require([ 'echarts' - // 'echarts/chart/line', - // 'echarts/component/legend', - // 'echarts/component/grid', - // 'echarts/component/tooltip', - // 'echarts/component/visualMap', - // 'echarts/component/dataZoom' ], function (echarts) { var main = document.getElementById('main0'); @@ -650,12 +613,6 @@ under the License. require([ 'echarts' - // 'echarts/chart/line', - // 'echarts/component/legend', - // 'echarts/component/grid', - // 'echarts/component/tooltip', - // 'echarts/component/visualMap', - // 'echarts/component/dataZoom' ], function (echarts) { var main = document.getElementById('main1'); @@ -740,12 +697,6 @@ under the License. require([ 'echarts' - // 'echarts/chart/line', - // 'echarts/component/legend', - // 'echarts/component/grid', - // 'echarts/component/tooltip', - // 'echarts/component/visualMap', - // 'echarts/component/dataZoom' ], function (echarts) { var main = document.getElementById('main2'); @@ -839,12 +790,6 @@ under the License. require([ 'echarts' - // 'echarts/chart/line', - // 'echarts/component/legend', - // 'echarts/component/grid', - // 'echarts/component/tooltip', - // 'echarts/component/visualMap', - // 'echarts/component/dataZoom' ], function (echarts) { var main = document.getElementById('main4'); diff --git a/test/runTest/server.js b/test/runTest/server.js index 04ba56069..79eb6cafe 100644 --- a/test/runTest/server.js +++ b/test/runTest/server.js @@ -178,6 +178,7 @@ function startTests(testsNameList, socket, { function checkPuppeteer() { try { const packageConfig = require('puppeteer/package.json'); + console.log(`puppeteer version: ${packageConfig.version}`) return semver.satisfies(packageConfig.version, '>=1.19.0'); } catch (e) { diff --git a/test/runTest/util.js b/test/runTest/util.js index 9bac45e4b..c30f15687 100644 --- a/test/runTest/util.js +++ b/test/runTest/util.js @@ -126,11 +126,11 @@ module.exports.buildRuntimeCode = async function () { } ] }); - const output = await bundle.generate({ + const { output } = await bundle.generate({ format: 'iife', name: 'autorun' }); - return output.code; + return output[0].code; }; module.exports.waitTime = function (time) { diff --git a/test/visualMap-layout.html b/test/visualMap-layout.html index ffc5a5d11..931ed0bd9 100644 --- a/test/visualMap-layout.html +++ b/test/visualMap-layout.html @@ -305,7 +305,9 @@ under the License. inverse: true, dimension: 3, backgroundColor: '#eee', - inRange: 'colorSaturation' + inRange: { + colorSaturation: [0.3, 1] + } }); makeChart({ right: 0, @@ -315,7 +317,9 @@ under the License. calculable: true, dimension: 3, backgroundColor: '#eee', - inRange: 'colorLightness' + inRange: { + colorLightness: [0.9, 0.5] + } }); makeChart({ top: 40, @@ -324,7 +328,9 @@ under the License. calculable: true, dimension: 3, backgroundColor: '#eee', - inRange: 'colorAlpha' + inRange: { + colorAlpha: [0.3, 1] + } }); makeChart({ left: 'center', @@ -334,7 +340,9 @@ under the License. calculable: true, dimension: 3, backgroundColor: '#eee', - inRange: 'colorAlpha' + inRange: { + colorAlpha: [0.3, 1] + } }); @@ -392,7 +400,9 @@ under the License. inverse: true, dimension: 3, backgroundColor: '#eee', - inRange: 'colorSaturation' + inRange: { + colorSaturation: [0.3, 1] + } }); makeChart({ right: 0, @@ -404,7 +414,9 @@ under the License. calculable: true, dimension: 3, backgroundColor: '#eee', - inRange: 'colorLightness' + inRange: { + colorLightness: [0.9, 0.5] + } }); makeChart({ top: 40, @@ -414,7 +426,9 @@ under the License. calculable: true, dimension: 3, backgroundColor: '#eee', - inRange: 'colorAlpha' + inRange: { + colorAlpha: [0.3, 1] + } }); makeChart({ left: 'center', @@ -425,7 +439,9 @@ under the License. calculable: true, dimension: 3, backgroundColor: '#eee', - inRange: 'colorAlpha' + inRange: { + colorAlpha: [0.3, 1] + } }); -- GitLab