蓝色天空.知识 · 实践 · 创造
我的收藏
Highcharts 教程目录 16章
Highcharts / LEARN BY DOING

Highcharts3D:投影、厚度与数据含义

五种3D变体保留滑块、缺测、堆叠、饼图和环形。

学完这一章,你能够

  • 五种3D变体保留滑块、缺测、堆叠、饼图和环形。
  • 3D投影与原生滑块

依赖与投影

加载highcharts核心再加载相同版本3D模块。alpha/beta调整视角,depth/viewDistance控制图形投影;column和pie仍按原数值进行表示。

原生滑块事件更新数值并重画,当前SVG几何实际变化。不能把一组柱体的透视效果称为第三个独立数据轴。

读取与局限

null与零仍然不同,stack组仍各自求和,饼环仍用原分母。厚度不额外编码数值;内径像素或百分比与depth厚度分开。

3D可能遮挡或夸大前后大小,量化阅读要回到提示和表格。当前电脑Edge交互已按命名范围观察,不能从投影成功推导所有设备、导出或来源事实完整。

3D投影与原生滑块

核心库之后加载highcharts-3d;options3d.enabled、alpha、beta、depth和viewDistance分别设置投影。column.depth是柱体厚度,和图表深度不是同一个字段。

两个range输入把值转换为Number,再更新角度和显示数值。实际SVG几何随滑块改变;数据仍是原本一组数值,不自动成为三维散点数据。

本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。

本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。
本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。

3D中的缺测与零

数组中的null表示未知,没有数值;0表示已知零量。三维外观不改变这一区别,分类仍要与原索引对应。

核对null点isNull为true,而零点不是空值。不得把两者统一过滤或填成0,标签和无障碍占位也不能冒充真实高度。

本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。

本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。
本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。

3D堆叠与独立组

column.stacking:normal与stack名共同决定累计。四系列分两组,当前首分类各组分别为8和5;3D深度仅改变外观。

提示保留段y和本组stackTotal。投影遮挡可能影响读取,应配合图例和数值,不能以厚度、遮挡面积或颜色替代累计值核对。

本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。

本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。
本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。

3D饼图的厚度

chart.type:pie结合3D模块;alpha45和pie.depth35决定投影及厚度。扇区的数值仍按同一分母分配。

初始选中的项可以偏移,名称标签和占比提示分别配置。厚度不代表另一个数据维度,透视也可能让前后面积看起来不同,应按数值比较。

本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。

本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。
本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。

3D环形的两种尺寸

pie.innerSize为100像素内径,本例实际内半径50;depth45是视觉厚度。百分比内径与像素内径不能混写。

曲面遮挡不改变原值,适合说明配置而不应夸大为高精度量化图。真实SVG内圆和厚度均与当前配置核对。

本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。

本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。
本站本例完成对应操作后的实际截图,与本例代码和状态绑定,不计为来源原图。

运行代码文件:gauges.js

下列代码与本章独立工程实际脚本一致;容器、本地数据和模块随工程包保留。

