Highcharts(散点)工具提示不起作用

时间:2013-10-05 12:59:43

标签: highcharts

                        chart: {
                            renderTo: 'chart-selection',
                            backgroundColor: null,
                            type: 'scatter'
                        },
                        title: {
                            text: txt + ' (' + title + ')'
                        },
                        plotOptions: {
                            tooltip: {
                                crosshairs: true,
                                headerFormat: '<b>{point.x}</b>',
                                pointFormat: '<b>Volumn : {point.y}</b><br/>Price : {point.price}<br/>Change : {point.change}'
                            }
                        },
                        xAxis: {
                            type: 'datetime'
                        },
                        yAxis: {
                                title: {
                                    text: title
                                },
                                height: 200,
                                lineWidth: 2
                            },
                        series: [{
                                color: 'rgba(100, 100, 200, .5)',
                                data: datax
                            }]

datax = [{x:1381942800000,y:23.000,价格:26.00,更改:0.00},{x:1382029200000,y:45.000,价格:23.000,更改:0.00}];

此代码未显示工具提示

tooltip: {
                            crosshairs: true, 
                            headerFormat: '<b>{point.x}</b>',
                            pointFormat: '<b>Volumn : {point.y}</b><br/>Price : {point.price}<br/>Change : {point.change}'
                        }

3 个答案:

答案 0 :(得分:1)

tooltip属性不是直接在plotOptions下,而是在plotOptions的系列(或散点)子属性中

以下任何更改都应该有效

<强> plotOptions.series.tooltip

plotOptions: {
    series: {
        tooltip: {
            crosshairs: true,
            headerFormat: '<b>{point.x}</b>',
            pointFormat: '<br /><b>Volumn : {point.y}</b><br/>Price : {point.price}<br/>Change : {point.change}'
        }
    }
}

<强> plotOptions.scatter.tooltip

plotOptions: {
    scatter: {
        tooltip: {
            crosshairs: true,
            headerFormat: '<b>{point.x}</b>',
            pointFormat: '<br /><b>Volumn : {point.y}</b><br/>Price : {point.price}<br/>Change : {point.change}'
        }
    }
}

<强> series[i].tooltip

 series: [{
        data: datax,
        tooltip: {
            crosshairs: true,
            headerFormat: '<b>{point.x}</b>',
            pointFormat: '<br /><b>Volumn : {point.y}</b><br/>Price : {point.price}<br/>Change : {point.change}'
        }
    }]

@jsFiddle

答案 1 :(得分:0)

您需要在一般的cofnigruation中使用工具提示,这样您就可以删除plotOptions,并保留工具提示对象:

xAxis: {

},
tooltip:{
    crosshairs: true,
        headerFormat: '<b>{point.x}</b>',
        pointFormat: '<br /><b>Volumn : {point.y}</b><br/>Price : {point.price}<br/>Change : {point.change}'
}

答案 2 :(得分:0)

我处于相同的情况,我错过的是我的index.js文件上的配置调用

Highcharts.setOptions({
plotOptions: {
area: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
arearange: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
areaspline: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
areasplinerange: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
bar: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
boxplot: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
bubble: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
column: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
columnrange: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
errorbar: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
funnel: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
gauge: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
heatmap: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
//line: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
pie: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
polygon: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
pyramid: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
scatter: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
//series: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
solidgauge: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
spline: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
treemap: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
waterfall: { animation: false, enableMouseTracking: false, stickyTracking: true, shadow: false, dataLabels: { style: { textShadow: false } } },
},
chart: {
reflow: false,
events: {
redraw: function () {
}
},
animation: false
},
exporting: {
enabled: false
},
credits: {
enabled: false
},
lang: {
decimalPoint: ',',
thousandsSep: '.'
},
tooltip: {
yDecimals: 2 // If you want to add 2 decimals
}
,
colors: ['rgb(124, 181, 236)']
});

最后我在2天后发现了这个:) ... 我真的很抱歉在这里忙于解决这个愚蠢的问题。在我的index.js上删除了这个配置调用之后,我的所有图表都是&#39;工具提示是固定的。 我希望我可以帮助任何有同样问题的人。

相关问题