Highcharts - 保持工具提示在点击时显示

Highcharts - Keep tooltip showing on click(Highcharts - 保持工具提示在点击时显示)
本文介绍了Highcharts - 保持工具提示在点击时显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 highcharts 图表,我允许用户动态创建他们自己的标志.现在我希望能够单击标志本身并能够一直显示它的工具提示,直到我再次单击该标志.这样做的原因是为了让用户给点赋予特殊的含义,当他们将图形保存为图像时,我希望它显示他们留下的工具提示信息.

I have a highcharts graph, and I allowed the user to dynamically create their own Flags. Now I want to be able to click on the flag itself and be able to keep it's tooltip showing the whole time until I click on the flag again. The reason for this is to allow the user to give special meaning to points, and when they save the graph as an image, I want it to show the tooltip information they left on.

任何人都知道如何做到这一点或去做这件事吗?我不知道如何访问标志工具提示

Anyone know how to do this or go about this? I can't figure out how to access the flags tooltip

plotOptions: {
            series: {
                allowPointSelect: true,
                animation: false,
                dataGrouping: {
                    force: true,
                    smoothed: true
                }
            },
            line: {
                allowPointSelect: true,
                animation: false,
                point: {
                    events: {
                        click: function () {
                            var thePoint = this;
                            var previousFlag = findFlag(thePoint);
                            if (previousFlag != null) {
                                previousFlag.remove();
                            } else {
                                createFlagForm(thePoint);
                            }
                        }
                    }
                }
            },
            flags: {
                point: {
                    events: {
                        click: function() { 
                            //How to access the tooltip? this means the flag point itself
                        }
                    }
                },
                tooltip: {
                    useHTML: true,
                    xDateFormat: "%B-%e-%Y %H:%M"
                }
            }
        },

推荐答案

我刚刚搞定了这个.当您单击一个点时,它将保留工具提示.它通过克隆工具提示 svg 元素并将其附加到绘图来做到这一点.

I just whipped this up. When you click a point it will persist the tooltip. It does this by cloning the tooltip svg element and appending it to the plot.

这是一个小提琴.

$(function () {
    cloneToolTip = null;
    chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container'
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },

        plotOptions: {
            series: {
                cursor: 'pointer',
                point: {
                    events: {
                        click: function() { 
                            if (cloneToolTip)
                            {
                                chart.container.firstChild.removeChild(cloneToolTip);
                            }
                            cloneToolTip = this.series.chart.tooltip.label.element.cloneNode(true);
                            chart.container.firstChild.appendChild(cloneToolTip);
                        }
                    }
                }
            }
        },

        series: [{
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]        
        }]
    });
});​

这篇关于Highcharts - 保持工具提示在点击时显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Update another component when Formik form changes(当Formik表单更改时更新另一个组件)
Formik validation isSubmitting / isValidating not getting set to true(Formik验证正在提交/isValiating未设置为True)
React Validation Max Range Using Formik(使用Formik的Reaction验证最大范围)
Validation using Yup to check string or number length(使用YUP检查字符串或数字长度的验证)
Updating initialValues prop on Formik Form does not update input value(更新Formik表单上的初始值属性不会更新输入值)
password validation with yup and formik(使用YUP和Formick进行密码验证)