highcharts3D蛋糕图 双饼图可旋转

效果图:

代码:

<!DOCTYPE html>

<html>

 

<head>

<meta charset="utf-8" />

<link rel="icon" href="https://jscdn.com.cn/highcharts/images/favicon.ico" />

<meta name="viewport" content="width=device-width, initial-scale=1" />

<style>

/* css 代码 */

</style>

<script src="https://code.highcharts.com.cn/highcharts/highcharts.js"></script>

<script src="https://code.highcharts.com.cn/highcharts/highcharts-3d.js"></script>

<script src="https://code.highcharts.com.cn/highcharts/modules/exporting.js"></script>

<script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>

</head>

 

<body>

<div id="container" style="height: 400px"></div>

<script>

var colors = Highcharts.getOptions().colors,

categories = ["Chrome", "Firefox", "IE"],

data = [{

y: 50,

color: colors[3],

drilldown: {

name: "Chrome",

categories: [

"Chrome v65.0",

"Chrome v64.0",

"Chrome v63.0",

],

data: [2, 2, 2],

},

}, {

y: 50,

color: colors[4],

drilldown: {

name: "Firefox",

categories: [

"Firefox v58.0",

"Firefox v57.0",

"Firefox v56.0",

],

data: [2, 2, 2],

},

}, {

y: 50,

color: colors[5],

drilldown: {

name: "IE",

categories: ["IEV11", "IEv10.0", "IEv9.0"],

data: [2, 2, 2],

},

}, ],

browserData = [],

versionsData = [],

i,

j,

dataLen = data.length,

drillDataLen,

brightness;

var rotateNum = -90,

rotateTimer;

// Build the data arrays

for (i = 0; i < dataLen; i += 1) {

// add browser data

browserData.push({

name: categories[i],

y: data[i].y,

color: data[i].color

});

// add version data

drillDataLen = data[i].drilldown.data.length;

for (j = 0; j < drillDataLen; j += 1) {

brightness = 0.2 - j / drillDataLen / 5;

versionsData.push({

name: data[i].drilldown.categories[j],

y: data[i].drilldown.data[j],

color: Highcharts.Color(data[i].color)

.brighten(brightness)

.get(),

});

}

}


 

var option = {

chart: {

type: "pie",

options3d: {

enabled: true,

alpha: 60,

beta: 0,

depth: 0,

},

// events: {

// load: startRotate

// },

},

yAxis: {

title: {

text: "Total percent market share",

},

},

plotOptions: {

pie: {

stacking: "normal",

allowPointSelect: true,

// innerSize:40,

shadow: false,

depth: 120,

center: ["50%", "50%"],

},

series: {

animation: false

}

},

tooltip: {

valueSuffix: "%",

},

series: [{

name: "Browsers",

data: browserData,

size: "66%",

zIndex: 99,

center: ["50%", "25%"],

startAngle: rotateNum,

dataLabels: {

formatter: function() {

return this.y > 1 ? this.point.name : null;

},

color: "#ffffff",

distance: -30,

},

}, {

name: "Versions",

data: versionsData,

size: "100%",

innerSize: "66%",

zIndex: 1,

startAngle: rotateNum,

dataLabels: {

formatter: function() {

// display only if larger than 1

return this.y > 1 ?

"<b>" +

this.point.name +

":</b> " +

this.y +

"%" :

null;

},

distance: 30,

zIndex: 2,

},

id: "versions",

}, ],

}

var chart = Highcharts.chart('container', option);

 

function xingYongPie() {

// Create the chart

// var chart = Highcharts.chart("container", option);

}

window.onload = function() {

xingYongPie();

 

setTimeout(startRotate, 500);

};

 

function rotate() {

console.log(rotateNum)

rotateNum = rotateNum + 5;

 

if (rotateNum == 270) {

rotateNum = -90;

}

option.series[0].startAngle = rotateNum;

option.series[1].startAngle = rotateNum;

Highcharts.chart('container', option);

}

 

function startRotate() {

rotateTimer = setInterval(rotate, 500);

}

 

function stopRotate() {

clearInterval(rotateTimer);

 

rotateTimer = null;

}

</script>

</body>

 

</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值