File tree Expand file tree Collapse file tree 3 files changed +20
-12
lines changed Expand file tree Collapse file tree 3 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -889,7 +889,11 @@ define(function(require) {
889
889
// 亚像素优化
890
890
function subPixelOptimize ( position , lineWidth ) {
891
891
if ( lineWidth % 2 == 1 ) {
892
- position += position == Math . ceil ( position ) ? 0.5 : 0 ;
892
+ //position += position == Math.ceil(position) ? 0.5 : 0;
893
+ position = Math . floor ( position ) + 0.5 ;
894
+ }
895
+ else {
896
+ position = Math . round ( position ) ;
893
897
}
894
898
return position ;
895
899
}
Original file line number Diff line number Diff line change @@ -625,15 +625,15 @@ define(function (require) {
625
625
626
626
// 根据类目轴数据索引换算位置
627
627
function getCoordByIndex ( dataIndex ) {
628
- if ( dataIndex < 0 ) {
628
+ if ( dataIndex <= 0 ) {
629
629
if ( option . position == 'bottom' || option . position == 'top' ) {
630
630
return grid . getX ( ) ;
631
631
}
632
632
else {
633
633
return grid . getYend ( ) ;
634
634
}
635
635
}
636
- else if ( dataIndex >= option . data . length ) {
636
+ else if ( dataIndex >= option . data . length - 1 ) {
637
637
if ( option . position == 'bottom' || option . position == 'top' ) {
638
638
return grid . getXend ( ) ;
639
639
}
@@ -644,7 +644,6 @@ define(function (require) {
644
644
else {
645
645
var gap = getGap ( ) ;
646
646
var position = option . boundaryGap ? gap : 0 ;
647
-
648
647
position += dataIndex * gap ;
649
648
650
649
if ( option . position == 'bottom'
@@ -657,12 +656,7 @@ define(function (require) {
657
656
// 纵向
658
657
position = grid . getYend ( ) - position ;
659
658
}
660
-
661
- return ( dataIndex === 0 || dataIndex == option . data . length - 1 )
662
- ? position
663
- : Math . floor ( position ) ;
664
-
665
- // return getCoord(option.data[dataIndex]);
659
+ return Math . floor ( position ) ;
666
660
}
667
661
}
668
662
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ define(function (require) {
66
66
var _zrWidth = zr . getWidth ( ) ;
67
67
68
68
var _lastTipShape = false ;
69
+ var _axisLineWidth = 0 ;
69
70
var _axisLineShape = {
70
71
shape : 'line' ,
71
72
id : zr . newShapeId ( 'tooltip' ) ,
@@ -513,7 +514,10 @@ define(function (require) {
513
514
}
514
515
) ;
515
516
y = zrEvent . getY ( _event ) + 10 ;
516
- x = categoryAxis . getCoordByIndex ( dataIndex ) ;
517
+ x = self . subPixelOptimize (
518
+ categoryAxis . getCoordByIndex ( dataIndex ) ,
519
+ _axisLineWidth
520
+ ) ;
517
521
_styleAxisPointer (
518
522
seriesArray ,
519
523
x , grid . getY ( ) ,
@@ -567,7 +571,10 @@ define(function (require) {
567
571
}
568
572
) ;
569
573
x = zrEvent . getX ( _event ) + 10 ;
570
- y = categoryAxis . getCoordByIndex ( dataIndex ) ;
574
+ y = self . subPixelOptimize (
575
+ categoryAxis . getCoordByIndex ( dataIndex ) ,
576
+ _axisLineWidth
577
+ ) ;
571
578
_styleAxisPointer (
572
579
seriesArray ,
573
580
grid . getX ( ) , y ,
@@ -1303,6 +1310,8 @@ define(function (require) {
1303
1310
_tDom . style . position = 'absolute' ; // 不是多余的,别删!
1304
1311
self . hasAppend = false ;
1305
1312
_setSelectedMap ( ) ;
1313
+
1314
+ _axisLineWidth = option . tooltip . axisPointer . lineStyle . width ;
1306
1315
}
1307
1316
1308
1317
/**
@@ -1325,6 +1334,7 @@ define(function (require) {
1325
1334
option . tooltip . padding
1326
1335
) ;
1327
1336
_setSelectedMap ( ) ;
1337
+ _axisLineWidth = option . tooltip . axisPointer . lineStyle . width ;
1328
1338
}
1329
1339
}
1330
1340
You can’t perform that action at this time.
0 commit comments