Skip to content

Commit b6a041e

Browse files
committed
fix(dataZoom): render data not equally distributed. close #16924
1 parent 88c77e7 commit b6a041e

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

src/component/dataZoom/SliderZoomView.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
* under the License.
1818
*/
1919

20-
import {bind, each, isFunction, isString, indexOf} from 'zrender/src/core/util';
20+
import { bind, each, isFunction, isString, indexOf } from 'zrender/src/core/util';
2121
import * as eventTool from 'zrender/src/core/event';
2222
import * as graphic from '../../util/graphic';
2323
import * as throttle from '../../util/throttle';
2424
import DataZoomView from './DataZoomView';
25-
import {linearMap, asc, parsePercent} from '../../util/number';
25+
import { linearMap, asc, parsePercent } from '../../util/number';
2626
import * as layout from '../../util/layout';
2727
import sliderMove from '../helper/sliderMove';
2828
import GlobalModel from '../../model/Global';
@@ -41,7 +41,7 @@ import { createSymbol, symbolBuildProxies } from '../../util/symbol';
4141
import { deprecateLog } from '../../util/log';
4242
import { PointLike } from 'zrender/src/core/Point';
4343
import Displayable from 'zrender/src/graphic/Displayable';
44-
import {createTextStyle} from '../../label/labelStyle';
44+
import { createTextStyle } from '../../label/labelStyle';
4545
import SeriesData from '../../data/SeriesData';
4646

