File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 66 < link rel ="stylesheet " href ="https://fonts.googleapis.com/css?family=Indie+Flower ">
77 < script src ="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js "> </ script >
88 < script src ="https://cdnjs.cloudflare.com/ajax/libs/rough.js/3.0.0/rough.js "> </ script >
9- < script src ="../dist/chartjs-plugin-rough.min. js "> </ script >
9+ < script src ="../dist/chartjs-plugin-rough.js "> </ script >
1010 < style >
1111 canvas {
1212 -moz-user-select : none;
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ import Chart from 'chart.js';
44
55var helpers = Chart . helpers ;
66
7+ // For Chart.js 2.7.1 backward compatibility
8+ Chart . layouts = Chart . layouts || Chart . layoutService ;
9+
710// For Chart.js 2.7.3 backward compatibility
811helpers . canvas = helpers . canvas || { } ;
912helpers . canvas . _isPointInArea = helpers . canvas . _isPointInArea || function ( point , area ) {
Original file line number Diff line number Diff line change @@ -44,8 +44,10 @@ var descriptors = plugins.descriptors;
4444plugins . descriptors = function ( chart ) {
4545 var rough = chart . _rough ;
4646
47+ // Replace filler/legend plugins with rough filler/legend plugins
4748 if ( rough ) {
48- var cache = chart . $plugins || ( chart . $plugins = { } ) ;
49+ // chart._plugins for Chart.js 2.7.1 backward compatibility
50+ var cache = chart . $plugins || chart . _plugins || ( chart . $plugins = chart . _plugins = { } ) ;
4951 if ( cache . id === this . _cacheId ) {
5052 return cache . descriptors ;
5153 }
@@ -81,16 +83,24 @@ export default {
8183 chart . buildOrUpdateControllers = function ( ) {
8284 var result ;
8385
86+ // Replace controllers with rough controllers on creation
8487 Chart . controllers = roughControllers ;
8588 result = Chart . prototype . buildOrUpdateControllers . apply ( this , arguments ) ;
8689 Chart . controllers = controllers ;
8790
8891 return result ;
8992 } ;
9093
94+ // Remove the existing legend if exists
9195 if ( chart . legend ) {
9296 Chart . layouts . removeBox ( chart , chart . legend ) ;
9397 delete chart . legend ;
9498 }
99+
100+ // Invalidate plugin cache and create new one
101+ delete chart . $plugins ;
102+ // For Chart.js 2.7.1 backward compatibility
103+ delete chart . _plugins ;
104+ plugins . descriptors ( chart ) ;
95105 }
96106} ;
You can’t perform that action at this time.
0 commit comments