如何将更多数据嵌入烛台HighChart工具提示? [英] How to embed more data to candlestick HighChart tooltip?

查看:281
本文介绍了如何将更多数据嵌入烛台HighChart工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在烛台类型的HighChart工具提示中显示一些自定义数据。我应该怎么做?
我已经找到了其他类型的图表的一些解决方案,但他们不适合我。



如您所知,我们可以访问X ,高,低,关闭和默认打开。但是,我想嵌入例如名称或百分比值以显示在工具提示上的每个点。



如果有人能回答我的问题,我将不胜感激。 / p>

Regards。

解决方案

是的,您绝对可以做到这一点。您可以访问您传递给highcharts的所有数据。



可以说这里是您正在绘制的数据的示例结构。

  {
低:19,
高:30,
开:20,
关闭:28,
pram2:'hi',
param1:'hello'
}

因为您已经知道这里的默认参数分别是打开,关闭,低和高。我们希望在工具提示中显示另外两个称为param1和pram2的prams。因为我们需要让他们在下面显示。



如何从工具提示访问这些参数?
这很简单。

 工具提示:{
格式化程序:function(){
这是一个在工具提示中称为格式化程序的参数。 ........
........
........
返回某物
}
}

这个格式化函数会在您的鼠标移动到图上的一个数据点时被调用。



在这个格式化函数中,您可以以 this.point 的形式访问该点的数据。这里我们的附加参数可以被访问为 this.point.param1 this.point.pram2



此处是一个jsfiddle,它可以帮助您。

I want to show some custom data in my candlestick type of HighChart tooltip. How should I do that? I've found some solutions for other types of charts but they didn't work for me.

As you know, we have access to value of X, high, low, close and open as default. But I want to embed for example "Name" or "Percent" values to each points to show on tooltip.

I'll appreciate if anyone could answer my question.

Regards.

解决方案

Yes you can definitely do that. You can access the all the data you pass to the highcharts.

lets say here is a the sample structure of the data you are plotting.

{
    low: 19,
    high: 30,
    open: 20,
    close: 28,
    pram2: 'hi',
    param1: 'hello'
}

as you already know the default parameters here are open, close, low and high respectively. we want to show 2 more prams called param1 and pram2 in the tooltip. for that we need to have them in the as shown below.

how to access these params from tooltip? it is quite simple. These is a prameter called formatter in tooltip.

tooltip : {
    formatter: function() {
        ........
        ........
        ........
        return something
    }
}

this formatter function gets called every tie your mouse goes on to a data point on the plot.

in this formatter function you can access the data of that point as this.point. here our additional params can be accessed as this.point.param1 and this.point.pram2

here is a jsfiddle that will help you.

这篇关于如何将更多数据嵌入烛台HighChart工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