蓝色天空网mbsky.com · 知识 · 实践 · 创造Highcharts · 本地阅读预览
教程 / 前端开发 / Highcharts

Highcharts区域:累计、缺测、平滑和区间

区分填充、正负、普通累计、百分比累计及上下界范围。

本站独立整理的内容草稿。实例显示的是预期结果;浏览器、服务端运行与技术内容验收尚待完成,本页只用于阅读和图文核对。

学完这一章,你能够

区域的量和基线

area将折线到基线之间的区域填充,areaspline平滑插值,arearange表示low/high之间的带。普通叠放、normal累计和percent占比表达不同问题,不能只换一个type后沿用全部解释。

本章实例分别覆盖基本、负值、堆叠、百分比、内部缺测、轴方向、平滑、区间及区间加线。所有原始数值与派生值分开,范围中点并不自动是统计均值。

配置与复核顺序

先核对每个分类/时间与各系列匹配,再选择基线、是否连接缺测和堆叠规则,最后设置颜色、透明度、提示及图例。null保留未知,fillOpacity不能改变业务值。

区间需要highcharts-more和有效low/high。异步例子先检查HTTP再解析JSON,失败保留可读状态;外部JSONP、原始数据和本站本地JSON是不同依赖,不能混报采集状态。

基本区域与格式化

chart.type:area绘制曲线到基线的区域。pointStart规定数值X起点,null保留缺测含义;标签除以1000显示k只是格式化,不应把实际数据也再除一次。

本例两条系列先有缺测,再出现虚构练习数据。默认不连接缺测,普通标记关闭而悬停标记可有独立状态;不要把来源历史统计或文献署名替换成本站真实数据。

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

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

负数区域

三条area系列含正负值。数值轴涵盖零,负点位于零基线另一侧;area本身不会把多条曲线自动相加,重叠填充与堆叠不同。

核对负数仍保存在原始y中,并比较实际plotY与零像素位置。颜色、透明度和系列顺序可能遮挡,不能仅凭一张静态图认定所有点都看得到。

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

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

普通堆叠

stacking:normal按同一X位置累加五条系列,面积边界表示累计值,单条带厚度表示其贡献。分类轴与共享提示应使用一致的分类顺序。

用按钮分别观察normal、percent和null。普通总量与百分比不是同一单位,切换应更新轴标题;取消堆叠恢复各系列自己的基线。

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

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

百分比区域

stacking:percent把当前可见、同组和同X的适用数据按总量换算百分比,原始y保留次数。本站正数案例每个分类的百分比之和为100。

点击百分比按钮后核对percentage及原y,再恢复普通堆叠。零总量、正负混合与隐藏系列的分母需要另外说明和验证,不能把此正数案例推广到任意输入。

本站实际切换到百分比堆叠后的结果:原y仍为次数,轴显示占比。

本站实际切换到百分比堆叠后的结果:原y仍为次数,轴显示占比。
本站实际切换到百分比堆叠后的结果:原y仍为次数,轴显示占比。

内部缺测与浮动说明

null不是0。内部缺测把曲线分成两段,connectNulls只决定是否跨缺口连线,不为缺测补数。spacingBottom是图表内部留白,不是两张图之间的页面间距。

切换连接缺测,观察真实路径分段数量及null仍在;浮动说明指出哪一项缺测。无障碍层可能生成No value透明占位矩形,不代表有一个零值数据点。

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

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

反转区域与可见图例

area结合inverted交换轴方向。两条七分类系列仍是独立半透明填充;yAxis.min:0限定本例的非负数值域。

图例浮动坐标必须落在实际图框内,不能沿用过大的负x使图例跑出页面。副标题使用正式对齐选项,而不是依赖任意CSS定位实现。

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

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

平滑区域

areaspline在点之间使用平滑曲线,并填充到基线;普通area与它的插值不同。fillOpacity控制重叠可辨识程度,共享提示需实际放入chart配置。

