2

嗨,我在获取提示显示正确信息时遇到了一些问题。现在它显示这个。

这是一个示例:示例 highstock 工具提示

我想删除出现在日期之前的短语“从星期一开始的一周”。我尝试更改图表选项中的工具提示对象参数,但没有帮助。这是图表选项现在的样子

var options = {
            chart: {
                renderTo: 'stock-chart-container',
                alignTicks: true,
            },
            tooltip: {
                dateTimeLabelFormats: {
                    millisecond: "%A, %b %e, %H:%M:%S.%L",
                    second: "%A, %b %e, %H:%M:%S",
                    minute: "%A, %b %e, %H:%M",
                    hour: "%A, %b %e, %H:%M",
                    day: "%A, %b %e, %Y",
                    week: "%m-%d-%Y",
                    month: "%B %Y",
                    year: "%Y"
                }
            },
            navigator: {
                //top: 400
            },
            yAxis: [{
                    title: {
                        text: 'Price'
                    },
                    top: 70,
                    height: 260,
                    lineWidth: 2
                }, {
                    title: {
                        text: 'Volume'
                    },
                    top: 350,
                    height: 100,
                    offset: 0,
                    lineWidth: 2,
                }],
            rangeSelector: {
                buttons: [{
                        type: 'month',
                        count: 1,
                        text: '1m'
                    }, {
                        type: 'month',
                        count: 3,
                        text: '3m'
                    }, {
                        type: 'month',
                        count: 6,
                        text: '6m'
                    }, {
                        type: 'ytd',
                        text: 'YTD'
                    }, {
                        type: 'year',
                        count: 1,
                        text: '1y'
                    }, {
                        type: 'year',
                        count: 3,
                        text: '3y'
                    }, {
                        type: 'year',
                        count: 5,
                        text: '5y'
                    }, {
                        type: 'all',
                        text: 'All'
                    }],
                selected: null
            },
            title: {
                text: $('#symbol-name').text() + " Stock Price",
            },
            series: [{
                    type: chartGlobalOptions.chartTypes.name,
                    name: $('#symbol-name').text(),
                    data: data.prices,
                    dataGrouping: {
                        units: groupingUnits
                    }
                }, {
                    type: 'column',
                    name: 'Volume',
                    data: data.volume,
                    yAxis: 1,
                    dataGrouping: {
                        units: groupingUnits
                    }
                }]
        };

谁能指出我如何删除该短语的正确方向。我一整天都在努力实现这一目标,但没有成功。

提前致谢

回答

在塞巴斯蒂安的帮助下,我设法让工具提示显示正确的信息。这是现在的样子

tooltip: {
                useHTML: true,
                formatter: function() {
                    var d = new Date(this.x);
                    var s = '';
                    s += '<b>' + Highcharts.dateFormat('%b %e, %Y', this.x) + '</b><br />';
                    $.each(this.points, function(i, point) {
                        s += '<b><span style = "color:'+point.series.color+';">'+point.series.name +' </span>'+' : '+point.y + '</b><br />';
                    });
                    return s;
                },
                shared: true
            },
4

1 回答 1

1

您可以使用工具提示格式化程序,它允许自定义工具提示的内容。

http://api.highcharts.com/highstock#tooltip.formatter

于 2013-11-13T02:01:29.507 回答