@@ -3,9 +3,10 @@ const fs = require("@nativescript/core/file-system");
3
3
const imageSourceModule = require ( "@nativescript/core/image-source" ) ;
4
4
const bd = require ( "@nativescript-community/ui-chart/data/BarData" ) ;
5
5
const bds = require ( "@nativescript-community/ui-chart/data/BarDataSet" ) ;
6
- const be = require ( "@nativescript-community/ui-chart/data/BarEntry" ) ;
7
6
const ld = require ( "@nativescript-community/ui-chart/data/LineData" ) ;
8
7
const lds = require ( "@nativescript-community/ui-chart/data/LineDataSet" ) ;
8
+ const pd = require ( "@nativescript-community/ui-chart/data/PieData" ) ;
9
+ const pds = require ( "@nativescript-community/ui-chart/data/PieDataSet" ) ;
9
10
10
11
function getRandomInt ( min , max )
11
12
{
@@ -39,6 +40,7 @@ exports.onBarChartLoaded = function(args)
39
40
chart . setScaleEnabled ( true ) ;
40
41
chart . setDragEnabled ( true ) ;
41
42
chart . getAxisRight ( ) . setEnabled ( false ) ;
43
+ chart . setHighlightPerTapEnabled ( true ) ;
42
44
// chart.setHardwareAccelerationEnabled(true);
43
45
44
46
const data = new Array ( 5 ) . fill ( 0 ) . map ( function ( v , i )
@@ -89,6 +91,36 @@ exports.onLineChartLoaded = function(args)
89
91
chart . setData ( linedata ) ;
90
92
} ;
91
93
94
+ exports . onPieChartLoaded = function ( args )
95
+ {
96
+ const chart = args . object ;
97
+
98
+ chart . drawFameRate = true ;
99
+ chart . setLogEnabled ( true ) ;
100
+ chart . setHighlightPerTapEnabled ( true ) ;
101
+ //chart.setHoleRadius(10);
102
+ //chart.setDrawHoleEnabled(false);
103
+ // chart.setHardwareAccelerationEnabled(true);
104
+
105
+ const data = new Array ( 5 ) . fill ( 0 ) . map ( function ( v , i )
106
+ {
107
+ return { label : i + "" , value : Math . random ( ) * 100 } ;
108
+ } ) ;
109
+
110
+ console . log ( 'setData' , data . length , data [ 0 ] ) ;
111
+ const sets = [ ] ;
112
+ const set = new pds . PieDataSet ( data , 'value' , 'value' ) ;
113
+ set . setColors ( [ getRandomColor ( ) , getRandomColor ( ) ] ) ;
114
+ set . setDrawValues ( true ) ;
115
+ sets . push ( set ) ;
116
+
117
+ // create a data object with the data sets
118
+ const piedata = new pd . PieData ( sets ) ;
119
+
120
+ // set data
121
+ chart . setData ( piedata ) ;
122
+ } ;
123
+
92
124
exports . redraw = function ( args )
93
125
{
94
126
const page = args . object . page ;
@@ -110,6 +142,12 @@ exports.redraw = function(args)
110
142
{
111
143
lc . invalidate ( ) ;
112
144
}
145
+
146
+ const pc = page . getViewById ( "pie-chart" ) ;
147
+ if ( pc )
148
+ {
149
+ pc . invalidate ( ) ;
150
+ }
113
151
} ;
114
152
115
153
exports . onNavigationButtonTap = function ( args )
0 commit comments