jquery - Highstocks 工具提示删除短语 "Week From Monday"

标签 jquery highcharts

您好,我在让提示显示正确信息时遇到一些问题。现在它显示这个。

这里是一个示例:sample highstock tooltip

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

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
            },

最佳答案

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

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

关于jquery - Highstocks 工具提示删除短语 "Week From Monday",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19932556/

相关文章:

jquery - 帮助在 Jquery 中将数组操作为新数组

javascript - 具有 id 的多个文本的 1 个按钮切换

javascript - 获取特定刻度值的所有积分

highcharts - 条形图上的 slider

javascript - Highcharts : endOnTick not finishing with the max extreme set for xaxis

javascript - 导出旁边的自定义按钮与 To : of the range picker 重叠

javascript - 当运行 WebMatrix 的站点访问时,是否有任何 protected 文件类型会返回 404?

javascript - DataTables初始化后如何更改数据?

javascript - Bootstrap 表 : sort by date field

javascript - Highcharts 可以制作发散图吗?