@@ -91,76 +91,85 @@ define([
9191
9292 _createChart : function ( data ) {
9393 logger . debug ( this . id + "._createChart" ) ;
94- this . _chart = new this . _chartJS ( this . _ctx , {
95- type : "pie" ,
96- data : this . _createDataSets ( data ) ,
97- options : {
98- title : {
99- display : ( this . chartTitle !== "" ) ? true : false ,
100- text : ( this . chartTitle !== "" ) ? this . chartTitle : "" ,
101- fontFamily : this . _font ,
102- fontSize : this . titleSize
103- } ,
104-
105- responsive : this . responsive ,
106- responsiveAnimationDuration : ( this . responsiveAnimationDuration > 0 ? this . responsiveAnimationDuration : 0 ) ,
107- tooltips : {
108- enabled : this . showTooltips
109- } ,
110- legend : {
111- display : this . showLegend ,
112- labels : { fontFamily : this . _font }
113- } ,
114-
115- //Boolean - Whether we should show a stroke on each segment
116- segmentShowStroke : this . segmentShowStroke ,
117-
118- //String - The colour of each segment stroke
119- segmentStrokeColor : this . segmentStrokeColor ,
120-
121- //Number - The width of each segment stroke
122- segmentStrokeWidth : this . segmentStrokeWidth ,
123-
124- //Number - Amount of animation steps
125- animationSteps : this . animationSteps ,
126-
127- //String - Animation easing effect
128- animationEasing : this . animationEasing ,
129-
130- //Boolean - Whether we animate the rotation of the Doughnut
131- animateRotate : this . animateRotate ,
132-
133- //Boolean - Whether we animate scaling the Doughnut from the centre
134- animateScale : this . animateScale ,
135-
136- legendCallback : this . _legendAlternateCallback ,
137-
138- // Show tooltips at all
139- showTooltips : this . showTooltips ,
140-
141- // maintainAspectRatio
142- maintainAspectRatio : this . maintainAspectRatio ,
143-
94+ if ( this . _chart ) {
95+ var set = this . _createDataSets ( data ) ;
96+ this . _chart . stop ( ) ;
97+ this . _chart . data . datasets = set . datasets ;
98+ this . _chart . data . labels = set . labels ;
99+ this . _chart . update ( 1000 ) ;
100+ this . _chart . bindEvents ( ) ; // tooltips otherwise won't work
101+ } else {
102+ var chartOptions = {
103+ type : "pie" ,
104+ data : this . _createDataSets ( data ) ,
105+ options : {
106+ title : {
107+ display : ( this . chartTitle !== "" ) ? true : false ,
108+ text : ( this . chartTitle !== "" ) ? this . chartTitle : "" ,
109+ fontFamily : this . _font ,
110+ fontSize : this . titleSize
111+ } ,
112+
113+ responsive : this . responsive ,
114+ responsiveAnimationDuration : ( this . responsiveAnimationDuration > 0 ? this . responsiveAnimationDuration : 0 ) ,
115+ tooltips : {
116+ enabled : this . showTooltips
117+ } ,
118+ legend : {
119+ display : this . showLegend ,
120+ labels : { fontFamily : this . _font }
121+ } ,
122+
123+ //Boolean - Whether we should show a stroke on each segment
124+ segmentShowStroke : this . segmentShowStroke ,
125+
126+ //String - The colour of each segment stroke
127+ segmentStrokeColor : this . segmentStrokeColor ,
128+
129+ //Number - The width of each segment stroke
130+ segmentStrokeWidth : this . segmentStrokeWidth ,
131+
132+ //Number - Amount of animation steps
133+ animationSteps : this . animationSteps ,
134+
135+ //String - Animation easing effect
136+ animationEasing : this . animationEasing ,
137+
138+ //Boolean - Whether we animate the rotation of the Doughnut
139+ animateRotate : this . animateRotate ,
140+
141+ //Boolean - Whether we animate scaling the Doughnut from the centre
142+ animateScale : this . animateScale ,
143+
144+ legendCallback : this . _legendAlternateCallback ,
145+
146+ // Show tooltips at all
147+ showTooltips : this . showTooltips ,
148+
149+ // maintainAspectRatio
150+ maintainAspectRatio : this . maintainAspectRatio ,
151+
152+
153+ //cutOut of pie
154+ cutoutPercentage : 0 , //always zero for Pie chart
155+
156+ // Custom tooltip?
157+ customTooltips : false //lang.hitch(this, this.customTooltip)
158+
159+ }
160+ } ;
161+ this . _chart = new this . _chartJS ( this . _ctx , chartOptions ) ;
144162
145- //cutOut of pie
146- cutoutPercentage : 0 , //always zero for Pie chart
163+ // Set the con
164+ html . set ( this . _numberNode , this . _data . object . get ( this . numberInside ) ) ;
147165
148- // Custom tooltip?
149- customTooltips : false //lang.hitch( this, this.customTooltip)
166+ // Add class to determain chart type
167+ this . _addChartClass ( "chartjs-pie-chart" ) ;
150168
169+ if ( this . onclickmf ) {
170+ on ( this . _chart . chart . canvas , "click" , lang . hitch ( this , this . _onClickChart ) ) ;
151171 }
152- } ) ;
153-
154- // Set the con
155- html . set ( this . _numberNode , this . _data . object . get ( this . numberInside ) ) ;
156-
157- // Add class to determain chart type
158- this . _addChartClass ( "chartjs-pie-chart" ) ;
159-
160- if ( this . onclickmf ) {
161- on ( this . _chart . chart . canvas , "click" , lang . hitch ( this , this . _onClickChart ) ) ;
162172 }
163-
164173 }
165174 } ) ;
166175} ) ;
0 commit comments