圆饼示例:

<html>
<head>
<!--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', 3],
['Pepperoni', 2]
]); // Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
'width':800,
'height':600}; // Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head> <body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>

运行效果:

annotation-charts

<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['annotationchart']}]}"></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages':['annotationchart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'test1');
data.addColumn('string', 'test2');
data.addColumn('string', 'test3');
data.addColumn('number', 'test4');
data.addColumn('string', 'test5');
data.addColumn('string', 'test6');
data.addRows([
[new Date(2014, 2, 15), 12400, undefined, undefined,
10645, undefined, undefined],
[new Date(2114, 2, 16), 24045, 'hello1', 'hello2',
12374, undefined, undefined],
[new Date(2314, 2, 17), 35022, 'hello3', 'hello4',
15766, 'hello5', 'hell06'],
[new Date(2314, 2, 18), 12284, 'hello7', 'hello8',
34334, 'hello9', 'hello10'],
[new Date(2314, 2, 19), 8476, 'hello11', 'hello12',
66467, 'hello13', 'hello14'],
[new Date(2314, 2, 20), 0, 'hello15', 'hello16',
79463, 'hello17', 'hello18']
]); var chart = new google.visualization.AnnotationChart(document.getElementById('chart_div')); var options = {
displayAnnotations: true
}; chart.draw(data, options);
}
</script>
</head> <body>
<div id='chart_div' style='width: 900px; height: 500px;'></div>
</body>
</html>

效果图:

area-charts:

<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2013', 1000, 400],
['2014', 1170, 460],
['2015', 660, 1120],
['2016', 1030, 540]
]); var options = {
title: 'Company Performance',
hAxis: {title: 'Year', titleTextStyle: {color: '#333'}},
vAxis: {minValue: 0}
}; var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>

效果图:

bar-charts:

<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1.1", {packages:["bar"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses', 'Profit'],
['2014', 1000, 400, 200],
['2015', 1170, 460, 250],
['2016', 660, 1120, 300],
['2017', 1030, 540, 350]
]); var options = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017',
},
bars: 'horizontal' // Required for Material Bar Charts.
}; var chart = new google.charts.Bar(document.getElementById('barchart_material')); chart.draw(data, options);
}
</script>
</head>
<body>
<div id="barchart_material" style="width: 900px; height: 500px;"></div>
</body>
</html>

效果图:

bubble-charts:

<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['ID', 'X', 'Y', 'Temperature'],
['', 80, 167, 120],
['', 79, 136, 130],
['', 78, 184, 50],
['', 72, 278, 230],
['', 81, 200, 210],
['', 72, 170, 100],
['', 68, 477, 80]
]); var options = {
colorAxis: {colors: ['yellow', 'red']}
}; var chart = new google.visualization.BubbleChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>

效果图:

calendar-charts:

<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1.1", {packages:["calendar"]});
google.setOnLoadCallback(drawChart); function drawChart() {
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'date', id: 'Date' });
dataTable.addColumn({ type: 'number', id: 'Won/Loss' });
dataTable.addRows([
[ new Date(2012, 3, 13), 37032 ],
[ new Date(2012, 3, 14), 38024 ],
[ new Date(2012, 3, 15), 38024 ],
[ new Date(2012, 3, 16), 38108 ],
[ new Date(2012, 3, 17), 38229 ],
// Many rows omitted for brevity.
[ new Date(2013, 9, 4), 38177 ],
[ new Date(2013, 9, 5), 38705 ],
[ new Date(2013, 9, 12), 38210 ],
[ new Date(2013, 9, 13), 38029 ],
[ new Date(2013, 9, 19), 38823 ],
[ new Date(2013, 9, 23), 38345 ],
[ new Date(2013, 9, 24), 38436 ],
[ new Date(2013, 9, 30), 38447 ]
]); var chart = new google.visualization.Calendar(document.getElementById('calendar_basic')); var options = {
title: "Red Sox Attendance",
height: 350,
}; chart.draw(dataTable, options);
}
</script>
</head>
<body>
<div id="calendar_basic" style="width: 1000px; height: 350px;"></div>
</body>
</html>

效果图:

candlestick-charts:

<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var 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); var options = {
legend:'none'
}; var chart = new google.visualization.CandlestickChart(document.getElementById('chart_div')); chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>

效果图:

column-charts:

<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1.1", {packages:["bar"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses', 'Profit'],
['2014', 1000, 400, 200],
['2015', 1170, 460, 250],
['2016', 660, 1120, 300],
['2017', 1030, 540, 350]
]); var options = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017',
}
}; var chart = new google.charts.Bar(document.getElementById('columnchart_material')); chart.draw(data, options);
}
</script>
</head>
<body>
<div id="columnchart_material" style="width: 900px; height: 500px;"></div>
</body>
</html>