4747
const Rect = graphic.Rect;
@@ -227,7 +227,7 @@ class SliderZoomView extends DataZoomView {
227227
// If some of x/y/width/height are not specified,
228228
// auto-adapt according to target grid.
229229
const coordRect = this._findCoordRect();
230-
const ecSize = {width: api.getWidth(), height: api.getHeight()};
230+
const ecSize = { width: api.getWidth(), height: api.getHeight() };
231231
// Default align by coordinate system rect.
232232
const positionInfo = this._orient === HORIZONTAL
233233
? {
@@ -261,7 +261,7 @@ class SliderZoomView extends DataZoomView {
261261
ecSize
262262
);
263263

264-
this._location = {x: layoutRect.x, y: layoutRect.y};
264+
this._location = { x: layoutRect.x, y: layoutRect.y };
265265
this._size = [layoutRect.width, layoutRect.height];
266266
this._orient === VERTICAL && this._size.reverse();
267267
}
@@ -281,13 +281,13 @@ class SliderZoomView extends DataZoomView {
281281
// Transform barGroup.
282282
sliderGroup.attr(
283283
(orient === HORIZONTAL && !inverse)
284-
? {scaleY: otherAxisInverse ? 1 : -1, scaleX: 1 }
285-
: (orient === HORIZONTAL && inverse)
286-
? {scaleY: otherAxisInverse ? 1 : -1, scaleX: -1 }
287-
: (orient === VERTICAL && !inverse)
288-
? {scaleY: otherAxisInverse ? -1 : 1, scaleX: 1, rotation: Math.PI / 2}
289-
// Dont use Math.PI, considering shadow direction.
290-
: {scaleY: otherAxisInverse ? -1 : 1, scaleX: -1, rotation: Math.PI / 2}
284+
? { scaleY: otherAxisInverse ? 1 : -1, scaleX: 1 }
285+
: (orient === HORIZONTAL && inverse)
286+
? { scaleY: otherAxisInverse ? 1 : -1, scaleX: -1 }
287+
: (orient === VERTICAL && !inverse)
288+
? { scaleY: otherAxisInverse ? -1 : 1, scaleX: 1, rotation: Math.PI / 2 }
289+
// Dont use Math.PI, considering shadow direction.
290+
: { scaleY: otherAxisInverse ? -1 : 1, scaleX: -1, rotation: Math.PI / 2 }
291291
);
292292

293293
// Position barGroup
@@ -389,24 +389,24 @@ class SliderZoomView extends DataZoomView {
389389
const linePoints: number[][] = [];
390390
const step = thisShadowExtent[1] / (data.count() - 1);
391391
const normalizationConstant = size[0] / (thisDataExtent[1] - thisDataExtent[0]);
392+
const isTimeAxis = info.thisAxis.type === 'time';
392393
let thisCoord = -step;
393394

394395
// Optimize for large data shadow
395396
const stride = Math.round(data.count() / size[0]);
396397
let lastIsEmpty: boolean;
397398

398399
data.each([info.thisDim, otherDim], function (thisValue: ParsedValue, otherValue: ParsedValue, index) {
399-
if (stride > 0 && (index % stride) && info.thisAxis.type !== 'time') {
400-
thisCoord += step;
401-
return;
402-
}
403-
else if (stride > 0 && (index % stride)) {
400+
if (stride > 0 && (index % stride)) {
401+
if (!isTimeAxis) {
402+
thisCoord += step;
403+
}
404404
return;
405405
}
406406

407-
thisCoord = info.thisAxis.type === 'time'
408-
? (+thisValue - thisDataExtent[0]) * normalizationConstant
409-
: thisCoord + step;
407+
thisCoord = isTimeAxis
408+
? (+thisValue - thisDataExtent[0]) * normalizationConstant
409+
: thisCoord + step;
410410

411411
// FIXME
412412
// Should consider axis.min/axis.max when drawing dataShadow.
@@ -497,8 +497,8 @@ class SliderZoomView extends DataZoomView {
497497
}
498498

499499
if (showDataShadow !== true && indexOf(
500-
SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type')
501-
) < 0
500+
SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type')
501+
) < 0
502502
) {
503503
return;
504504
}
@@ -630,17 +630,17 @@ class SliderZoomView extends DataZoomView {
630630

631631
thisGroup.add(
632632
handleLabels[handleIndex] = new graphic.Text({
633-
silent: true,
634-
invisible: true,
635-
style: createTextStyle(textStyleModel, {
636-
x: 0, y: 0, text: '',
637-
verticalAlign: 'middle',
638-
align: 'center',
639-
fill: textStyleModel.getTextColor(),
640-
font: textStyleModel.getFont()
641-
}),
642-
z2: 10
643-
}));
633+
silent: true,
634+
invisible: true,
635+
style: createTextStyle(textStyleModel, {
636+
x: 0, y: 0, text: '',
637+
verticalAlign: 'middle',
638+
align: 'center',
639+
fill: textStyleModel.getTextColor(),
640+
font: textStyleModel.getFont()
641+
}),
642+
z2: 10
643+
}));
644644

645645
}, this);
646646

@@ -681,8 +681,8 @@ class SliderZoomView extends DataZoomView {
681681
});
682682

683683
actualMoveZone.on('mouseover', () => {
684-
api.enterEmphasis(moveHandle);
685-
})
684+
api.enterEmphasis(moveHandle);
685+
})
686686
.on('mouseout', () => {
687687
api.leaveEmphasis(moveHandle);
688688
});
@@ -888,8 +888,8 @@ class SliderZoomView extends DataZoomView {
888888
return isFunction(labelFormatter)
889889
? labelFormatter(value as number, valueStr)
890890
: isString(labelFormatter)
891-
? labelFormatter.replace('{value}', valueStr)
892-
: valueStr;
891+
? labelFormatter.replace('{value}', valueStr)
892+
: valueStr;
893893
}
894894

895895
/**
@@ -1091,7 +1091,7 @@ class SliderZoomView extends DataZoomView {
10911091
function getOtherDim(thisDim: 'x' | 'y' | 'radius' | 'angle' | 'single' | 'z') {
10921092
// FIXME
10931093
// 这个逻辑和getOtherAxis里一致,但是写在这里是否不好
1094-
const map = {x: 'y', y: 'x', radius: 'angle', angle: 'radius'};
1094+
const map = { x: 'y', y: 'x', radius: 'angle', angle: 'radius' };
10951095
return map[thisDim as 'x' | 'y' | 'radius' | 'angle'];
10961096
}
10971097

0 commit comments

Comments
 (0)