markdown 谷歌排行榜
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 谷歌排行榜相关的知识,希望对你有一定的参考价值。
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700);
body {
font-family: "Open Sans", Arial;
background: #EDEDED;
}
main {
width: 600px;
margin: 10px auto;
padding: 10px 40px 30px;
background: #FFF;
box-shadow: 0 3px 5px rgba(0,0,0,0.2);
}
p {
margin-top: 2rem;
font-size: 13px;
}
#bar-chart {
width: 600px;
height: 300px;
position: relative;
}
#line-chart {
width: 600px;
height: 300px;
position: relative;
}
#bar-chart::before, #line-chart::before {
content: "";
position: absolute;
display: block;
width: 220px;
height: 30px;
left: 215px;
top: 254px;
background: #FAFAFA;
box-shadow: 1px 1px 0 0 #DDD;
}
#pie-chart {
width: 500px;
height: 250px;
position: relative;
}
#pie-chart::before {
content: "";
position: absolute;
display: block;
width: 120px;
height: 115px;
left: 315px;
top: 0;
background: #FAFAFA;
box-shadow: 1px 1px 0 0 #DDD;
}
#pie-chart::after {
content: "";
position: absolute;
display: block;
top: 260px;
left: 70px;
width: 170px;
height: 2px;
background: rgba(0,0,0,0.1);
border-radius: 50%;
box-shadow: 0 0 3px 4px rgba(0,0,0,0.1);
}
footer {
position: fixed;
bottom: 0;
right: 0;
font-size: 13px;
background: #DDD;
padding: 5px 10px;
margin: 5px;
}
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawCharts);
function drawCharts() {
// BEGIN BAR CHART
// create zero data so the bars will 'grow'
var barZeroData = google.visualization.arrayToDataTable([
['Day', 'Page Views', 'Unique Views'],
['Sun', 0, 0],
['Mon', 0, 0],
['Tue', 0, 0],
['Wed', 0, 0],
['Thu', 0, 0],
['Fri', 0, 0],
['Sat', 0, 0]
]);
// actual bar chart data
var barData = google.visualization.arrayToDataTable([
['Day', 'Page Views', 'Unique Views'],
['Sun', 1050, 600],
['Mon', 1370, 910],
['Tue', 660, 400],
['Wed', 1030, 540],
['Thu', 1000, 480],
['Fri', 1170, 960],
['Sat', 660, 320]
]);
// set bar chart options
var barOptions = {
focusTarget: 'category',
backgroundColor: 'transparent',
colors: ['cornflowerblue', 'tomato'],
fontName: 'Open Sans',
chartArea: {
left: 50,
top: 10,
width: '100%',
height: '70%'
},
bar: {
groupWidth: '80%'
},
hAxis: {
textStyle: {
fontSize: 11
}
},
vAxis: {
minValue: 0,
maxValue: 1500,
baselineColor: '#DDD',
gridlines: {
color: '#DDD',
count: 4
},
textStyle: {
fontSize: 11
}
},
legend: {
position: 'bottom',
textStyle: {
fontSize: 12
}
},
animation: {
duration: 1200,
easing: 'out'
}
};
// draw bar chart twice so it animates
var barChart = new google.visualization.ColumnChart(document.getElementById('bar-chart'));
barChart.draw(barZeroData, barOptions);
barChart.draw(barData, barOptions);
// BEGIN LINE GRAPH
function randomNumber(base, step) {
return Math.floor((Math.random()*step)+base);
}
function createData(year, start1, start2, step, offset) {
var ar = [];
for (var i = 0; i < 12; i++) {
ar.push([new Date(year, i), randomNumber(start1, step)+offset, randomNumber(start2, step)+offset]);
}
return ar;
}
var randomLineData = [
['Year', 'Page Views', 'Unique Views']
];
for (var x = 0; x < 7; x++) {
var newYear = createData(2007+x, 10000, 5000, 4000, 800*Math.pow(x,2));
for (var n = 0; n < 12; n++) {
randomLineData.push(newYear.shift());
}
}
var lineData = google.visualization.arrayToDataTable(randomLineData);
var animLineData = [
['Year', 'Page Views', 'Unique Views']
];
for (var x = 0; x < 7; x++) {
var zeroYear = createData(2007+x, 0, 0, 0, 0);
for (var n = 0; n < 12; n++) {
animLineData.push(zeroYear.shift());
}
}
var zeroLineData = google.visualization.arrayToDataTable(animLineData);
var lineOptions = {
backgroundColor: 'transparent',
colors: ['cornflowerblue', 'tomato'],
fontName: 'Open Sans',
focusTarget: 'category',
chartArea: {
left: 50,
top: 10,
width: '100%',
height: '70%'
},
hAxis: {
//showTextEvery: 12,
textStyle: {
fontSize: 11
},
baselineColor: 'transparent',
gridlines: {
color: 'transparent'
}
},
vAxis: {
minValue: 0,
maxValue: 50000,
baselineColor: '#DDD',
gridlines: {
color: '#DDD',
count: 4
},
textStyle: {
fontSize: 11
}
},
legend: {
position: 'bottom',
textStyle: {
fontSize: 12
}
},
animation: {
duration: 1200,
easing: 'out'
}
};
var lineChart = new google.visualization.LineChart(document.getElementById('line-chart'));
lineChart.draw(zeroLineData, lineOptions);
lineChart.draw(lineData, lineOptions);
// BEGIN PIE CHART
// pie chart data
var pieData = google.visualization.arrayToDataTable([
['Country', 'Page Hits'],
['USA', 7242],
['Canada', 4563],
['Mexico', 1345],
['Sweden', 946],
['Germany', 2150]
]);
// pie chart options
var pieOptions = {
backgroundColor: 'transparent',
pieHole: 0.4,
colors: [ "cornflowerblue",
"olivedrab",
"orange",
"tomato",
"crimson",
"purple",
"turquoise",
"forestgreen",
"navy",
"gray"],
pieSliceText: 'value',
tooltip: {
text: 'percentage'
},
fontName: 'Open Sans',
chartArea: {
width: '100%',
height: '94%'
},
legend: {
textStyle: {
fontSize: 13
}
}
};
// draw pie chart
var pieChart = new google.visualization.PieChart(document.getElementById('pie-chart'));
pieChart.draw(pieData, pieOptions);
}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<main>
<h2>Beautiful Google Charts</h2>
<h5>Daily Page Hits</h5>
<div id="bar-chart"></div>
<h5>Traffic Over Time</h5>
<div id="line-chart"></div>
<h5>Page Hits per Country</h5>
<div id="pie-chart"></div>
<p>Google Charts can be <a href="https://google-developers.appspot.com/chart/">found here</a>.
</main>
<footer>
An original pen by <a href="https://codepen.io/ejsado/">Eric</a>.
</footer>
Google charts
-------------
A [Pen](https://codepen.io/rramona2/pen/BYOpdL) by [ryan ramona](https://codepen.io/rramona2) on [CodePen](https://codepen.io).
[License](https://codepen.io/rramona2/pen/BYOpdL/license).
以上是关于markdown 谷歌排行榜的主要内容,如果未能解决你的问题,请参考以下文章
谷歌排行榜提交分数错误:必须连接GoogleApiClient