[英]Align label and the marker on the same vertical line(Highcharts)
I want to add a dash like in the red circle from the first point(blue). 我想在第一个点(蓝色)的红色圆圈中添加一个破折号。 Is it possible?
可能吗? Here is my code
这是我的代码
function graph(graph_id, value_array,tool_tip_title, max, min){
$('#'+graph_id).highcharts({
chart: {
type: 'areaspline',
backgroundColor:'transparent'
},
title: {
text: false
},
xAxis: {
type: 'datetime',
labels: {
formatter: function() {
return moment(this.value).format("HH:mm:ss");
}
}
},
yAxis: {
title: {
text: false
},
gridLineColor: 'transparent',
labels:{enabled: true},
gridLineWidth: 0,
minorGridLineWidth: 0,
min: min,
max: max
},
tooltip: {
shared: true
},
credits: {
enabled: false
},
plotOptions: {
areaspline: {
fillOpacity: 1
},
series: {
tooltip: {
dateTimeLabelFormats: {
second:"%A, %b %e, %H:%M:%S"
}
},
marker: {
fillColor: '#3D84B1',
lineWidth: 2,
lineColor: 'white',
radius: 6
}
}
},
series: [{
showInLegend: false,
name: tool_tip_title,
color: "#EC615F",
data: value_array
}]
});
}
I have also tried setting up the startOnTick
to true and min to the least dateTime of x axis but nothing is happening. 我还尝试将
startOnTick
设置为true,并将min设置为x轴的最小dateTime,但没有任何反应。
Highcharts by default calculates some nice dates and sometimes the first possible label/datapoint is not fitting into that 'nice labels' algorithm. Highcharts默认情况下会计算一些不错的日期,有时第一个可能的标签/数据点不适合该“好的标签”算法。 In case you want to display specific labels, use
xAxis.tickPositioner
. 如果要显示特定标签,请使用
xAxis.tickPositioner
。 In your case, I think you can simply add two extra dates, like this: 就您而言,我认为您可以简单地添加两个额外的日期,例如:
tickPositioner: function() {
var tp = this.tickPositions; // get default positions
tp.splice(0, 1, this.min); // replace first label
tp.splice(tp.length - 1, 1, this.max); // replace last label
return tp;
}
Simple demo: http://jsfiddle.net/p98rggva/ 简单的演示: http : //jsfiddle.net/p98rggva/
you can use startOnTick and min as per your minimum data. 您可以根据最小数据使用startOnTick和min。
startOnTick: true,
min: your smallest data of xAxis/in date use first timestamp of sorted data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.