D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
jnclnmuac
/
public_html
/
web
/
admin
/
global_assets
/
js
/
demo_pages
/
charts
/
google
/
bars
/
Filename :
bar.js
back
Copy
/* ------------------------------------------------------------------------------ * * # Google Visualization - bars * * Google Visualization bar chart demonstration * * ---------------------------------------------------------------------------- */ // Setup module // ------------------------------ var GoogleBarBasic = function() { // // Setup module components // // Bar chart var _googleBarBasic = function() { if (typeof google == 'undefined') { console.warn('Warning - Google Charts library is not loaded.'); return; } // Initialize chart google.charts.load('current', { callback: function () { // Draw chart drawBar(); // Resize on sidebar width change $(document).on('click', '.sidebar-control', drawBar); // Resize on window resize var resizeBarBasic; $(window).on('resize', function() { clearTimeout(resizeBarBasic); resizeBarBasic = setTimeout(function () { drawBar(); }, 200); }); }, packages: ['corechart'] }); // Chart settings function drawBar() { // Define charts element var bar_chart_element = document.getElementById('google-bar'); // Data var data = google.visualization.arrayToDataTable([ ['Year', 'Sales', 'Expenses'], ['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540] ]); // Options var options_bar = { fontName: 'Roboto', height: 400, fontSize: 12, chartArea: { left: '5%', width: '94%', height: 350 }, tooltip: { textStyle: { fontName: 'Roboto', fontSize: 13 } }, vAxis: { gridlines:{ color: '#e5e5e5', count: 10 }, minValue: 0 }, legend: { position: 'top', alignment: 'center', textStyle: { fontSize: 12 } } }; // Draw chart var bar = new google.visualization.BarChart(bar_chart_element); bar.draw(data, options_bar); } }; // // Return objects assigned to module // return { init: function() { _googleBarBasic(); } } }(); // Initialize module // ------------------------------ GoogleBarBasic.init();