观察真实SVG的三次曲线路径与两条半透明区域。平滑只是视觉插值,不表示测量频率提高,也不能保证区间内的每个插值都具有业务意义。

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

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

区间区域与JSON请求

arearange需要highcharts-more,每点用[x,low,high]或相应对象字段。本站实际fetch同目录JSON并核对有限数值、上下界和严格递增时间戳。

历史JSONP服务是外部依赖,不等同普通JSON,更不能下载失败后伪称已取回原数据。本例独立生成31天虚构区间,保留缩放及共享提示,原数据仍列为未取得。

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

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

区间加代表值线

line与arearange分别保留对应时间戳;line的zIndex更高,区间lineWidth为0、fillOpacity为0.3,linkedTo:previous关联图例。

本站代表值明确是(low+high)/2,不把它称为真实平均气温。点击唯一图例时同时隐藏和恢复线与区间;范围中点不一定等于观察样本均值。

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

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

运行代码文件:areas.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={},START=Date.UTC(2026,0,1),DAY=86400000;
const base={chart:{animation:false},title:{text:"蓝色天空网 · mbsky.com"},subtitle:{text:"本站虚构教学数据"},time:{timezone:"UTC"},plotOptions:{series:{animation:false}},colors:["#2563eb","#f97316"],accessibility:{enabled:true}};
function make(id,options){return plots[id]=Highcharts.chart(id,Highcharts.merge(base,options));}
const week=["周一","周二","周三","周四","周五","周六","周日"];
const two=[{name:"HTML5练习",data:[3,4,3,5,4,10,12]},{name:"CSS练习",data:[1,3,4,3,3,5,4]}];
make("missing",{chart:{type:"area",spacingBottom:30},subtitle:{text:"* CSS练习的阶段四为缺测,不是零",floating:true,align:"right",verticalAlign:"bottom",y:15},legend:{layout:"vertical",align:"left",verticalAlign:"top",x:110,y:80,floating:true,borderWidth:1,backgroundColor:"#ffffff"},xAxis:{categories:["一","二","三","四","五","六","七","八"]},yAxis:{title:{text:"练习次数"}},tooltip:{formatter(){return `${this.series.name} · ${this.key}:${this.y}次`;}},plotOptions:{area:{fillOpacity:.5,connectNulls:false}},series:[{name:"HTML5练习",data:[0,1,4,4,5,2,3,7]},{name:"CSS练习",data:[1,0,3,null,3,1,2,1]}]});
document.querySelector("#connect").onclick=()=>plots.missing.series[1].update({connectNulls:!plots.missing.series[1].options.connectNulls});
make("inverted-area",{chart:{type:"area",inverted:true},subtitle:{text:"方向交换;数据含义保持",align:"right",verticalAlign:"bottom"},legend:{layout:"vertical",align:"right",verticalAlign:"top",x:-20,y:70,floating:true,borderWidth:1,backgroundColor:"#fff"},xAxis:{categories:week},yAxis:{min:0,title:{text:"虚构练习次数"}},plotOptions:{area:{fillOpacity:.5}},series:structuredClone(two)});
make("areaspline",{chart:{type:"areaspline"},legend:{layout:"vertical",align:"left",verticalAlign:"top",x:110,y:80,floating:true,borderWidth:1,backgroundColor:"#fff"},xAxis:{categories:week},yAxis:{title:{text:"虚构练习次数"}},tooltip:{shared:true,valueSuffix:" 次"},plotOptions:{areaspline:{fillOpacity:.5}},series:structuredClone(two)});
function validateRange(data){if(!Array.isArray(data)||data.length===0||data.some(row=>!Array.isArray(row)||row.length!==3||row.some(v=>!Number.isFinite(v))||row[1]>row[2]))throw new RangeError("区间要求有限的[x,low,high]且low<=high");for(let i=1;i<data.length;i++)if(data[i][0]<=data[i-1][0])throw new RangeError("时间戳必须严格递增");return data.map(row=>[...row]);}
let generation=0;
async function loadRange(){const n=++generation,status=document.querySelector("#range-status");status.textContent="读取本站JSON中";try{const response=await fetch("fixtures/range.json",{cache:"no-store"});if(!response.ok)throw new Error(`HTTP ${response.status}`);const data=validateRange(await response.json());if(n!==generation)return;if(plots.range)plots.range.destroy();make("range",{chart:{type:"arearange",zooming:{type:"x"}},xAxis:{type:"datetime",crosshair:true},yAxis:{title:{text:null}},legend:{enabled:false},tooltip:{shared:true,valueSuffix:" 虚构单位"},series:[{name:"计划范围",data}]});status.textContent=`已加载${data.length}个真实区间点`;}catch(error){if(n===generation)status.textContent=`加载失败:${error.message}`;}}
document.querySelector("#range-reload").onclick=()=>loadRange();
const ranges=Array.from({length:31},(_,i)=>[START+i*DAY,10+i%6,20+i%6]);
const representative=ranges.map(([x,low,high])=>[x,(low+high)/2]);
make("rangeline",{xAxis:{type:"datetime",crosshair:true},yAxis:{title:{text:"虚构范围单位"}},tooltip:{shared:true,valueSuffix:" 单位"},series:[{id:"representative",name:"区间中点(本站计算)",type:"line",data:representative,zIndex:1,marker:{fillColor:"white",lineWidth:2,lineColor:"#2563eb"}},{name:"计划范围",type:"arearange",data:ranges,linkedTo:":previous",lineWidth:0,color:"#2563eb",fillOpacity:.3,zIndex:0}]});
window.mbskyAreas={plots,validateRange,loadRange};loadRange();