效果图:

Google Chart API学习(一)的更多相关文章

  1. 使用Google Chart API绘制组合图

    Google Chart API 绘图 组合图作者:方倍工作室 地址: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN& ...

  2. Google Chart API 参考 中文版

    Google Chart API 参考 中文版 文档信息 翻译: Cloudream ,最后修改:02/22/2008 06:11:08 英文版版权归 Google , 转载此中文版必须以链接形式注明 ...

  3. 使用google chart api生成报表图片

    使用google chart api生成报表图片 截图 折线图 饼图 柱状图   实现方法 原理是调用google的报表服务,动态拼接url字符串,得到一张图片,数据和说明文字都是从url中传进去的. ...

  4. google map api 学习笔记

    (1)地图的缩放监听函数 google.maps.event.addlistener(map,"zoom_change",function(){ 缩放级别变化后的函数. }); ( ...

  5. 转载总结一些关于Google chart api的知识

    <script type="text/javascript">      google.setOnLoadCallback(drawChartLine);      f ...

  6. Google Map API 学习六

    今天其实收货很大的 1.new google.maps.Circle 就是如何在地图上标注一个圆 3.getAnimation 在这里是通过获取Marker是否存在动作,然后如果存在动作的话,就将动作 ...

  7. Google Map API 学习五

    今天其实收货很大的 1.InfoWindow google.maps.InfoWindow class An overlay that looks like a bubble and is often ...

  8. Google Map API学习1

    这一段时间公司一个新产品上线, 做超市代购的 这样,就需要计算每个门店也就是超市,距离小区之间的距离. 我们用的是Google Map 1.批量对地址进行编码,也就是将地址批量转化成对应的Goole ...

  9. 利用 Google Chart API 生成二维码大小不一致

    大小不一致是由于 chl  参数内容不一样导致的,而 chs 参数只能指定生成图片的大小,不能指定生成具体二维码大小. 比如:https://chart.googleapis.com/chart?ch ...

  10. Google Map API 学习六-设置infoWindow的长宽

随机推荐

  1. 官方实锤!AMD真的已经有了大小核:不搞Intel那一套

    Intel 12代酷睿开始引入大小核混合架构,多核跑分提升立竿见影,在游戏.渲染等场景中也有很好的辅助作用,但因为大核心.小核心基于完全不同的架构,需要复杂的系统.软件调度配合,也直接导致失去了AVX ...

  2. workman在线五子棋

    一.下载安装workman,地址:https://github.com/walkor/workerman composer require workerman/workerman 二.cd到worke ...

  3. C++中,new与malloc的区别何在?(代码实验向)

    在C++中,new与malloc()都可用于在堆中分配一块内存.其中,new是C++的语法,而malloc则来自古老的C语言,二者在使用时有何区别? new会调用构造函数,而malloc()不会 假设 ...

  4. 练习(Java):将一个数转换为16进制;获得多位数的各个位上的数

    //将一个数转换为十六进制 int num = 60; int i1 = num % 16; int i2 = num % (16*16) / 16; int i3 = num % (16*16*16 ...

  5. Oracle迁移到MySQL时数据类型转换问题

    最近在做"去O"(去除Oracle数据库)的相关工作,需要将Oracle表结构转换成MySQL的表结构.这里面最重要的一点就是字段数据类型的变化. 1.ORACLE常用的数据类型与 ...

  6. Python def() 后的-> 符号的作用

    python – 定义函数 def 后面的 ->,:表示的含义-> 常常出现在python函数定义的函数名后面,为函数添加元数据,描述函数返回的类型. : 表示参数的类型建议符示例: de ...

  7. 【分布式】load balance 03-一致性哈希算法 java 实现

    负载均衡系列专题 01-负载均衡基础知识 02-一致性 hash 原理 03-一致性哈希算法 java 实现 04-负载均衡算法 java 实现 本节我们来看一下如何实现一个一致性 hash 框架. ...

  8. 服务端渲染SSR的理解

    服务端渲染SSR的理解 SSR服务端渲染Server Side Render就是当进行请求时,页面上的内容是通过服务端渲染生成的,浏览器直接显示服务端返回的HTML即可. 客户端渲染CSR 通常在构建 ...

  9. ElementUI导入Excel文件

    功能介绍 最近用ElementUI做管理系统需要把excel数据导入到系统内,我想这是一个很常见的功能点,把它分享出来,希望对大家有所帮助:) 实现效果 实现步骤 1.定义导入组件 <el-up ...

  10. C++常用快读

    1.快读相关代码 inline int read() { int x=0,f=0; char ch=getchar(); while(!isdigit(ch))f|=(ch=='-'),ch=getc ...