html js 扇形统计图_HTML5块状饼图数据可视化统计图表

这篇博客介绍了如何使用HTML5和CSS创建扇形统计图,也称为块状饼图。通过CSS的径向渐变和动画效果,实现了数据可视化的统计图表。文章中提供了具体的CSS代码示例,包括不同颜色区块的定义以及鼠标悬停时的高亮效果。
摘要由CSDN通过智能技术生成

CSS

语言:

CSSSCSS

确定

body {

/* Old browsers */

background: #fff2ad;

/* FF3.6+ */

background: -moz-radial-gradient(center, ellipse cover, #fff2ad 34%, #f5d200 100%);

/* Chrome,Safari4+ */

background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(34%, #fff2ad), color-stop(100%, #f5d200));

/* Chrome10+,Safari5.1+ */

background: -webkit-radial-gradient(center, ellipse cover, #fff2ad 34%, #f5d200 100%);

/* Opera 12+ */

background: -o-radial-gradient(center, ellipse cover, #fff2ad 34%, #f5d200 100%);

/* IE10+ */

background: -ms-radial-gradient(center, ellipse cover, #fff2ad 34%, #f5d200 100%);

/* W3C */

background: radial-gradient(ellipse at center, #fff2ad 34%, #f5d200 100%);

/* IE6-9 fallback on horizontal gradient */

filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#fff2ad', endColorstr='#f5d200', GradientType=1);

}

.block-chart {

height: 400px;

overflow: hidden;

margin: 10px auto;

position: relative;

width: 400px;

}

.block-chart.small {

height: 250px;

width: 250px;

}

.block-chart.long-one {

height: 50px;

width: 600px;

}

.block {

background: white;

display: block;

float: left;

height: 9%;

margin: 0.5%;

position: relative;

width: 9%;

-webkit-animation: twistin 0.8s;

-moz-animation: twistin 0.8s;

-ms-animation: twistin 0.8s;

-o-animation: twistin 0.8s;

animation: twistin 0.8s;

}

.long-one .block {

background: white;

display: block;

float: left;

height: 100%;

margin: 0.1%;

width: 0.8%;

}

.block:hover:before {

/* FF3.6+ */

background: -moz-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 1%, rgba(0, 0, 0, 0.65) 100%);

/* Chrome,Safari4+ */

background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(1%, rgba(0, 0, 0, 0)), color-stop(100%, rgba(0, 0, 0, 0.65)));

/* Chrome10+,Safari5.1+ */

background: -webkit-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 1%, rgba(0, 0, 0, 0.65) 100%);

/* Opera 12+ */

background: -o-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 1%, rgba(0, 0, 0, 0.65) 100%);

/* IE10+ */

background: -ms-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 1%, rgba(0, 0, 0, 0.65) 100%);

/* W3C */

background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 1%, rgba(0, 0, 0, 0.65) 100%);

/* IE6-9 fallback on horizontal gradient */

filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#a6000000', GradientType=1);

content: "";

height: 100%;

opacity: 0.5;

position: absolute;

top: 0;

left: 0;

width: 100%;

}

.block p {

background: black;

background: rgba(0, 0, 0, 0.7);

color: white;

display: none;

font-family: sans-serif;

font-size: 1em;

margin: -1em 0 0 -0.1em;

padding: 0.2em;

position: absolute;

top: 0;

text-align: center;

text-transform: uppercase;

width: auto;

z-index: 101;

}

.block:nth-child(-n+10) p {

top: 100%;

}

.block:nth-child(-n+10) p:after {

border-style: solid;

border-width: 0 5px 5px 5px;

border-color: transparent transparent #000 transparent;

border-color: transparent transparent rgba(0, 0, 0, 0.7) transparent;

height: 0;

margin-top: -5px;

top: 0;

width: 0;

}

.block:nth-child(10n) p,

.block:nth-child(10n-1) p,

.block:nth-child(10n-2) p {

right: 0;

margin: -1em -0.1em 0 0;

}

.block:nth-child(10n) p:after,

.block:nth-child(10n-1) p:after,

.block:nth-child(10n-2) p:after {

left: initial;

right: 0.2em;

}

.block:hover p {

display: block;

}

.long-one .block:hover p {

display: none;

}

.block p:after {

border-style: solid;

border-width: 5px 5px 0 5px;

border-color: #000 transparent transparent transparent;

border-color: rgba(0, 0, 0, 0.7) transparent transparent transparent;

content: "";

position: absolute;

top: 100%;

left: 0.2em;

width: 0;

}

.block.type0 {

background: #da1d52;

}

.block.type1 {

background: #8cc63f;

}

.block.type2 {

background: #44c8f5;

}

.block.type3 {

background: #faa61a;

}

.block.type4 {

background: #812990;

}

.block.type5 {

background: #f68c50;

}

.block.type6 {

background: #da1d52;

}

.block.type7 {

background: #8cc63f;

}

.block.type8 {

background: #44c8f5;

}

.block.type9 {

background: #faa61a;

}

.block.type10 {

background: #812990;

}

.block.type11 {

background: #f68c50;

}

@keyframes twistin {

/* Firefox < 16 */

from {

transform: rotateY(90deg);

}

to {

transform: rotateY(0deg);

}

}

@-moz-keyframes twistin {

/* Safari, Chrome and Opera > 12.1 */

from {

transform: rotateY(90deg);

}

to {

transform: rotateY(0deg);

}

}

@-webkit-keyframes twistin {

/* Internet Explorer */

from {

transform: rotateY(90deg);

}

to {

transform: rotateY(0deg);

}

}

@-ms-keyframes twistin {

/* Opera < 12.1 */

from {

transform: rotateY(90deg);

}

to {

transform: rotateY(0deg);

}

}

@-o-keyframes twistin {

from {

transform: rotateY(90deg);

}

to {

transform: rotateY(0deg);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值