运行代码文件:curves.js

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

javascript · 阅读源码
"use strict";
window.mbskyErrors=[];
window.addEventListener("error",e=>mbskyErrors.push(e.message));
window.addEventListener("unhandledrejection",e=>mbskyErrors.push(String(e.reason)));
const DAY=86400000, START=Date.UTC(2026,0,1), plots={};
const base={chart:{animation:false},title:{text:"蓝色天空网 · mbsky.com"},subtitle:{text:"本站虚构教学数据"},time:{timezone:"UTC"},colors:["#2563eb","#f97316","#10b981","#8b5cf6","#e11d48"],plotOptions:{series:{animation:false}},accessibility:{enabled:true}};
function make(id,opts){return plots[id]=Highcharts.chart(id,Highcharts.merge(base,opts));}
let requestGeneration=0;
async function loadCSV(path="fixtures/weekly.csv"){
 const generation=++requestGeneration;const status=document.querySelector("#csv-status");
 status.textContent="正在读取本站CSV";
 try{
  const response=await fetch(path,{cache:"no-store"});
  if(!response.ok)throw new Error(`HTTP ${response.status}`);
  const csv=await response.text();if(generation!==requestGeneration)return;
  // data模块负责CSV解析;不是jQuery.getJSON,也不会把CSV当JSON。
  if(plots.ajax)plots.ajax.destroy();
  make("ajax",{chart:{type:"line"},data:{csv,beforeParse:text=>text.split(/\r?\n/).filter(line=>line.trim()).join("\n")},xAxis:{type:"datetime",tickInterval:7*DAY,crosshair:true},yAxis:[{min:0,max:120,title:{text:"全部练习 / 次"}},{min:0,max:60,title:{text:"新增练习 / 次"},opposite:true}],tooltip:{shared:true},legend:{layout:"horizontal",align:"center",verticalAlign:"top",floating:false},plotOptions:{series:{cursor:"pointer",point:{events:{click:function(){document.querySelector("#point-detail").textContent=`${this.series.name} · ${Highcharts.dateFormat("%Y-%m-%d",this.x)} · ${this.y} 次(本站虚构数据)`;document.querySelector("#point-dialog").showModal();}}}}},series:[{name:"全部练习",yAxis:0,lineWidth:4,marker:{radius:4}},{name:"新增练习",yAxis:1,lineWidth:2,marker:{radius:2}}]});
  status.textContent="CSV加载成功:6周、2条系列";
 }catch(error){if(generation===requestGeneration)status.textContent=`数据加载失败:${error.message};保留已有图表`;}
}
document.querySelector("#reload").onclick=()=>loadCSV();
document.querySelector("#bad-csv").onclick=()=>loadCSV("fixtures/not-present.csv");
make("time",{chart:{type:"area",zooming:{type:"x"}},xAxis:{type:"datetime",minRange:14*DAY},yAxis:{title:{text:"练习量(虚构)"}},legend:{enabled:false},plotOptions:{area:{threshold:null,marker:{radius:2},fillColor:{linearGradient:{x1:0,y1:0,x2:0,y2:1},stops:[[0,Highcharts.color("#2563eb").setOpacity(.65).get("rgba")],[1,Highcharts.color("#2563eb").setOpacity(.03).get("rgba")]]}}},series:[{name:"每日练习",pointStart:START,pointInterval:DAY,data:Array.from({length:90},(_,i)=>20+Math.sin(i/5)*4+i/10)}]});
document.querySelector("#zoom-reset").onclick=()=>plots.time.zoomOut();
make("inverted",{chart:{type:"spline",inverted:true},xAxis:{reversed:false,title:{text:"练习阶段 / 虚构"}},yAxis:{title:{text:"偏差 / 虚构值"}},plotOptions:{spline:{marker:{enabled:false}}},tooltip:{headerFormat:"",pointFormat:"阶段 {point.x},偏差 {point.y}"},series:[{name:"阶段偏差",data:[[0,15],[10,-50],[20,-56],[30,-46],[40,-22],[50,-3],[60,-18],[70,-48],[80,-75]]}]});
window.invertedBeforeOthers={marker:structuredClone(plots.inverted.series[0].options.marker),enabled:plots.inverted.series[0].options.marker.enabled};document.querySelector("#reverse").onclick=()=>plots.inverted.xAxis[0].update({reversed:!plots.inverted.xAxis[0].reversed});
const months=["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"];
make("symbols",{chart:{type:"spline"},xAxis:{categories:months,crosshair:true},yAxis:{title:{text:"练习次数"},lineWidth:2},tooltip:{shared:true},plotOptions:{spline:{marker:{enabled:true,radius:4,lineColor:"#666666",lineWidth:1}}},series:[{name:"方形默认",marker:{symbol:"square"},data:[2,3,4,6,7,8,9,{y:11,marker:{symbol:"url(fixtures/marker.svg)"}},10,8,7,6]},{name:"菱形默认",marker:{symbol:"diamond"},data:[{y:4,marker:{symbol:"url(fixtures/marker.svg)"}},3,5,6,8,9,10,9,8,7,6,5]}]});
const ranges=[[.3,1.5],[1.5,3.3],[3.3,5.5],[5.5,8],[8,11],[11,14],[14,15]];
make("bands",{chart:{type:"spline"},xAxis:{type:"datetime"},yAxis:{min:0,max:15,title:{text:"虚构练习强度"},gridLineWidth:0,minorGridLineWidth:0,plotBands:ranges.map(([from,to],i)=>({id:`band-${i}`,from,to,color:i%2?"rgba(0,0,0,0)":"rgba(37,99,235,.10)",label:{text:`练习区间${i+1}`,style:{color:"#526078"}}}))},plotOptions:{spline:{lineWidth:4,states:{hover:{lineWidth:5}},marker:{enabled:false},pointStart:START,pointInterval:3600000}},series:[{name:"计划甲",data:Array.from({length:49},(_,i)=>7+5*Math.sin(i/7))},{name:"计划乙",data:Array.from({length:49},(_,i)=>4+3*Math.cos(i/6))}]});
make("irregular",{chart:{type:"spline"},xAxis:{type:"datetime",dateTimeLabelFormats:{month:"%e.%b",year:"%b"},title:{text:"对齐后的练习日期"}},yAxis:{min:0,title:{text:"虚构练习进度"}},tooltip:{headerFormat:"<b>{series.name}</b><br>",pointFormat:"{point.x:%Y-%m-%d}: {point.y:.2f}"},plotOptions:{spline:{marker:{enabled:true}}},series:[{name:"第一期",data:[[Date.UTC(1970,9,27),0],[Date.UTC(1970,10,10),.6],[Date.UTC(1970,11,2),.8],[Date.UTC(1971,0,1),1.2],[Date.UTC(1971,2,4),2.4],[Date.UTC(1971,5,12),0]]},{name:"第二期",data:[[Date.UTC(1970,9,18),0],[Date.UTC(1970,9,26),.2],[Date.UTC(1970,11,1),.5],[Date.UTC(1971,0,8),1.4],[Date.UTC(1971,2,12),1.9],[Date.UTC(1971,5,7),0]]},{name:"第三期",data:[[Date.UTC(1970,9,9),0],[Date.UTC(1970,9,14),.15],[Date.UTC(1970,10,28),.35],[Date.UTC(1971,0,1),.6],[Date.UTC(1971,3,18),.94],[Date.UTC(1971,4,21),0]]}]});
function positive(values){if(values.some(value=>!Number.isFinite(value)||value<=0))throw new RangeError("普通对数轴要求有限正数");return [...values];}
make("logarithmic",{xAxis:{type:"linear",tickInterval:1},yAxis:{type:"logarithmic",minorTickInterval:.1,title:{text:"正数学习规模(虚构)"}},tooltip:{pointFormat:"x={point.x},y={point.y}"},series:[{name:"倍增",pointStart:1,data:positive([1,2,4,8,16,32,64,128,256,512])}]});
document.querySelector("#log-zero").onclick=()=>{try{positive([1,0,4]);}catch(error){document.querySelector("#log-status").textContent=error.message;}};
make("area",{chart:{type:"area"},xAxis:{allowDecimals:false,labels:{formatter(){return String(this.value);}}},yAxis:{title:{text:"虚构练习量"},labels:{formatter(){return `${this.value/1000}k`;}}},tooltip:{pointFormat:"{series.name}:{point.x}年,{point.y:,.0f}次"},plotOptions:{area:{pointStart:2020,connectNulls:false,marker:{enabled:false,radius:2,states:{hover:{enabled:true}}}}},series:[{name:"第一组",data:[null,null,600,1100,1800,2400,3000]},{name:"第二组",data:[null,null,null,400,1200,2100,2600]}]});
make("negative",{chart:{type:"area"},xAxis:{categories:["阶段一","阶段二","阶段三","阶段四","阶段五"]},yAxis:{title:{text:"相对计划偏差"},plotLines:[{value:0,color:"#475569",width:1}]},series:[{name:"HTML5",data:[5,3,4,7,2]},{name:"CSS",data:[2,-2,-3,2,1]},{name:"JavaScript",data:[3,4,4,-2,5]}]});
make("stacked",{chart:{type:"area"},xAxis:{categories:["一","二","三","四","五","六","七"],tickmarkPlacement:"on",title:{text:null}},yAxis:{title:{text:"虚构练习次数"}},tooltip:{shared:true,valueSuffix:" 次"},plotOptions:{area:{stacking:"normal",lineWidth:1,lineColor:"#666666",marker:{lineWidth:1,lineColor:"#666666"}}},series:Array.from({length:5},(_,i)=>({name:`小组${i+1}`,data:Array.from({length:7},(_,j)=>(i+1)*(j+2))}))});
for(const [id,mode]of [["normal","normal"],["percent","percent"],["none",null]])document.querySelector(`#stack-${id}`).onclick=()=>{plots.stacked.series.forEach(series=>series.update({stacking:mode},false));plots.stacked.yAxis[0].setTitle({text:mode==="percent"?"占比 / %":"虚构练习次数"},false);plots.stacked.redraw();};
window.mbskyCurves={plots,DAY,START,positive,loadCSV};
loadCSV().then(()=>document.querySelector("#status").textContent=`Highcharts ${Highcharts.version} · 十类图表已创建;原图和来源完整验收另记`);

