`

Google Chart -- corechart packages离线版使用方法

 
阅读更多
https://github.com/sunlittlebill/knowledge/tree/master/google-chart
需要使用两个文件:api.js 和 tooltip.css

api.js
下载到本地后把"GoogleApisBase"换成你的域名(域名结尾不要"/"),默认把"tooltip.css"放在"/static/modules/gviz/1.0/core/"路径下面。

tooltip.css
默认把css文件放在/static/modules/gviz/1.0/core/下面。

这样,在页面中只要引用api.js 就可以离线状态下使用Google Charts的corechart packages工具了。

Demo http://blog.littlebill.me/2013/04/google-corechart-package-introduced.html?utm_source=googlechart-git&utm_medium=readme


<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!--Load the AJAX API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
 
      // Load the Visualization API and the piechart package.
      google.load('visualization', '1.0', {'packages':['corechart']});
 
      // Set a callback to run when the Google Visualization API is loaded.
      google.setOnLoadCallback(drawChart);
 
      // Callback that creates and populates a data table,
      // instantiates the pie chart, passes in the data and
      // draws it.
      function drawChart() {
 
        // Create the data table.
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Topping');
        data.addColumn('number', 'Slices');
        data.addRows([
          ['Mushrooms', 3],
          ['Onions', 1],
          ['Olives', 1],
          ['Zucchini', 1],
          ['Pepperoni', 2]
        ]);
        // Set chart options
        var options = {
          'title':'How Much Pizza I Ate Last Night - 饼图 3D',
          'is3D':true,
          'width':500,
          'height':300
        };
        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.PieChart(document.getElementById('chart_div01'));
        chart.draw(data, options);
 
        data = google.visualization.arrayToDataTable([
          ['Age', 'Weight'],
          [ 8,      12],
          [ 4,      5.5],
          [ 11,     14],
          [ 4,      5],
          [ 3,      3.5],
          [ 6.5,    7]
        ]);
        options = {
          title: 'Age vs. Weight comparison - 散点图',
          hAxis: {title: 'Age', minValue: 0, maxValue: 15},
          vAxis: {title: 'Weight', minValue: 0, maxValue: 15},
          legend: 'none'
        };
        chart = new google.visualization.ScatterChart(document.getElementById('chart_div02'));
        chart.draw(data, options);
 
        // Some raw data (not necessarily accurate)
        data = google.visualization.arrayToDataTable([
          ['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 'Rwanda', 'Average'],
          ['2004/05',  165,      938,         522,             998,           450,      614.6],
          ['2005/06',  135,      1120,        599,             1268,          288,      682],
          ['2006/07',  157,      1167,        587,             807,           397,      623],
          ['2007/08',  139,      1110,        615,             968,           215,      609.4],
          ['2008/09',  136,      691,         629,             1026,          366,      569.6]
        ]);
        options = {
          title : 'Monthly Coffee Production by Country - 组合图',
          vAxis: {title: "Cups"},
          hAxis: {title: "Month"},
          seriesType: "bars",
          series: {5: {type: "line"}}
        };
        chart = new google.visualization.ComboChart(document.getElementById('chart_div03'));
        chart.draw(data, options);
 
        data = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2004',  1000,      400],
          ['2005',  1170,      460],
          ['2006',  660,       1120],
          ['2007',  1030,      540]
        ]);
        options = {
          title: 'Company Performance - 折线图'
        };
        chart = new google.visualization.LineChart(document.getElementById('chart_div04'));
        chart.draw(data, options);
 
        data = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2004',  1000,      400],
          ['2005',  1170,      460],
          ['2006',  660,       1120],
          ['2007',  1030,      540]
        ]);
        options = {
          title: 'Company Performance - 条图',
          vAxis: {title: 'Year',  titleTextStyle: {color: 'red'}}
        };
        chart = new google.visualization.BarChart(document.getElementById('chart_div05'));
        chart.draw(data, options);
 
        data = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2004',  1000,      400],
          ['2005',  1170,      460],
          ['2006',  660,       1120],
          ['2007',  1030,      540]
        ]);
        options = {
          title: 'Company Performance - 柱状图',
          hAxis: {title: 'Year',titleTextStyle: {color: 'red'}}
        };
        chart = new google.visualization.ColumnChart(document.getElementById('chart_div06'));
        chart.draw(data, options);
 
        data = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2004',  1000,      400],
          ['2005',  1170,      460],
          ['2006',  660,       1120],
          ['2007',  1030,      540]
        ]);
        options = {
          title: 'Company Performance - 面积图',
          hAxis: {title: 'Year',  titleTextStyle: {color: 'red'}}
        };
        chart = new google.visualization.AreaChart(document.getElementById('chart_div07'));
        chart.draw(data, options);
 
        data = google.visualization.arrayToDataTable([
          ['Mon', 20, 28, 38, 45],
          ['Tue', 31, 38, 55, 66],
          ['Wed', 50, 55, 77, 80],
          ['Thu', 77, 77, 66, 50],
          ['Fri', 68, 66, 22, 15]
          // Treat first row as data as well.
        ], true);
        options = {
          title: '蜡烛图',
          legend:'none'
        };
        chart = new google.visualization.CandlestickChart(document.getElementById('chart_div08'));
        chart.draw(data, options);
      }
    </script>
  </head>
 
  <body>
    <table>
      <tr>
        <td>
          <div id="chart_div01"></div>
        </td>
        <td>
          <div id="chart_div02"></div>
        </td>
      </tr>
      <tr>
        <td>
          <div id="chart_div03"></div>
        </td>
        <td>
          <div id="chart_div04"></div>
        </td>
        <td>
          <div id="chart_div05"></div>
        </td>
      </tr>
      <tr>
        <td>
          <div id="chart_div06"></div>
        </td>
        <td>
          <div id="chart_div07"></div>
        </td>
        <td>
          <div id="chart_div08"></div>
        </td>
      </tr>
    </table>
  </body>
</html>
分享到:
评论

相关推荐

    LibreTranslate之argos-translate-packages离线包

    LibreTranslate依赖的argos-translate-packages离线包资源,做了相应的调整,支持离线访问调用。记得需要修改settings.py文件。

    LibreTranslate之argos-translate-packages离线包-附加包

    LibreTranslate依赖的argos-translate-packages离线包资源,做了相应的调整,支持离线访问调用。记得需要修改settings.py文件。

    mingw-get-inst-20120426-离线安装

    2.如果在线安装失败:将packages.rar解压,然后将得到的packages文件夹中所有内容复制到“MinGW安装路径\var\cache\mingw-get\packages”目录下。再重新运行mingw-get-inst-20120426.exe安装即可。

    TA-Lib-0.4.17-cp37-cp37m-win-amd64离线包

    安装这个离线包通常涉及解压后将库文件移动到Python的site-packages目录下,或者使用pip的install选项指定本地文件路径进行安装。对于Python开发者来说,熟悉如何管理Python环境和安装第三方库是至关重要的,特别是...

    centos7 离线安装gcc pcre-devel openssl-devel zlib-devel

    1.离线安装gcc pcre-devel openssl-devel zlib-devel 下载路径 http://mirrors.163.com/centos/7.4.1708/os/x86_64/Packages/ autogen-libopts-5.18-5.el7.x86_64.rpm cpp-4.8.5-16.el7.x86_64.rpm gcc-4.8.5-16....

    rknn-toolkit-v1.7.3-packages

    "rknn-toolkit-v1.7.3-packages" 是Rockchip公司推出的RKNN(Rockchip Neural Network)工具包的一个版本,主要用于AI模型的部署和优化。RKNN是针对嵌入式设备,特别是Rockchip处理器设计的深度学习推理框架,旨在...

    RedHat 6.5离线安装openssl-devel顺序

    在本例中,文件名为`openssl-devel-packages`,这意味着它可能是一个包含多个版本或不同架构的RPM包的压缩文件。你需要解压这个文件,然后找到与你的系统架构(例如,x86_64)匹配的RPM包。 2. **准备安装环境**:...

    Centos7 离线perl-CPAN rpm包

    在IT行业中,Linux系统是广泛应用于服务器环境的操作系统,尤其是对于内网服务器,由于网络访问限制,离线安装软件包成为必要。本话题主要聚焦于如何在CentOS 7系统中离线安装Perl相关的CPAN模块,这在升级或维护...

    SLE-15-SP1-Packages-x86_64-GM-DVD1.iso

    SLE-15-SP1-Packages-x86_64-GM-DVD1.iso SUSE 15 SP1 for SAP 百度下载地址:SLE-15-SP1-Packages-x86_64-GM-DVD1.iso.txt

    MinGW全部离线包

    使用MinGW进行开发时,开发者可以在Windows环境下编写源代码,然后使用MinGW提供的编译器和链接器将源代码编译成可执行程序。由于MinGW生成的是原生的Windows程序,因此不需要依赖任何额外的环境,这使得它成为...

    SLE-15-SP1-Packages-x86_64-GM-DVD2.iso

    SLE-15-SP1-Packages-x86_64-GM-DVD2.iso SUSE 15 SP1 for SAP 百度下载地址:SLE-15-SP1-Packages-x86_64-GM-DVD2.iso.txt

    docker&amp;docker-compose离线安装包(centos)

    一、安装离线 dokcer20.10.17 1、上传离线包 # rz docker_packages.tar.gz 2、解压离线包 # tar -zxf docker_packages.tar.gz 3、安装 docker # yum -y install ./*.rpm 4、启动 docker # systemctl start docker # ...

    AnderWeb-android-packages-apps-Launcher-4458ee4

    android studio期末作业AnderWeb-android_packages_apps_Launcher-4458ee4AnderWeb-android_packages_apps_Launcher-4458ee4AnderWeb-android_packages_apps_Launcher-4458ee4AnderWeb-android_packages_apps_...

    openssl-devel-1.0.1e-57.el6.x86_64-packages.zip

    openssl-devel-1.0.1e-57.el6.x86_64.rpm离线安装时的相关依赖库: openssl-devel-packages\e2fsprogs-1.41.12-22.el6.x86_64.rpm openssl-devel-packages\e2fsprogs-libs-1.41.12-22.el6.x86_64.rpm openssl-...

    windows和linux下python opencv安装(含离线安装)

    本篇将详细介绍在Windows和Linux环境下如何安装Python OpenCV,包括使用pip以及离线安装的方法。 ### Windows上的Python OpenCV安装 #### 1. 使用pip 首先,确保你的系统已经安装了Python和pip。在命令提示符或...

    rpms-chrony-pcs-packages.rpm.rar

    bclinux8.2上使用的pcs的安装包,centos8.2...不要单独下载,先看这篇博客使用说明,确定是你要的东西在下载:Pacemaker详解、pcs命令详解和参数说明、centos8或bclinux8.2离线安装pcs以及搭建pcs、pcs的使用说明【2】 ...

    Centos7-x86架构下离线安装docker与docker-compose的教程和资源

    大家也可以自己在有网络的机子下载rpm包(yum install --downloadonly --downloaddir=/data/packages docker-ce) 版本信息: Docker version 20.10.7, build f0df350; docker-compose version 1.18.0, build 8dd22a9...

    Python 2.7,离线安装合集tornado,backports_abc,certifi,ordereddict,six

    Python 2.7,离线安装 合集 tornado-4.4.2,python2-backports_abc-0.5-2,python-backports-ssl_match_hostname-3.5.0.1-1,python2-certifi-2016.9.26-2,future-0.15.1.tar.gz,future-0.17.1.tar.gz,python-...

    AnderWeb-android-packages-apps-Launcher-4458ee4.zip

    AnderWeb-android_packages_apps_Launcher-4458ee4.zip AnderWeb-android_packages_apps_Launcher-4458ee4.zip AnderWeb-android_packages_apps_Launcher-4458ee4.zip AnderWeb-android_packages_apps_Launcher-4458...

    docker-ce19.03.8-afacb8b-packages.rar

    附件是Docker-ce19.3.8离线安装包和安装教程,欢迎下载使用.主要解决离线环境下docker-ce的安装问题.也是我多方总结的成果.安装步骤分为两步如下: 1.给install.sh文件最大权限. chmod 777 install.sh 2.在install.sh...

Global site tag (gtag.js) - Google Analytics