The*_*apa 1 javascript css jquery highcharts
当屏幕调整大小时,我无法让我的 highcharts 仪表的tootlip出现并保持可见并在仪表内居中。
在我的小提琴中,您可以看到工具提示出现,然后在一段时间后消失。此外,调整窗口大小时,它不会留在仪表的中心。
任何帮助表示赞赏。我的JSFIDDLE在这里。
gaugeChartObj = new Highcharts.Chart({
credits: false,
chart: {
renderTo: divID,
type: 'solidgauge',
marginTop: 30,
events: {
load: function(){
var p = this.series[0].points[0];
this.tooltip.refresh(p);
}
}
},
title: {
text: dataC.title,
style: {
fontSize: '16px'
}
},
exporting: {
enabled: false
},
tooltip: {
borderWidth: 0,
backgroundColor: 'none',
useHTML: true,
shadow: false,
style: {
fontSize: '16px'
},
formatter: function() {
return '<div style="width:100%;text-align:center;"><span style="font-size:1.2em;font-weight:bold;">' + this.point.series.name + '</span><br/><span style="font-size:3em;color:' + Highcharts.getOptions().colors[0] + ';font-weight:bold;">' + Highcharts.numberFormat(this.y / 10, 0) + '</span>';
},
positioner: function (labelWidth) {
return {
x: 170 - labelWidth / 2,
y: 125
};
}
},
pane: {
startAngle: 0,
endAngle: 360,
background: [{
outerRadius: '106%',
innerRadius: '94%',
backgroundColor: Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0.3).get(),
borderWidth: 0
}]
},
yAxis: {
min: 0,
max: 100,
lineWidth: 0,
tickPositions: []
},
plotOptions: {
solidgauge: {
borderWidth: '12px',
dataLabels: {
enabled: false
},
linecap: 'round',
stickyTracking: true
}
},
series: [{
name: 'Subscriptions',
borderColor: Highcharts.getOptions().colors[0],
data: [{
color: Highcharts.getOptions().colors[0],
radius: '100%',
innerRadius: '100%',
y: dataC.seriesData
}]
}],
lang: {
noData: "No data to display"
},
noData: {
style: {
fontWeight: 'bold',
fontSize: '15px',
color: '#333333'
}
}
});
Run Code Online (Sandbox Code Playgroud)
您可以使用 dataLabels 而不是工具提示在您的solidgauge 图表中显示居中的信息:http ://api.highcharts.com/highcharts/plotOptions.solidgauge.dataLabels
dataLabels: {
enabled: true,
y: -40,
borderWidth: 0,
backgroundColor: 'none',
useHTML: true,
shadow: false,
style: {
fontSize: '16px'
},
formatter: function() {
return '<div style="width:100%;text-align:center;"><span style="font-size:1.2em;font-weight:bold;">' + this.point.series.name + '</span><br/><span style="font-size:3em;color:' + Highcharts.getOptions().colors[0] + ';font-weight:bold;">' + Highcharts.numberFormat(this.y / 10, 0) + '</span>';
}
},
Run Code Online (Sandbox Code Playgroud)
在这里你可以看到它是如何工作的一个例子:http : //jsfiddle.net/ujmxxf03/10/