Вход Регистрация
Файл: wapxl.ru/top/amcharts/plugins/export/examples/export.config.advanced.js
Строк: 204
<?php
/**
 * This is a sample chart export config file. It is provided as a reference on
 * how miscelaneous items in export menu can be used and set up.
 *
 * Please refer to README.md for more information.
 */

/**
 * PDF-specfic configuration
 */
AmCharts.exportDrawingMenu = [ {
  class: 
"export-drawing",
  
label"Export",
  
menu: [ {
    
label"Undo",
    
click: function() {
      
this.drawing.undo();
    }
  }, {
    
label"Redo",
    
click: function() {
      
this.drawing.redo();
    }
  }, {
    
label"Cancel",
    
click: function() {
      
this.drawing.done();
    }
  }, {
    
label"Save",
    
menu: [ {
      
label"JPG",
      
click: function() {
        
this.drawing.done();
        
this.toJPG( {}, function( data ) {
          
this.downloaddata"image/jpg""amCharts.jpg" );
        } );
      }
    }, {
      
label"PNG",
      
click: function() {
        
this.drawing.done();
        
this.toPNG( {}, function( data ) {
          
this.downloaddata"image/png""amCharts.png" );
        } );
      }
    }, {
      
label"PDF",
      
click: function() {
        
this.drawing.done();
        
this.toPDF( {}, function( data ) {
          
this.downloaddata"application/pdf""amCharts.pdf" );
        } );
      }
    }, {
      
label"SVG",
      
click: function() {
        
this.drawing.done();
        
this.toSVG( {}, function( data ) {
          
this.downloaddata"text/xml""amCharts.svg" );
        } );
      }
    } ]
  } ]
} ];


/**
 * Define main universal config
 */
AmCharts.exportCFG = {
  
enabledtrue,
  
libs: {
    
path"../libs/"
  
},
  
menu: [ {
    class: 
"export-main",
    
label"Export",
    
menu: [
      
/*
       ** DRAWING
       */
      
{
        
label"Draw",
        
click: function() {
          
this.capture( {
            
action"draw",
            
freeDrawingBrush: {
              
width2,
              
color"#000000",
              
shadow: {
                
color"rgba(0,0,0,0.3)",
                
blur10,
                
offsetX3,
                
offsetY3
              
}
            }
          }, function() {
            
this.createMenuAmCharts.exportDrawingMenu );
          } );
        }
      },

      
/*
       ** DELAYED EXPORT
       */
      
{
        
label"Delayed",
        
click: function() {
          var 
_this this;
          var 
delay 2;
          var 
timer 0;
          var 
starttime Number( new Date() );
          var 
menu this.createMenu( [ {
            
label"Capturing: " delay,
            
click: function() {
              
clearTimeouttimer );
              
this.createMenuthis.defaults.menu );
            }
          } ] );
          var 
label menu.getElementsByTagName"span" )[ ];

          
timer setInterval( function() {
            
diff = ( delay - ( Number( new Date() ) - starttime ) / 1000 );
            
label.innerHTML "Capturing: " + ( diff diff ).toFixed);

            if ( 
diff <= ) {
              
clearTimeouttimer );
              
_this.capture( {}, function() {
                
this.toJPG( {}, function( data ) {
                  
this.downloaddata"image/jpg""amCharts.jpg" );
                } );
                
this.createMenuthis.defaults.menu );
              } );
            }
          }, 
10 );
        }
      },

      
/*
       ** DELAYED EXPORT WITH DRAWING
       */
      
{
        
label"Delayed Draw",
        
click: function() {
          var 
_this this;
          var 
delay 2;
          var 
timer 0;
          var 
starttime Number( new Date() );
          var 
menu this.createMenu( [ {
            
label"Capturing: " delay,
            
click: function() {
              
clearTimeouttimer );
              
this.createMenuthis.defaults.menu );
            }
          } ] );
          var 
label menu.getElementsByTagName"span" )[ ];

          
timer setInterval( function() {
            var 
diff = ( delay - ( Number( new Date() ) - starttime ) / 1000 );
            
label.innerHTML "Capturing: " + ( diff diff ).toFixed);

            if ( 
diff <= ) {
              
clearTimeouttimer );
              
_this.capture( {
                
action"draw"
              
}, function() {
                
_this.createMenuAmCharts.exportDrawingMenu );
              } );
            }
          }, 
10 );
        }
      },

      
/*
       ** DOWNLOAD
       */
      
{
        
label"Download",
        
menu: [ {
          
label"JPG",
          
click: function() {
            
this.capture( {}, function() {
              
this.toJPG( {}, function( data ) {
                
this.downloaddata"image/jpg""amCharts.jpg" );
              } );
            } );
          }
        }, {
          
label"PNG",
          
click: function() {
            
this.capture( {}, function() {
              
this.toPNG( {}, function( data ) {
                
this.downloaddata"image/png""amCharts.png" );
              } );
            } );
          }
        }, {
          
label"PDF",
          
click: function() {
            
this.capture( {}, function() {
              
this.toPDF( {}, function( data ) {
                
this.downloaddata"application/pdf""amCharts.pdf" );
              } );
            } );
          }
        }, {
          
label"PDF + data",
          
click: function() {
            
this.capture( {}, function() {
              var 
tableData this.setup.chart.dataProvider;
              var 
tableBody this.toArray( {
                
withHeadertrue,
                
datatableData
              
} );

              var 
tableWidths = [];
              var 
content = [ {
                
image"reference",
                
fit: [ 523.28769.89 ]
              } ];

              for ( 
i in tableBody] ) {
                
tableWidths.push"*" );
              }

              
content.push( {
                
table: {
                  
headerRows1,
                  
widthstableWidths,
                  
bodytableBody
                
},
                
layout'lightHorizontalLines'
              
} );

              
this.toPDF( {
                
contentcontent
              
}, function( data ) {
                
this.downloaddata"application/pdf""amCharts.pdf" );
              } );
            } );
          }
        }, {
          
label"SVG",
          
click: function() {
            
this.capture( {}, function() {
              
this.toSVG( {}, function( data ) {
                
this.downloaddata"text/xml""amCharts.svg" );
              } );
            } );
          }
        }, {
          
label"CSV",
          
click: function() {
            
this.toCSV( {}, function( data ) {
              
this.downloaddata"text/plain""amCharts.csv" );
            } );
          }
        }, {
          
label"JSON",
          
click: function() {
            
this.toJSON( {}, function( data ) {
              
this.downloaddata"text/plain""amCharts.json" );
            } );
          }
        }, {
          
label"XLSX",
          
click: function() {
            
this.toXLSX( {}, function( data ) {
              
this.downloaddata"application/octet-stream""amCharts.xlsx" );
            } );
          }
        } ]
      }
    ]
  } ]
};
?>
Онлайн: 2
Реклама