本章配置与条件

配置或接口类型/写法用途与准确条件本例或迁移说明
stackingnormal / percent / null累计、占比、不累计原y与percentage分开
connectNulls / threshold / fillOpacityboolean / number或null / 0..1缺口、基线和透明度连接不代表补值
arearange.data[x,low,high]每个x上的上下界需要more,low<=high
linkedTo / zIndex系列关联 / 层级数值范围和线联动并分层图例实际一起显隐

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

html · 阅读源码
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>基本区域与格式化 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-area" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>基本区域与格式化</h1><p>chart.type:area绘制曲线到基线的区域。pointStart规定数值X起点,null保留缺测含义;标签除以1000显示k只是格式化,不应把实际数据也再除一次。</p><iframe title="基本区域与格式化的实际运行图表" src="../curves.html#case-area" style="width:100%;height:650px;border:0"></iframe><p><a href="../curves.html#case-area" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>
基本区域与格式化

所需环境:Windows/Edge156独立会话,Highcharts13.1.1;具体命名检查已有记录,逐来源语义仍待核验

当前源码 SHA256:83be83333b583f632565effce497e9be6758284c810c54f95f439ec5f5832378

预期结果 · 待实际运行核验
  • chart.type:area绘制曲线到基线的区域。pointStart规定数值X起点,null保留缺测含义;标签除以1000显示k只是格式化,不应把实际数据也再除一次。
  • 本例两条系列先有缺测,再出现虚构练习数据。默认不连接缺测,普通标记关闭而悬停标记可有独立状态;不要把来源历史统计或文献署名替换成本站真实数据。

