简体   繁体   English

在highcharts中使用长系列的奇怪工具提示行为

[英]Strange tooltip behavior with long series in highcharts

I'm using Highcharts for a project in which I have to display two series with about a thousand points each. 我正在使用Highcharts进行一个项目,其中我必须展示两个系列,每个系列大约有一千个点。 The x-axis represents a date, and the y-axis a quantity. x轴表示日期,y轴表示数量。 In addition, each point has an associated list of namesMy data is day-by-day without gaps, with a structure such as 此外,每个点都有一个相关的名称列表。我的数据是每天没有间隙的,具有如下结构

var mydata = [ ...
               {x: theDate, y: theValue, names: theNames},
               ... ]

where theNames is an array of strings. 其中theNames是一个字符串数组。 I can access these in the tooltip formatter through this.points.point.names , given that the range displayed on the chart is small enough . 我可以通过this.points.point.names在工具提示格式化程序中访问这些, 因为图表上显示的范围足够小 If I change the x-axes so that the start date and end date are more than roughly a year apart, then the tooltip is not rendered at all. 如果我更改x轴以使开始日期和结束日期相隔大约一年,则根本不会渲染工具提示。

One of the possible avenues that I have tried but failed with so far is setting the turboThreshold limit to the length of the longest series plus 1. Setting this lets me at least display a graph when mydata.length > 1000 (the default value). 到目前为止,我尝试但失败的可能途径之一是将turboThreshold限制设置为最长系列的长度加1.设置此项允许我至少在mydata.length > 1000 (默认值)时显示图形。 However, this only displays the tooltip if the x-axis range is less than 261. Otherwise, the tooltip disappears entirely, as does the point.data object where I'm getting the name from. 但是,如果x轴范围小于261,则仅显示工具提示。否则,工具提示将完全消失,我从中获取名称的point.data对象也是point.data

I'm also not great at JavaScript, but I was wondering if there were a way to separate the names of the points from the array containing them (in my examples, myData1 and myData2 ) and somehow access those names from the tooltip function without going through the current point. 我也不擅长JavaScript,但我想知道是否有办法将点的名称与包含它们的数组分开(在我的示例中, myData1myData2 )并以某种方式从工具提示函数中访问这些名称而不进行通过目前的观点。

Here is the link to the jsFiddle demonstrating this issue. 以下是jsFiddle演示此问题的链接。

All help is appreciated! 所有帮助表示赞赏!

The problem is in dataGrouping, when disabled works fine: http://jsfiddle.net/34tfg/1/ 问题出在dataGrouping中,当禁用时工作正常: http//jsfiddle.net/34tfg/1/

DataGrouping is method in Highcharts to approximate points and display them when width of the chart is not enough, eg how to display 10 000points in a chart of width 1 000px -> 10 points in a one pixel..? DataGrouping是Highcharts中的方法,用于近似点并在图表宽度不足时显示它们,例如如何在宽度为1 000px - > 1个像素的10个点的图表中显示10 000个点。 And when dataGrouping is used, new points are created, so all your custom options like 'names' etc. are lost (at least not accessible). 当使用dataGrouping时,会创建新的点,因此所有自定义选项(如“名称”等)都会丢失(至少无法访问)。

Code: 码:

    plotOptions: {
        line: {
            dataGrouping: {
                enabled: false
            },
            turboThreshold: 10000
        }
    },

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM