Highcharts图例自定义HTML [英] Highcharts Legend Custom HTML

查看:770
本文介绍了Highcharts图例自定义HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图表图表,我希望从用户那里收集有关绘制的每条线的一些数据.我正在尝试在图例中每个标签旁边显示一个带有ID或与系列名称相关的名称的文本输入框.然后,我可以有一个按钮和代码,以将收集的数据提交到其他地方的服务器.

I have a highcharts graph and I'm looking to collect some data from the user about each line graphed. I'm trying to have a text input box with an id or a name related to the series name to appear next to each label in the legend. I could then have a button and code to submit the collected data to the server elsewhere.

我尝试设置labelFormatter函数,但该函数似乎仅支持纯文本.

I've tried setting a labelFormatter function, but that appears to only support plain text.

是否有一种简单的方法可以通过highcharts完成此操作,或者我是否正在寻找将要使用的highchart事件挂钩来编写自己的函数,并添加所需的html?

Is there an easy way to do this with highcharts or am I looking at writing my own function using the highchart event hooks that will go in and add the html I want?

感谢您的帮助. 谢谢!

Any help is appreciated. Thanks!

推荐答案

您可以将Highcharts图例的useHTML选项设置为true.

You can set the useHTML option of Highcharts legend to true.

legend: {
    useHTML: true,
    labelFormatter: function () {
        return '<span title="' + this.name + '">' + this.name + '</span>';
    }
}

http://api.highcharts.com/highcharts/legend.useHTML

这篇关于Highcharts图例自定义HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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