负数区域

html · 阅读源码
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>负数区域 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-negative" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>负数区域</h1><p>三条area系列含正负值。数值轴涵盖零,负点位于零基线另一侧;area本身不会把多条曲线自动相加,重叠填充与堆叠不同。</p><iframe title="负数区域的实际运行图表" src="../curves.html#case-negative" style="width:100%;height:650px;border:0"></iframe><p><a href="../curves.html#case-negative" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>
负数区域

所需环境:Windows/Edge156独立会话,Highcharts13.1.1;具体命名检查已有记录,逐来源语义仍待核验

当前源码 SHA256:89c25449c468612799f3e3d097c97708206b1def4ebe8f1a383f8be825cb9039

预期结果 · 待实际运行核验
  • 三条area系列含正负值。数值轴涵盖零,负点位于零基线另一侧;area本身不会把多条曲线自动相加,重叠填充与堆叠不同。
  • 核对负数仍保存在原始y中,并比较实际plotY与零像素位置。颜色、透明度和系列顺序可能遮挡,不能仅凭一张静态图认定所有点都看得到。

普通堆叠

html · 阅读源码
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>普通堆叠 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-stacked" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>普通堆叠</h1><p>stacking:normal按同一X位置累加五条系列,面积边界表示累计值,单条带厚度表示其贡献。分类轴与共享提示应使用一致的分类顺序。</p><iframe title="普通堆叠的实际运行图表" src="../curves.html#case-stacked" style="width:100%;height:650px;border:0"></iframe><p><a href="../curves.html#case-stacked" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>
普通堆叠

