具有不规则时间序列间隔的HighCharts Errorbar
我正试图建立一个样条曲线与误差与xAxis基于不规则的时间,而不是使用类别,但我得到了一些麻烦 这是一个例子: 你知道怎么做到吗 先谢谢你 代码如下:具有不规则时间序列间隔的HighCharts Errorbar,highcharts,time-series,timeserieschart,Highcharts,Time Series,Timeserieschart,我正试图建立一个样条曲线与误差与xAxis基于不规则的时间,而不是使用类别,但我得到了一些麻烦 这是一个例子: 你知道怎么做到吗 先谢谢你 代码如下: var chart; $(function() { $('#container').highcharts({ chart: { zoomType: 'xy', }, title: { text: 'Temperature vs Rainfall' }, xAxis:
var chart;
$(function() {
$('#container').highcharts({
chart: {
zoomType: 'xy',
},
title: {
text: 'Temperature vs Rainfall'
},
xAxis: [{
type: 'datetime'
}],
/*
xAxis: [{
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
}],
*/
yAxis: [{ // Primary yAxis
labels: {
format: '{value} °C',
style: {
color: Highcharts.getOptions().colors[0]
}
},
title: {
text: 'Temperature',
style: {
color: Highcharts.getOptions().colors[0]
}
}
}],
tooltip: {
shared: true
},
series: [{
name: 'Temperature',
type: 'spline',
data: [
[Date.UTC(2014, 5, 10), 7.0],
[Date.UTC(2014, 5, 11), 26.5],
[Date.UTC(2014, 5, 12), 9.6]
],
tooltip: {
pointFormat: '<span style="font-weight: bold; color: {series.color}">{series.name}</span>: <b>{point.y:.1f}°C</b> '
}
}, {
name: 'Temperature error',
type: 'errorbar',
data: [
[Date.UTC(2014, 5, 10), [6, 8]],
[Date.UTC(2014, 5, 11), [26.1, 27.8]],
[Date.UTC(2014, 5, 12), [7.6, 10.0]]
],
tooltip: {
pointFormat: '(error range: {point.low}-{point.high}°C)<br/>'
}
}]
});
var图;
$(函数(){
$(“#容器”)。高图({
图表:{
zoomType:'xy',
},
标题:{
文字:“温度与降雨量”
},
xAxis:[{
键入:“日期时间”
}],
/*
xAxis:[{
类别:[一月、二月、三月、四月、五月、六月、七月、八月、九月、十月、十一月、十二月]
}],
*/
yAxis:[{//主yAxis
标签:{
格式:“{value}°C”,
风格:{
颜色:Highcharts.getOptions().color[0]
}
},
标题:{
文字:“温度”,
风格:{
颜色:Highcharts.getOptions().color[0]
}
}
}],
工具提示:{
分享:真的
},
系列:[{
名称:“温度”,
类型:“样条线”,
数据:[
[UTC日期(2014年5月10日),7.0],
[UTC日期(2014年5月11日),26.5],
[UTC日期(2014年5月12日),9.6]
],
工具提示:{
pointFormat:“{series.name}:{point.y:.1f}°C”
}
}, {
名称:“温度错误”,
键入:“errorbar”,
数据:[
[UTC日期(2014年5月10日),[6月8日]],
[UTC日期(2014年5月11日),[26.1日,27.8],
[UTC日期(2014年5月12日),[7.6日,10.0]]
],
工具提示:{
pointFormat:'(错误范围:{point.low}-{point.high}°C)
}
}]
});
问题在于您在errorbar
系列中使用的数据的格式。正确的格式是使用二维数组,而不是像您在代码中使用的三维数组
本系列中的每一点都是:
[Date.UTC(2014, 5, 10), [6, 8]]
应该是:
[Date.UTC(2014, 5, 10), 6, 8]
以下是最后更新的errorbar
系列:
{
name: 'Temperature error',
type: 'errorbar',
data: [
[Date.UTC(2014, 5, 10), 6, 8],
[Date.UTC(2014, 5, 11), 26.1, 27.8],
[Date.UTC(2014, 5, 12), 7.6, 10.0]
],
tooltip: {
pointFormat: '(error range: {point.low}-{point.high}°C)<br/>'
}
}
{
名称:“温度错误”,
键入:“errorbar”,
数据:[
[UTC日期(2014年5月10日),6月8日],
[UTC日期(2014年5月11日),26.1日,27.8],
[UTC日期(2014年5月12日)、7.6日和10.0日]
],
工具提示:{
pointFormat:'(错误范围:{point.low}-{point.high}°C)
}
}
看看结果