javascript
"use strict";
window.mbskyErrors=[];window.addEventListener("error",e=>mbskyErrors.push(e.message));window.addEventListener("unhandledrejection",e=>mbskyErrors.push(String(e.reason)));
const plots={},timers=new Map(),steps=new Map();const base={chart:{animation:false},title:{text:"蓝色天空网 · mbsky.com"},subtitle:{text:"本站虚构教学数据"},plotOptions:{series:{animation:false}},colors:["#2563eb","#f97316","#10b981","#8b5cf6"],accessibility:{enabled:true}};
function make(id,opts){return plots[id]=Highcharts.chart(id,Highcharts.merge(base,opts));}
const o3={enabled:true,alpha:15,beta:15,depth:50,viewDistance:25};
make("column3d",{chart:{type:"column",options3d:o3,margin:70},plotOptions:{column:{depth:25}},series:[{name:"练习",data:[3,5,7,6,9,10,12,8,9,7,6,5]}]});
for(const key of ["alpha","beta"])document.querySelector(`#${key}`).oninput=e=>{const value=Number(e.target.value);plots.column3d.update({chart:{options3d:{[key]:value}}},true,false);document.querySelector(`#${key}-value`).textContent=String(value);};
make("null3d",{chart:{type:"column",options3d:{...o3,alpha:10,beta:25,depth:70},margin:70},xAxis:{categories:Array.from({length:10},(_,i)=>`阶段${i+1}`)},series:[{name:"练习",data:[2,3,null,4,0,5,1,4,6,3]}]});
make("stack3d",{chart:{type:"column",options3d:{...o3,depth:40},marginTop:70,marginRight:40},xAxis:{categories:["一","二","三","四","五"]},yAxis:{min:0,allowDecimals:false},tooltip:{pointFormat:"{series.name}:{point.y} / 本组{point.stackTotal}"},plotOptions:{column:{stacking:"normal",depth:40}},series:[{name:"甲一",stack:"甲",data:[5,3,4,7,2]},{name:"甲二",stack:"甲",data:[3,4,4,2,5]},{name:"乙一",stack:"乙",data:[2,5,6,2,1]},{name:"乙二",stack:"乙",data:[3,0,4,4,3]}]});
const pie=()=>[40,25,15,10,7,3].map((y,i)=>({name:`练习${i+1}`,y,...(i===2?{selected:true,sliced:true}:{})}));
make("pie3d",{chart:{type:"pie",options3d:{enabled:true,alpha:45,beta:0}},plotOptions:{pie:{depth:35,allowPointSelect:true,cursor:"pointer",dataLabels:{enabled:true,format:"{point.name}"}}},series:[{name:"练习组成",data:pie()}]});
make("donut3d",{chart:{type:"pie",options3d:{enabled:true,alpha:45}},plotOptions:{pie:{innerSize:100,depth:45}},series:[{name:"练习组成",data:pie()}]});
const pane={startAngle:-150,endAngle:150,background:[{backgroundColor:{linearGradient:{x1:0,y1:0,x2:0,y2:1},stops:[[0,"#fff"],[1,"#526078"]]},borderWidth:0,outerRadius:"109%"},{borderWidth:1,outerRadius:"107%"},{backgroundColor:"#eef4ff"},{backgroundColor:"#dce6f3",borderWidth:0,outerRadius:"105%",innerRadius:"103%"}]};
make("gauge",{chart:{type:"gauge"},pane,yAxis:{min:0,max:200,minorTickInterval:"auto",minorTickLength:10,minorTickPosition:"inside",tickLength:10,tickPosition:"inside",labels:{step:2,rotation:"auto"},title:{text:"虚构练习量"},plotBands:[{from:0,to:120,color:"#55bf3b"},{from:120,to:160,color:"#dddf0d"},{from:160,to:200,color:"#df5353"}]},series:[{name:"虚构练习量",data:[80]}]});
for(const [id,max,y,unit]of [["solid-speed",200,80,"练习量"],["solid-rpm",5,1,"虚构倍率"]])make(id,{chart:{type:"solidgauge"},pane:{center:["50%","80%"],size:"130%",startAngle:-90,endAngle:90,background:{backgroundColor:"#eef4ff",innerRadius:"60%",outerRadius:"100%",shape:"arc"}},tooltip:{enabled:false},yAxis:{min:0,max,endOnTick:false,startOnTick:false,stops:[[.1,"#55bf3b"],[.5,"#dddf0d"],[.9,"#df5353"]],lineWidth:0,minorTickInterval:null,tickWidth:0,tickPixelInterval:400,title:{text:unit,y:-60},labels:{y:16}},plotOptions:{solidgauge:{dataLabels:{borderWidth:0,y:5,useHTML:true}}},series:[{name:unit,data:[y],dataLabels:{format:`<div style="text-align:center"><strong>{y:.1f}</strong><br>${unit}</div>`}}]});
function clockValues(date){return {hour:date.getUTCHours()%12+date.getUTCMinutes()/60+date.getUTCSeconds()/3600,minute:date.getUTCMinutes()/5+date.getUTCSeconds()/300,second:date.getUTCSeconds()/5,text:date.toISOString().slice(11,19)+" UTC"};}
make("clock",{chart:{type:"gauge"},pane:{startAngle:0,endAngle:360,background:[{}, {backgroundColor:{radialGradient:{cx:.5,cy:-.4,r:1.9},stops:[[.5,"rgba(255,255,255,.2)"],[.5,"rgba(200,200,200,.2)"]]}}]},yAxis:{min:0,max:12,tickInterval:1,lineWidth:0,showFirstLabel:false,minorTickInterval:"auto",minorTickLength:5,labels:{distance:-20},title:{text:"蓝色天空网 · UTC",y:10}},tooltip:{formatter(){return document.querySelector("#clock-time").textContent;}},series:[{name:"UTC时钟",data:[{id:"hour",y:0,dial:{radius:"60%",baseWidth:4,baseLength:"95%",rearLength:0}},{id:"minute",y:0,dial:{baseLength:"95%",rearLength:0}},{id:"second",y:0,dial:{radius:"100%",baseWidth:1,rearLength:"20%"}}],dataLabels:{enabled:false},animation:false}]});
function setClock(date){const v=clockValues(date);for(const key of ["hour","minute","second"])plots.clock.get(key).update(v[key],false,false);plots.clock.redraw(false);document.querySelector("#clock-time").textContent=v.text;return v;}
function stop(key){if(timers.has(key))clearInterval(timers.get(key));timers.delete(key);document.querySelector("#timer-status").textContent=`活动定时器:${timers.size}`;}
function start(key,fn,period){stop(key);timers.set(key,setInterval(fn,period));document.querySelector("#timer-status").textContent=`活动定时器:${timers.size}`;}
document.querySelector("#clock-live").onclick=()=>{setClock(new Date());start("clock",()=>setClock(new Date()),1000);};document.querySelector("#clock-stop").onclick=()=>stop("clock");document.querySelector("#clock-boundary").onclick=()=>{stop("clock");setClock(new Date("2026-01-01T23:59:59Z"));};document.querySelector("#clock-wrap").onclick=()=>{stop("clock");setClock(new Date("2026-01-02T00:00:00Z"));};setClock(new Date());
const KM_PER_MILE=1.609344;
make("dual-gauge",{chart:{type:"gauge"},pane:{startAngle:-150,endAngle:150},yAxis:[{min:0,max:200,endOnTick:false,lineColor:"#2563eb",lineWidth:2,offset:-25,labels:{distance:-20,rotation:"auto"},title:{text:"km/h"}},{min:0,max:200/KM_PER_MILE,endOnTick:false,lineColor:"#e11d48",lineWidth:2,tickPosition:"outside",minorTickPosition:"outside",offset:-20,labels:{distance:12,rotation:"auto"},title:{text:"mph"}}],series:[{name:"虚构速度",data:[80],dataLabels:{formatter(){return `${this.y.toFixed(1)} km/h<br>${(this.y/KM_PER_MILE).toFixed(1)} mph`;}}}]});
make("vu",{chart:{type:"gauge",height:350,plotBorderWidth:1,plotBackgroundColor:{linearGradient:{x1:0,y1:0,x2:0,y2:1},stops:[[0,"#fff4c6"],[.3,"white"],[1,"#fff4c6"]]}},pane:[{startAngle:-45,endAngle:45,background:null,center:["25%","100%"],size:270},{startAngle:-45,endAngle:45,background:null,center:["75%","100%"],size:270}],yAxis:[0,1].map(i=>({min:-20,max:6,pane:i,tickPosition:"outside",minorTickPosition:"outside",labels:{rotation:"auto",distance:20},plotBands:[{from:0,to:6,color:"#c02316",innerRadius:"100%",outerRadius:"105%"}],title:{text:`VU · ${i?"B":"A"}(模拟)`,y:-40}})),plotOptions:{gauge:{dataLabels:{enabled:false},dial:{radius:"100%"}}},series:[{name:"通道A",data:[-20],yAxis:0},{name:"通道B",data:[-20],yAxis:1}]});
function tick(key){const c=plots[key];if(!c?.series){stop(key);return;}const i=(steps.get(key)||0)+1;steps.set(key,i);if(key==="vu"){c.series[0].points[0].update(-20+(i*2)%27,false,false);c.series[1].points[0].update(-20+(i*3)%27,false,false);}else{const max=c.yAxis[0].max;c.series[0].points[0].update((i*(max===5?.2:7))%max,false,false);}c.redraw(false);}
const moving=["gauge","solid-speed","solid-rpm","dual-gauge","vu"];
document.querySelector("#start").onclick=()=>moving.forEach(key=>{if(plots[key]?.series)start(key,()=>tick(key),300);});document.querySelector("#stop").onclick=()=>moving.forEach(stop);document.querySelector("#step").onclick=()=>moving.forEach(tick);document.querySelector("#gauge-destroy").onclick=()=>{stop("gauge");plots.gauge.destroy();document.querySelector("#gauge").textContent="此仪表已销毁;重新打开页面可恢复。";};window.addEventListener("pagehide",()=>[...timers.keys()].forEach(stop));
window.mbskyGauges={plots,timers,steps,start,stop,tick,clockValues,setClock,KM_PER_MILE};