所需环境:Windows/Edge156独立会话,Highcharts13.1.1;具体命名检查已有记录,逐来源语义仍待核验

当前源码 SHA256:58c95724bf517c8c4d2011726dd646022a71bcfd5901b81516296e8dbc587a6c

预期结果 · 待实际运行核验
  • stacking:normal按同一X位置累加五条系列,面积边界表示累计值,单条带厚度表示其贡献。分类轴与共享提示应使用一致的分类顺序。
  • 用按钮分别观察normal、percent和null。普通总量与百分比不是同一单位,切换应更新轴标题;取消堆叠恢复各系列自己的基线。

百分比区域

html · 阅读源码
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>百分比区域 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-stacked" data-mode="percent"><header>蓝色天空网 · mbsky.com</header><main><h1>百分比区域</h1><p>stacking:percent把当前可见、同组和同X的适用数据按总量换算百分比,原始y保留次数。本站正数案例每个分类的百分比之和为100。</p><iframe title="百分比区域的实际运行图表" src="../curves.html#case-stacked" style="width:100%;height:650px;border:0"></iframe><p><a href="../curves.html#case-stacked" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>
百分比区域

所需环境:Windows/Edge156独立会话,Highcharts13.1.1;具体命名检查已有记录,逐来源语义仍待核验

