@@ -19,7 +19,8 @@ import { profile } from '@nativescript/core/profiling/profiling';
19
19
import { ChartAnimator } from '../animation/ChartAnimator' ;
20
20
import { ViewPortJob } from '../jobs/ViewPortJob' ;
21
21
import { ChartTouchListener } from '../listener/ChartTouchListener' ;
22
- import { isIOS } from '@nativescript/core/platform' ;
22
+ import { isAndroid , isIOS } from '@nativescript/core/platform' ;
23
+ import { layout } from '@nativescript/core/utils/utils' ;
23
24
24
25
const LOG_TAG = 'NSChart' ;
25
26
@@ -110,7 +111,7 @@ export abstract class Chart<U extends Entry, D extends IDataSet<U>, T extends Ch
110
111
/**
111
112
* text that is displayed when the chart is empty
112
113
*/
113
- private mNoDataText = 'No chart data available.' ;
114
+ private mNoDataText = null ;
114
115
115
116
/**
116
117
* Gesture listener for custom callbacks when making gestures on the chart.
@@ -1544,17 +1545,15 @@ export abstract class Chart<U extends Entry, D extends IDataSet<U>, T extends Ch
1544
1545
// this.onSizeChanged(this.getMeasuredWidth(), this.getMeasuredHeight());
1545
1546
// }
1546
1547
1547
- public onSizeChanged ( w : number , h : number , oldw : number , oldh : number ) : void {
1548
- super . onSizeChanged ( w , h , oldw , oldh ) ;
1549
- // super.setMeasuredDimension(measuredWidth, measuredHeight);
1548
+ onSetWidthHeight ( w : number , h : number ) {
1550
1549
const needsDataSetChanged = ! this . mViewPortHandler . hasChartDimens ( ) ;
1551
- if ( this . mLogEnabled ) console . log ( LOG_TAG , 'OnSizeChanged' , w , h , needsDataSetChanged ) ;
1550
+ if ( this . mLogEnabled ) console . log ( LOG_TAG , 'OnSizeChanged' , w , h , needsDataSetChanged , new Error ( ) . stack ) ;
1552
1551
1553
1552
if ( w > 0 && h > 0 && h < 10000 && h < 10000 ) {
1554
1553
if ( this . mLogEnabled ) console . log ( LOG_TAG , 'Setting chart dimens, width: ' + w + ', height: ' + h ) ;
1555
1554
this . mViewPortHandler . setChartDimens ( w , h ) ;
1556
1555
} else {
1557
- if ( this . mLogEnabled ) console . warn ( LOG_TAG , '*Avoiding* setting chart dimens! width: ' + w + ', height: ' + h ) ;
1556
+ console . warn ( LOG_TAG , '*Avoiding* setting chart dimens! width: ' + w + ', height: ' + h ) ;
1558
1557
}
1559
1558
1560
1559
// This may cause the chart view to mutate properties affecting the view port --
@@ -1574,7 +1573,20 @@ export abstract class Chart<U extends Entry, D extends IDataSet<U>, T extends Ch
1574
1573
1575
1574
this . mJobs = [ ] ;
1576
1575
1577
- // super.onSizeChanged(w, h);
1576
+ }
1577
+ public onLayout ( left : number , top : number , right : number , bottom : number ) {
1578
+ super . onLayout ( left , top , right , bottom ) ;
1579
+
1580
+ if ( isIOS ) {
1581
+ this . onSetWidthHeight ( layout . toDeviceIndependentPixels ( right - left ) , layout . toDeviceIndependentPixels ( bottom - top ) ) ;
1582
+ }
1583
+
1584
+ }
1585
+ public onSizeChanged ( w : number , h : number , oldw : number , oldh : number ) : void {
1586
+ super . onSizeChanged ( w , h , oldw , oldh ) ;
1587
+ if ( isAndroid ) {
1588
+ this . onSetWidthHeight ( w , h ) ;
1589
+ }
1578
1590
}
1579
1591
1580
1592
/**
0 commit comments