3D配置

配置或接口类型/写法用途与准确条件本例或迁移说明
chart.options3denabled/alpha/beta/depth/viewDistance投影开关、角度和深度需相同版本3D模块
column.depth / pie.depthnumber柱厚度 / 饼厚度不改变原值
pie.innerSize像素或百分比环形内径100像素对应半径50

本章独立核心源码与验证步骤

含完整源码 · 3 行
展开查看收起
html
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>3D投影与原生滑块 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-column3d" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>3D投影与原生滑块</h1><p>核心库之后加载highcharts-3d;options3d.enabled、alpha、beta、depth和viewDistance分别设置投影。column.depth是柱体厚度,和图表深度不是同一个字段。</p><iframe title="3D投影与原生滑块的实际运行图表" src="../gauges.html#case-column3d" style="width:100%;height:650px;border:0"></iframe><p><a href="../gauges.html#case-column3d" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>

尝试一下 ↗ 在独立页面修改并运行

  • 核心库之后加载highcharts-3d;options3d.enabled、alpha、beta、depth和viewDistance分别设置投影。column.depth是柱体厚度,和图表深度不是同一个字段。
  • 两个range输入把值转换为Number,再更新角度和显示数值。实际SVG几何随滑块改变;数据仍是原本一组数值,不自动成为三维散点数据。