当前源码 SHA256:590643de7a45022fde266c147b52acc4ac7c86a4e7771d5e963b47e3bf2523b0

预期结果 · 待实际运行核验
  • stacking:percent把当前可见、同组和同X的适用数据按总量换算百分比,原始y保留次数。本站正数案例每个分类的百分比之和为100。
  • 点击百分比按钮后核对percentage及原y,再恢复普通堆叠。零总量、正负混合与隐藏系列的分母需要另外说明和验证,不能把此正数案例推广到任意输入。

内部缺测与浮动说明

html · 阅读源码
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>内部缺测与浮动说明 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-missing" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>内部缺测与浮动说明</h1><p>null不是0。内部缺测把曲线分成两段,connectNulls只决定是否跨缺口连线,不为缺测补数。spacingBottom是图表内部留白,不是两张图之间的页面间距。</p><iframe title="内部缺测与浮动说明的实际运行图表" src="../areas.html#case-missing" style="width:100%;height:650px;border:0"></iframe><p><a href="../areas.html#case-missing" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>
内部缺测与浮动说明

所需环境:Windows/Edge156独立会话,Highcharts13.1.1;具体命名检查已有记录,逐来源语义仍待核验

当前源码 SHA256:96ebc82e7d103b11dd721992c989996131304fd94fdeb86ab52cf5d4229b8783

预期结果 · 待实际运行核验
  • null不是0。内部缺测把曲线分成两段,connectNulls只决定是否跨缺口连线,不为缺测补数。spacingBottom是图表内部留白,不是两张图之间的页面间距。
  • 切换连接缺测,观察真实路径分段数量及null仍在;浮动说明指出哪一项缺测。无障碍层可能生成No value透明占位矩形,不代表有一个零值数据点。

反转区域与可见图例

html · 阅读源码
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>反转区域与可见图例 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-inverted-area" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>反转区域与可见图例</h1><p>area结合inverted交换轴方向。两条七分类系列仍是独立半透明填充;yAxis.min:0限定本例的非负数值域。</p><iframe title="反转区域与可见图例的实际运行图表" src="../areas.html#case-inverted-area" style="width:100%;height:650px;border:0"></iframe><p><a href="../areas.html#case-inverted-area" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>
反转区域与可见图例

所需环境:Windows/Edge156独立会话,Highcharts13.1.1;具体命名检查已有记录,逐来源语义仍待核验

当前源码 SHA256:818285c9bb2a98a67412664a1039a2dd23f26875942e52c43f0aa90b6a2bc371

预期结果 · 待实际运行核验
  • area结合inverted交换轴方向。两条七分类系列仍是独立半透明填充;yAxis.min:0限定本例的非负数值域。
  • 图例浮动坐标必须落在实际图框内,不能沿用过大的负x使图例跑出页面。副标题使用正式对齐选项,而不是依赖任意CSS定位实现。

平滑区域

