@@ -967,6 +967,17 @@ Graph3d.prototype.redraw = function() {
967
967
this . _redrawLegend ( ) ;
968
968
} ;
969
969
970
+
971
+ /**
972
+ * Get drawing context without exposing canvas
973
+ */
974
+ Graph3d . prototype . _getContext = function ( ) {
975
+ var canvas = this . frame . canvas ;
976
+ var ctx = canvas . getContext ( '2d' ) ;
977
+ return ctx ;
978
+ } ;
979
+
980
+
970
981
/**
971
982
* Clear the canvas before redrawing
972
983
*/
@@ -1024,8 +1035,7 @@ Graph3d.prototype._redrawLegend = function() {
1024
1035
var left = right - width ;
1025
1036
var bottom = top + height ;
1026
1037
1027
- var canvas = this . frame . canvas ;
1028
- var ctx = canvas . getContext ( '2d' ) ;
1038
+ var ctx = this . _getContext ( ) ;
1029
1039
ctx . lineWidth = 1 ;
1030
1040
ctx . font = '14px arial' ; // TODO: put in options
1031
1041
@@ -1157,8 +1167,7 @@ Graph3d.prototype._redrawSlider = function() {
1157
1167
*/
1158
1168
Graph3d . prototype . _redrawInfo = function ( ) {
1159
1169
if ( this . dataFilter ) {
1160
- var canvas = this . frame . canvas ;
1161
- var ctx = canvas . getContext ( '2d' ) ;
1170
+ var ctx = this . _getContext ( ) ;
1162
1171
1163
1172
ctx . font = '14px arial' ; // TODO: put in options
1164
1173
ctx . lineStyle = 'gray' ;
@@ -1177,8 +1186,7 @@ Graph3d.prototype._redrawInfo = function() {
1177
1186
* Redraw the axis
1178
1187
*/
1179
1188
Graph3d . prototype . _redrawAxis = function ( ) {
1180
- var canvas = this . frame . canvas ,
1181
- ctx = canvas . getContext ( '2d' ) ,
1189
+ var ctx = this . _getContext ( ) ,
1182
1190
from , to , step , prettyStep ,
1183
1191
text , xText , yText , zText ,
1184
1192
offset , xOffset , yOffset ,
@@ -1477,8 +1485,7 @@ Graph3d.prototype._hsv2rgb = function(H, S, V) {
1477
1485
* This function can be used when the style is 'grid'
1478
1486
*/
1479
1487
Graph3d . prototype . _redrawDataGrid = function ( ) {
1480
- var canvas = this . frame . canvas ,
1481
- ctx = canvas . getContext ( '2d' ) ,
1488
+ var ctx = this . _getContext ( ) ,
1482
1489
point , right , top , cross ,
1483
1490
i ,
1484
1491
topSideVisible , fillStyle , strokeStyle , lineWidth ,
@@ -1624,8 +1631,7 @@ Graph3d.prototype._getStrokeWidth = function(point) {
1624
1631
* This function can be used when the style is 'dot' or 'dot-line'
1625
1632
*/
1626
1633
Graph3d . prototype . _redrawDataDot = function ( ) {
1627
- var canvas = this . frame . canvas ;
1628
- var ctx = canvas . getContext ( '2d' ) ;
1634
+ var ctx = this . _getContext ( ) ;
1629
1635
var i ;
1630
1636
1631
1637
if ( this . dataPoints === undefined || this . dataPoints . length <= 0 )
@@ -1720,8 +1726,7 @@ Graph3d.prototype._redrawDataDot = function() {
1720
1726
* This function can be used when the style is 'bar', 'bar-color', or 'bar-size'
1721
1727
*/
1722
1728
Graph3d . prototype . _redrawDataBar = function ( ) {
1723
- var canvas = this . frame . canvas ;
1724
- var ctx = canvas . getContext ( '2d' ) ;
1729
+ var ctx = this . _getContext ( ) ;
1725
1730
var i , j , surface , corners ;
1726
1731
1727
1732
if ( this . dataPoints === undefined || this . dataPoints . length <= 0 )
@@ -1862,8 +1867,7 @@ Graph3d.prototype._redrawDataBar = function() {
1862
1867
* This function can be used when the style is 'line'
1863
1868
*/
1864
1869
Graph3d . prototype . _redrawDataLine = function ( ) {
1865
- var canvas = this . frame . canvas ,
1866
- ctx = canvas . getContext ( '2d' ) ,
1870
+ var ctx = this . _getContext ( ) ,
1867
1871
point , i ;
1868
1872
1869
1873
if ( this . dataPoints === undefined || this . dataPoints . length <= 0 )
0 commit comments