2014-11-03 34 views
0

我尝试使用水平十字线作为某种辅助线来比较错误条的上下端点。Highcharts errorors with corsshairs

从统计的角度来看,它是通过比较置信区间进行某种虚拟显着性检验。

我的问题是,给出一个柱形图我不能达到与十字线的错误条的下端点。

这里is a fiddle(来自Highcharts的简化演示)。

var chart; 
$(function() { 
    $('#container').highcharts({ 
    chart: { 
     zoomType: 'xy' 
    }, 
    title: { 
     text: 'Temperature vs Rainfall' 
    }, 
    xAxis: [{ 
     categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] 
    }], 
    yAxis: [{ 
     title: { 
      text: 'Rainfall', 
      style: { 
       color: Highcharts.getOptions().colors[0] 
      } 
     }, 
     labels: { 
      format: '{value} mm', 
      style: { 
       color: Highcharts.getOptions().colors[0] 
      } 
     } 
    }], 
    tooltip:{ 
     crosshairs: [false, {color: 'red'}], 
     formatter: function(){ 
      return false; 
     } 

    }, 
    series: [{ 
     name: 'Rainfall', 
     type: 'column', 
     yAxis: 0, 
     data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], 
    }, { 
     name: 'Rainfall error', 
     type: 'errorbar', 
     yAxis: 0, 
     data: [[42, 51], [66, 73], [90, 110], [128, 136], [140, 150], [171, 179], [135, 143], [142, 149], [204, 220], [189, 199], [90, 110], [52, 56]], 
    }] 
    }); 
}); 

欢迎任何建议!

+0

我不知道这将如何告诉你任何东西,除非你的错误都是以相同的y值为中心。如果是这样的话,我认为使用plotLine显示单个参考线或适当格式化线条系列会更好。 – jlbriggs 2014-11-03 21:40:18

回答

0

错误栏是SVG中的路径,所以没有像低/高部分那样的东西。如果您检查highcharts.src.js文件并搜索drawCrosshair,您会发现负责渲染十字线的方法。正如你所看到的,有行:

pos = (this.chart.inverted != this.horiz) ? point.plotX : this.len - point.plotY; 

这需要point.plotY得到的十字线的位置。在错误栏中,plotY是最重要的一点。如果您将point.plotY替换为point.lowPlot(仅适用于错误栏!),则您将在错误栏的底部显示十字准线。