html · 阅读源码
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>平滑区域 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-areaspline" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>平滑区域</h1><p>areaspline在点之间使用平滑曲线,并填充到基线;普通area与它的插值不同。fillOpacity控制重叠可辨识程度,共享提示需实际放入chart配置。</p><iframe title="平滑区域的实际运行图表" src="../areas.html#case-areaspline" style="width:100%;height:650px;border:0"></iframe><p><a href="../areas.html#case-areaspline" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>
平滑区域

所需环境:Windows/Edge156独立会话,Highcharts13.1.1;具体命名检查已有记录,逐来源语义仍待核验

当前源码 SHA256:df34dc721f4fe2adc9a8659c9d26680e0e9b0e701f3a70471c4cdac4cbd29570

预期结果 · 待实际运行核验
  • areaspline在点之间使用平滑曲线,并填充到基线;普通area与它的插值不同。fillOpacity控制重叠可辨识程度,共享提示需实际放入chart配置。
  • 观察真实SVG的三次曲线路径与两条半透明区域。平滑只是视觉插值,不表示测量频率提高,也不能保证区间内的每个插值都具有业务意义。

区间区域与JSON请求

html · 阅读源码
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>区间区域与JSON请求 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-range" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>区间区域与JSON请求</h1><p>arearange需要highcharts-more,每点用[x,low,high]或相应对象字段。本站实际fetch同目录JSON并核对有限数值、上下界和严格递增时间戳。</p><iframe title="区间区域与JSON请求的实际运行图表" src="../areas.html#case-range" style="width:100%;height:650px;border:0"></iframe><p><a href="../areas.html#case-range" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>
区间区域与JSON请求

所需环境:Windows/Edge156独立会话,Highcharts13.1.1;具体命名检查已有记录,逐来源语义仍待核验

当前源码 SHA256:dc9afe29d2c33408959b6a5aae655925ec2591de02eb691e204d081d105b0a43

预期结果 · 待实际运行核验
  • arearange需要highcharts-more,每点用[x,low,high]或相应对象字段。本站实际fetch同目录JSON并核对有限数值、上下界和严格递增时间戳。
  • 历史JSONP服务是外部依赖,不等同普通JSON,更不能下载失败后伪称已取回原数据。本例独立生成31天虚构区间,保留缩放及共享提示,原数据仍列为未取得。

区间加代表值线

html · 阅读源码
<!doctype html>
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>区间加代表值线 | 蓝色天空网 mbsky.com</title><link rel="stylesheet" href="../bootstrap.css"><script defer src="../lesson-view.js"></script></head><body data-section="case-rangeline" data-mode=""><header>蓝色天空网 · mbsky.com</header><main><h1>区间加代表值线</h1><p>line与arearange分别保留对应时间戳;line的zIndex更高,区间lineWidth为0、fillOpacity为0.3,linkedTo:previous关联图例。</p><iframe title="区间加代表值线的实际运行图表" src="../areas.html#case-rangeline" style="width:100%;height:650px;border:0"></iframe><p><a href="../areas.html#case-rangeline" target="_blank" rel="noopener">新窗口打开完整实验</a></p></main></body></html>
区间加代表值线

所需环境:Windows/Edge156独立会话,Highcharts13.1.1;具体命名检查已有记录,逐来源语义仍待核验

当前源码 SHA256:341eb8ffe47a4c7081ee4fe01f7428942d92b15b2079402fdb33424adfe64b87

预期结果 · 待实际运行核验
  • line与arearange分别保留对应时间戳;line的zIndex更高,区间lineWidth为0、fillOpacity为0.3,linkedTo:previous关联图例。
  • 本站代表值明确是(low+high)/2,不把它称为真实平均气温。点击唯一图例时同时隐藏和恢复线与区间;范围中点不一定等于观察样本均值。

常见错误与边界

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

练习与解答

改变本例一个有效值或边界,先写出单位、状态和图形预期,再独立运行核对。

展开参考解答

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

规范与官方依据