3D中的缺测与零

含完整源码 · 3 行
展开查看收起
html
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>3D中的缺测与零 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-null3d" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>3D中的缺测与零</h1><p>数组中的null表示未知,没有数值;0表示已知零量。三维外观不改变这一区别,分类仍要与原索引对应。</p><iframe title="3D中的缺测与零的实际运行图表" src="../gauges.html#case-null3d" style="width:100%;height:650px;border:0"></iframe><p><a href="../gauges.html#case-null3d" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>

尝试一下 ↗ 在独立页面修改并运行

  • 数组中的null表示未知,没有数值;0表示已知零量。三维外观不改变这一区别,分类仍要与原索引对应。
  • 核对null点isNull为true,而零点不是空值。不得把两者统一过滤或填成0,标签和无障碍占位也不能冒充真实高度。

3D堆叠与独立组

含完整源码 · 3 行
展开查看收起
html
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>3D堆叠与独立组 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-stack3d" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>3D堆叠与独立组</h1><p>column.stacking:normal与stack名共同决定累计。四系列分两组,当前首分类各组分别为8和5;3D深度仅改变外观。</p><iframe title="3D堆叠与独立组的实际运行图表" src="../gauges.html#case-stack3d" style="width:100%;height:650px;border:0"></iframe><p><a href="../gauges.html#case-stack3d" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>

尝试一下 ↗ 在独立页面修改并运行

  • column.stacking:normal与stack名共同决定累计。四系列分两组,当前首分类各组分别为8和5;3D深度仅改变外观。
  • 提示保留段y和本组stackTotal。投影遮挡可能影响读取,应配合图例和数值,不能以厚度、遮挡面积或颜色替代累计值核对。

3D饼图的厚度

含完整源码 · 3 行
展开查看收起
html
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>3D饼图的厚度 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-pie3d" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>3D饼图的厚度</h1><p>chart.type:pie结合3D模块;alpha45和pie.depth35决定投影及厚度。扇区的数值仍按同一分母分配。</p><iframe title="3D饼图的厚度的实际运行图表" src="../gauges.html#case-pie3d" style="width:100%;height:650px;border:0"></iframe><p><a href="../gauges.html#case-pie3d" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>

尝试一下 ↗ 在独立页面修改并运行

  • chart.type:pie结合3D模块;alpha45和pie.depth35决定投影及厚度。扇区的数值仍按同一分母分配。
  • 初始选中的项可以偏移,名称标签和占比提示分别配置。厚度不代表另一个数据维度,透视也可能让前后面积看起来不同,应按数值比较。

3D环形的两种尺寸

含完整源码 · 3 行
展开查看收起
html
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>3D环形的两种尺寸 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-donut3d" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>3D环形的两种尺寸</h1><p>pie.innerSize为100像素内径,本例实际内半径50;depth45是视觉厚度。百分比内径与像素内径不能混写。</p><iframe title="3D环形的两种尺寸的实际运行图表" src="../gauges.html#case-donut3d" style="width:100%;height:650px;border:0"></iframe><p><a href="../gauges.html#case-donut3d" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>

尝试一下 ↗ 在独立页面修改并运行

  • pie.innerSize为100像素内径,本例实际内半径50;depth45是视觉厚度。百分比内径与像素内径不能混写。
  • 曲面遮挡不改变原值,适合说明配置而不应夸大为高精度量化图。真实SVG内圆和厚度均与当前配置核对。

本章附件与实例包

下载课程关联工程包:Highcharts

课程关联工程包(登记关联16章) · 含当前章节或实例 · mbskycom202611a515.zip

常见错误与边界检查

  • 把配置名、SVG节点或成功加载当成全部教学行为。
  • 把本站合成数据、重写实例及自制图称为原始采集成功。

技术规范与官方资料

练习与参考解答

查看参考解答

分别核对数据、轴/系列映射、可见几何、交互和资源清理,不只看退出码。

SITE SEARCH

搜索教程、工具与资讯

热门搜索

JavaScriptJSON格式化正则表达式AI 编程AI 翻译AI导航专题标签
Esc 关闭

欢迎登录蓝色天空网

使用会员账号,继续你的学习